{"name":"unicode-trie","version":"1.0.0","description":"Unicode Trie data structure for fast character metadata lookup, ported from ICU","devDependencies":{"mocha":"^6.1.4","nyc":"^14.1.1"},"scripts":{"test":"mocha","coverage":"nyc mocha"},"repository":{"type":"git","url":"git://github.com/devongovett/unicode-trie.git"},"author":{"name":"Devon Govett","email":"devongovett@gmail.com"},"license":"MIT","bugs":{"url":"https://github.com/devongovett/unicode-trie/issues"},"homepage":"https://github.com/devongovett/unicode-trie","dependencies":{"pako":"^0.2.5","tiny-inflate":"^1.0.0"},"gitHead":"cc87aecf5f5222fbc2f9cfa60904c29c91156826","_id":"unicode-trie@1.0.0","_nodeVersion":"12.0.0","_npmVersion":"6.9.0","dist":{"integrity":"sha512-v5raLKsobbFbWLMoX9+bChts/VhPPj3XpkNr/HbqkirXR1DPk8eo9IYKyvk0MQZFkaoRsFj2Rmaqgi2rfAZYtA==","shasum":"f649afdca127135edb55ca0ad7c8c60656d92ad1","tarball":"http://registry-npm.ywwl.com/unicode-trie/download/unicode-trie-1.0.0.tgz","fileCount":7,"unpackedSize":47565,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJdBvB8CRA9TVsSAnZWagAAb+EP/0VjAn/NUh0iJQUmakV9\n5Xb/Hj/gxp7C4kT9Vl9M/ippwN8idOLuM3bzWo2uHjSWWGg+IV2spgfTg7VB\nHzYiOnZOL9nhJP0Ey27m8/bu2A/hKkbk8pwhdKTTEP0LhK7AeZCL60CQADuv\n5jaWeDO6rudrreoF5rqUdp3GCP+02WdaLe41gQCeL3eQbF6bQ/CMI1bXPFKP\nUUPMWLs7LKzAa2M01QkkoNXcI3144tSYyiyd/c/AZzIG+c78Oqgd2mI2wLKG\n6nPS4Wq+xK0KoywxTt6AJBJxjTSr5v7e9yDLsaFC9iTaroS3vnaKUWPw5HWM\nCymeVKJ43wvaTg7KACCZGy+KIKr2NOfFeCnGC+FZVJPe+1GPbQxTOqXn9bBc\nBxXpf5d4N1qcYqDOyw+0wiY2u0ZRmI8lInXLyNGcRGBmqozl2FuIW+2nCt9M\nBZqVkij56/nIO06kg402eFtJX97YBmKueOhg8sq09oUN34Dgz8eOqQhGZUGY\nGbsTPe+0ja5mc2pnbmJZwCgHYP2UN9rPdje9I20srOmScEAeSOUXn/QL3qMo\noI44Y5Zx31piF1tW07oezKnuAWtueDqmQGO20O/R2x/aGwaNxY0BbpS+9Wyh\nCwgyvWKji6Iw7bI6L1/0AmmBxN8Qei3OdDdXTTLcxhl0FmPQzkicOLdaIbr1\nxN+d\r\n=CGvb\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDvtYmUJOp1xyMEK+1Yf1tqJW/KLjn+znQLQTzqonYNDwIgP9dmwGHqvrFh/Er0O70QwYNag8wM7g2SeL4rsEbuOzA="}],"size":11857,"noattachment":false,"key":"/unicode-trie/-/unicode-trie-1.0.0.tgz"},"maintainers":[{"name":"devongovett","email":"devongovett@gmail.com"}],"_npmUser":{"name":"devongovett","email":"devongovett@gmail.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/unicode-trie_1.0.0_1560735867452_0.19049912551356862"},"_hasShrinkwrap":false,"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\nconst UnicodeTrieBuilder = require('unicode-trie/builder');\nconst fs = require('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\nconst UnicodeTrie = require('unicode-trie');\nconst fs = require('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## License\n\nMIT\n","publish_time":1560735867616,"_cnpm_publish_time":1560735867616,"dist-tags":{"latest":"3.0.0"}}