{"_id":"unicode-trie@3.0.0","bugs":{"url":"https://github.com/devongovett/unicode-trie/issues"},"dist":{"shasum":"1c8aa406bd8e1510baa7cf7c23e6cb65bebe9a33","tarball":"http://registry-npm.ywwl.com/unicode-trie/download/unicode-trie-3.0.0.tgz","fileCount":11,"integrity":"sha512-Cy+7EIpopVQ7ZCVZ8dFo1fmTk1lHMNxY62SeEhxsVEmISZEryEGgKSLzz6z6pquJXXopamfpi2AzsDCJ7KmAOA==","signatures":[{"sig":"MEUCIQDAM8TgHxHWKCCgnSlozs3ATUSuvU7VHAtxhD3h1fCsKAIgcRDROx2ImffCy5+sQ/jsdWkANaLu2YFTKj7hQ873YMg=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIErxXAdQhKc/iSEQ9Vhj0p6BWTfOsTOh0eDYuOG3/Qt/AiEApn7YpAxwjyJCGClgMeph/Zh+21jW5Dz/R5XC+2jxO9I="}],"unpackedSize":51158,"size":13155,"noattachment":false,"key":"/unicode-trie/-/unicode-trie-3.0.0.tgz"},"main":"index.js","name":"unicode-trie","type":"module","author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"engines":{"node":">=20.17.0"},"exports":{".":"./index.js","./builder":"./builder.js","./builder.js":"./builder.js"},"gitHead":"b0f97b95700c59ea742bfad532b30393b1bd6ea3","imports":{"#zlib":{"node":"./lib/zlib/node.js","default":"./lib/zlib/browser.js"}},"license":"MIT","scripts":{"test":"mocha","coverage":"nyc mocha"},"version":"3.0.0","_npmUser":{"name":"blikblum-dev","email":"camara_luiz@yahoo.com.br"},"homepage":"https://github.com/devongovett/unicode-trie","repository":{"url":"git://github.com/devongovett/unicode-trie.git","type":"git"},"_npmVersion":"11.6.2","description":"Unicode Trie data structure for fast character metadata lookup, ported from ICU","directories":{},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"},{"name":"blikblum-dev","email":"camara_luiz@yahoo.com.br"}],"_nodeVersion":"24.12.0","dependencies":{"fflate":"^0.8.3"},"_hasShrinkwrap":false,"devDependencies":{"nyc":"^18.0.0","mocha":"^12.0.2"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/unicode-trie_3.0.0_1791580636419_0.5778329994564697"},"readme":"# unicode-trie\nA data structure for fast Unicode character metadata lookup, ported from ICU\n\n## Background\n\nWhen implementing many Unicode algorithms such as text segmentation,\nnormalization, bidi processing, etc., fast access to character metadata\nis crucial to good performance.  There over a million code points in the\nUnicode standard, many of which produce the same result when looked up,\nso an array or hash table is not appropriate - those data structures are\nfast but would require a lot of memory.  The data is generally\ngrouped in ranges, so you could do a binary search, but that is not\nfast enough for some applications.\n\nThe [International Components for Unicode](http://site.icu-project.org) (ICU) project\ncame up with a data structure based on a [Trie](http://en.wikipedia.org/wiki/Trie) that provides fast access\nto Unicode metadata.  The range data is precompiled to a serialized\nand flattened trie, which is then used at runtime to lookup the necessary\ndata.  According to my own tests, this is generally at least 50% faster\nthan binary search, with not too much additional memory required.\n\n## Installation\n\n    npm install unicode-trie\n\n## Building a Trie\n\nUnicode Tries are generally precompiled from data in the Unicode database\nfor faster runtime performance.  To build a Unicode Trie, use the\n`UnicodeTrieBuilder` class.\n\n```js\nimport { UnicodeTrieBuilder } from 'unicode-trie/builder';\nimport fs from 'fs';\n\n// create a trie\nlet t = new UnicodeTrieBuilder();\n\n// optional parameters for default value, and error value\n// if not provided, both are set to 0\nt = new UnicodeTrieBuilder(10, 999);\n\n// set individual values and ranges\nt.set(0x4567, 99);\nt.setRange(0x40, 0xe7, 0x1234);\n\n// you can lookup a value if you like\nt.get(0x4567); // => 99\n\n// get a compiled trie (returns a UnicodeTrie object)\nconst trie = t.freeze();\n\n// write compressed trie to a binary file\nfs.writeFileSync('data.trie', t.toBuffer());\n```\n\n## Using a precompiled Trie\n\nOnce you've built a precompiled trie, you can load it into the\n`UnicodeTrie` class, which is a readonly representation of the\ntrie.  From there, you can lookup values.\n\n```js\nimport { UnicodeTrie } from 'unicode-trie';\nimport fs from 'fs';\n\n// load serialized trie from binary file\nconst data = fs.readFileSync('data.trie');\nconst trie = new UnicodeTrie(data);\n\n// lookup a value\ntrie.get(0x4567); // => 99\n```\n\n## CommonJS Compatibility\n\nThe package is published as an ECMAScript module (ESM). To [load it using `require()`](https://nodejs.org/api/modules.html#loading-ecmascript-modules-using-require), Node.js 20.17.0 or later is required.\n\n```js\n// Example of loading the package using require() in Node.js 20.17.0 or higher\nconst { UnicodeTrieBuilder } = require('unicode-trie/builder');\nconst { UnicodeTrie } = require('unicode-trie');\nconst fs = require('fs');\n```\n \n## License\n\nMIT\n","publish_time":1791580636519,"_cnpm_publish_time":1791580636519,"dist-tags":{"latest":"3.0.0"}}