{"id":"kampfkarren/unicode-ident","name":"unicode-ident","scope":"kampfkarren","platform":"roblox","description":"Mirrored from the Wally registry.","version":"1.0.0","latest":"1.0.0","versions":["1.0.0"],"license":"Apache-2.0","licenseRating":"safe","licenseCaveats":["Modified files must carry a notice of changes. If the package ships a NOTICE file, its attributions must be preserved.","License identified from the packaged LICENSE file; the manifest declared none."],"licenseVerified":true,"dependencies":{},"integrity":"9d2ff291a3a20c18c64bfa3b5251d6e888a5a8ab3008d406c432adb334dfd15d","likes":0,"downloads":0,"install":"forest install kampfkarren/unicode-ident","url":"https://forest.dev/p/roblox/kampfkarren/unicode-ident","files":"https://api.forest.dev/ai/package/roblox/kampfkarren/unicode-ident/files","readme":"# unicode-ident-luau\n\nImplementation of [Unicode Standard Annex #31](https://www.unicode.org/reports/tr31/) for detecting \"general-purpose identifiers, immutable identifiers, hashtag identifiers, and in pattern-based syntax\". Tested on Unicode 15.0.0.\n\nPort of [https://github.com/dtolnay/unicode-ident].\n\n## Usage\n\nunicode-ident-luau exposes the following functions that take codepoints (such as those from [utf8.codes](https://luau-lang.org/library#utf8-library)).\n\n```\nunicodeIdent.isXidStart(codepoint: number): boolean\nunicodeIdent.isXidContinue(codepoint: number): boolean\n```\n\n### Installation\n\nunicode-ident-luau is on wally.\n\n```toml\nunicodeIdent = \"kampfkarren/unicode-ident@1.0.0\"\n```\n\n## Performance\n\n### TL;DR\n\n- 18.8 nanoseconds per call for ASCII\n- 37.6 nanoseconds per call for non-ASCII\n- 12.7 KB of memory.\n- My CPU is extremely good. YMMV.\n\n### Details\n\nunicode-ident-luau is extremely fast.\n\nThe following benchmarks consistently give the following benchmarks:\n\n```lua\n{\n\t[\"ASCII (totalling nearly FFFF times)\"] = function(Profiler)\n\t\tfor _ = 1, 0xFFFF / 128 do\n\t\t\tfor c = 0, 127 do\n\t\t\t\tlocal _ = unicodeIdent.isXidStart(c)\n\t\t\t\tlocal _ = unicodeIdent.isXidContinue(c)\n\t\t\tend\n\t\tend\n\tend,\n\n\t[\"0 to 0xFFFF\"] = function()\n\t\tfor c = 1, 0xffff do\n\t\t\tlocal _ = unicodeIdent.isXidStart(c)\n\t\t\tlocal _ = unicodeIdent.isXidContinue(c)\n\t\tend\n\tend,\n}\n```\n\n#![Benchmarking data. 0 to 0xFFFF is 7.950ms P50, and ASCII (totalling nearly FFFF times) is 2.459ms P50](docs/bench1.png)\n\nDividing these by the number of iterations, we get the following metrics for both isXidStart and isXidContinue. Because they are implemented nearly identically, we will divide by 50% for the price of either.\n\n**ASCII**: 2.459ms / 65,408 runs == 37.6 nanoseconds for both / **18.8 nanoseconds** for either.\n\n**Non-ASCII**: 7.950ms / 65,535 runs == 121.3 nanoseconds for both / **60.65 nanoseconds** for either.\n\nNote that these benchmarks (and similar ones performed outside of Benchmarker) don't seem to improve with `--!native`.\n\nThe necessary tables are stored in an extremely compressed manner. The Luau heap manager reports the tables as being 10.4 KB, but in a game the cost of the script bytecode is an additional 2,359 bytes, so about 12.7 KB.\n","readmeTruncated":false}