{"_id":"@borewit/text-codec","_rev":"4109108","name":"@borewit/text-codec","description":"Text Decoder","dist-tags":{"latest":"0.2.1"},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"time":{"modified":"2026-01-23T00:52:23.000Z","created":"2025-08-13T18:34:18.122Z","0.2.1":"2025-12-29T21:37:00.959Z","0.2.0":"2025-08-14T10:48:50.670Z","0.1.1":"2025-08-13T21:45:57.885Z","0.1.0":"2025-08-13T18:34:18.122Z"},"users":{},"author":{"name":"Borewit","url":"https://github.com/Borewit"},"repository":{"type":"git","url":"git+https://github.com/Borewit/text-codec.git"},"versions":{"0.2.1":{"name":"@borewit/text-codec","version":"0.2.1","description":"Text Decoder","type":"module","exports":"./lib/index.js","types":"lib/index.d.ts","scripts":{"clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","build":"npm run compile","prepublishOnly":"npm run build","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","compile":"npm run compile:src && npm run compile:test","lint":"biome check","test":"mocha","update-biome":"npm install --save-dev --save-exact @biomejs/biome@latest && npx @biomejs/biome migrate --write"},"devDependencies":{"@biomejs/biome":"2.3.10","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","chai":"^5.2.1","mocha":"^11.7.5","ts-node":"^10.9.2","typescript":"^5.9.3"},"keywords":["TextDecoder","TextEncoder","decoder","decoding","encod","encoding","decode","text","ascii","utf-8","utf8","utf-16le","latin1","iso-8859-1","windows-1252","charset","encoding","decoding","polyfill","character-set","latin","hermes","react"],"repository":{"type":"git","url":"git+https://github.com/Borewit/text-codec.git"},"author":{"name":"Borewit","url":"https://github.com/Borewit"},"funding":{"type":"github","url":"https://github.com/sponsors/Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.2.1","gitHead":"ec17227bc2890b27eb433a3c74d230d0a4657ac5","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"homepage":"https://github.com/Borewit/text-codec#readme","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"shasum":"5d171538907a8cb395fdc2eb5e8f7947d96c7f2f","size":4910,"noattachment":false,"key":"/@borewit/text-codec/-/@borewit/text-codec-0.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@borewit/text-codec/download/@borewit/text-codec-0.2.1.tgz"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/text-codec_0.2.1_1767044220831_0.5084084615917925"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-12-29T21:37:00.959Z","publish_time":1767044220959,"_source_registry_name":"default","_cnpm_publish_time":1767044220959},"0.2.0":{"name":"@borewit/text-codec","version":"0.2.0","description":"Text Decoder","type":"module","exports":"./lib/index.js","types":"lib/index.d.ts","scripts":{"clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","build":"npm run compile","prepublishOnly":"npm run build","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","compile":"npm run compile:src && npm run compile:test","lint":"biome check","test":"mocha","update-biome":"npm install --save-dev --save-exact @biomejs/biome && npx @biomejs/biome migrate --write"},"devDependencies":{"@biomejs/biome":"2.1.4","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","chai":"^5.2.1","mocha":"^11.7.1","ts-node":"^10.9.2","typescript":"^5.9.2"},"keywords":["TextDecoder","TextEncoder","decoder","decoding","encod","encoding","decode","text","ascii","utf-8","utf8","utf-16le","latin1","iso-8859-1","windows-1252","charset","encoding","decoding","polyfill","character-set","latin","hermes","react"],"repository":{"type":"git","url":"git+https://github.com/Borewit/text-codec.git"},"author":{"name":"Borewit","url":"https://github.com/Borewit"},"funding":{"type":"github","url":"https://github.com/sponsors/Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.2.0","gitHead":"6c171230fc738dd0c744869ec1e2801b52bbf8d9","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"homepage":"https://github.com/Borewit/text-codec#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"shasum":"1dbf3097b136b0dda56bce3ef53886c338ea3202","size":4080,"noattachment":false,"key":"/@borewit/text-codec/-/@borewit/text-codec-0.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@borewit/text-codec/download/@borewit/text-codec-0.2.0.tgz"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/text-codec_0.2.0_1755168530499_0.7250109019521032"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-08-14T10:48:50.670Z","publish_time":1755168530670,"_source_registry_name":"default","_cnpm_publish_time":1755168530670},"0.1.1":{"name":"@borewit/text-codec","version":"0.1.1","description":"Text Decoder","type":"module","exports":"./lib/index.js","types":"lib/index.d.ts","scripts":{"clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","build":"npm run compile","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","compile":"npm run compile:src && npm run compile:test","lint":"biome check","test":"mocha","update-biome":"npm install --save-dev --save-exact @biomejs/biome && npx @biomejs/biome migrate --write"},"devDependencies":{"@biomejs/biome":"2.1.4","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","chai":"^5.2.1","mocha":"^11.7.1","ts-node":"^10.9.2","typescript":"^5.9.2"},"keywords":["TextDecoder","TextEncoder","decoder","decoding","encod","encoding","decode","text","ascii","utf-8","utf8","utf-16le","latin1","iso-8859-1","windows-1252","charset","encoding","decoding","polyfill","character-set","latin","hermes"],"repository":{"type":"git","url":"git+https://github.com/Borewit/text-codec.git"},"author":{"name":"Borewit","url":"https://github.com/Borewit"},"funding":{"type":"github","url":"https://github.com/sponsors/Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.1.1","gitHead":"d3fc20d59baef32c175d7a6db5b4da3aed17d61a","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"homepage":"https://github.com/Borewit/text-codec#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"shasum":"7e7f27092473d5eabcffef693a849f2cc48431da","size":3791,"noattachment":false,"key":"/@borewit/text-codec/-/@borewit/text-codec-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/@borewit/text-codec/download/@borewit/text-codec-0.1.1.tgz"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/text-codec_0.1.1_1755121557663_0.8907179255768902"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-08-13T21:45:57.885Z","publish_time":1755121557885,"_source_registry_name":"default","_cnpm_publish_time":1755121557885},"0.1.0":{"name":"@borewit/text-codec","version":"0.1.0","description":"Text Decoder","type":"module","exports":"./lib/index.js","types":"lib/index.d.ts","scripts":{"clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","build":"npm run compile","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","compile":"npm run compile:src && npm run compile:test","lint":"biome check","test":"mocha","update-biome":"npm install --save-dev --save-exact @biomejs/biome && npx @biomejs/biome migrate --write"},"devDependencies":{"@biomejs/biome":"2.1.4","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","chai":"^5.2.1","mocha":"^11.7.1","ts-node":"^10.9.2","typescript":"^5.9.2"},"keywords":["TextDecoder","decoder","decode","text","ascii","utf-8","utf8","utf-16le","ascii","latin1","iso-8859-1","windows-1252"],"repository":{"type":"git","url":"git+https://github.com/Borewit/text-codec.git"},"author":{"name":"Borewit","url":"https://github.com/Borewit"},"funding":{"type":"github","url":"https://github.com/sponsors/Borewit"},"license":"MIT","packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","_id":"@borewit/text-codec@0.1.0","gitHead":"104503f83c8f92e9207db1449425595ff6a802bc","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"homepage":"https://github.com/Borewit/text-codec#readme","_nodeVersion":"22.14.0","_npmVersion":"10.9.2","dist":{"shasum":"330588f897eebce5170fe341daf0efbe800a362c","size":3950,"noattachment":false,"key":"/@borewit/text-codec/-/@borewit/text-codec-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/@borewit/text-codec/download/@borewit/text-codec-0.1.0.tgz"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/text-codec_0.1.0_1755110057960_0.4759801411111966"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2025-08-13T18:34:18.122Z","publish_time":1755110058122,"_source_registry_name":"default","_cnpm_publish_time":1755110058122}},"readme":"[![CI](https://github.com/Borewit/text-codec/actions/workflows/ci.yml/badge.svg)](https://github.com/Borewit/text-codec/actions/workflows/ci.yml)\r\n[![npm version](https://img.shields.io/npm/v/%40borewit%2Ftext-codec.svg)](https://www.npmjs.com/package/@borewit/text-codec)\r\n[![npm downloads](http://img.shields.io/npm/dm/@borewit/text-codec.svg)](https://npmcharts.com/compare/@borewit/text-codec?interval=30)\r\n![bundlejs](https://deno.bundlejs.com/?q=@borewit/text-codec&badge)\r\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?logo=open-source-initiative&logoColor=white)](LICENSE.txt)\r\n\r\n# `@borewit/text-codec`\r\n\r\nA **lightweight alternative implementation** of `TextEncoder` / `TextDecoder` supporting common encodings missing in some JavaScript engines and Node.js builds.  \r\nWorks in environments like **Hermes** (React Native) or **Small-ICU Node.js** where only UTF-8 and UTF-16LE are available.\r\n\r\n| Encoding                  | Hermes — **Encode** | Hermes — **Decode** | Small-ICU Node.js — **Encode** | Small-ICU Node.js — **Decode** |\r\n|---------------------------|---------------------|---------------------|--------------------------------|--------------------------------|\r\n| **utf-8** / `utf8`        | ➕                   | Native              | Native                         | Native                         |\r\n| **utf-16le**              | ➕                   | ➕                   | Native                         | Native                         |\r\n| **ascii**                 | ➕                   | ➕                   | ➕                              | ➕                              |\r\n| **latin1** / `iso-8859-1` | ➕                   | ➕                   | ➕                              | Native (sometimes)             |\r\n| **windows-1252**          | ➕                   | ➕                   | ➕                              | ➕                              |\r\n\r\n**Legend:**\r\n- **Native** — Supported natively by the JavaScript engine.\r\n- **➕** — Support added by this module.\r\n- **Native (sometimes)** — Available in some builds (e.g., certain Small-ICU Node.js builds).\r\n---\r\n\r\nWhen your project needs to handle encodings like `latin1` / `iso-8859-1` or `windows-1252` in these environments,\r\nnative `TextDecoder` / `TextEncoder` may throw an error or return incorrect results.\r\n\r\n## ✨ Features\r\n\r\n- Decoding and encoding\r\n- Lightweight\r\n- Typed\r\n\r\n### Supported encodings:\r\n- `utf-8` / `utf8`\r\n- `utf-16le`\r\n- `ascii`\r\n- `latin1` / `iso-8859-1`\r\n- `windows-1252`\r\n\r\n---\r\n\r\n## ???? Installation\r\n\r\n```sh\r\nnpm install @borewit/text-codec\r\n```\r\n\r\n\r\n# ???? API Documentation\r\n\r\n## `textDecode(bytes, encoding): string`\r\n\r\nDecodes binary data into a JavaScript string using the specified encoding.\r\n\r\n**Parameters**\r\n- `bytes` (`Uint8Array`) — The binary data to decode.\r\n- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `\"utf-8\"`.  \r\n\r\n**Returns**\r\n- `string` — The decoded text.\r\n\r\n**Example**\r\n```js\r\nimport { textDecode } from \"@borewit/text-encode\";\r\n\r\nconst bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);\r\nconst text = textDecode(bytes, \"ascii\");\r\nconsole.log(text); // \"Hello\"\r\n```\r\nEncodes a JavaScript string into binary form using the specified encoding.\r\n\r\n## `textEncode(input, encoding): Uint8Array`\r\n\r\n**Parameters**\r\n\r\n- `input` (`string`) — The string to encode.\r\n- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `\"utf-8\"`.\r\n\r\n**Returns**\r\n\r\n`Uint8Array` — The encoded binary data.\r\n\r\nExample:\r\n```js\r\nimport { textEncode } from \"@borewit/text-encode\";\r\n\r\nconst bytes = textEncode(\"Hello\", \"utf-16le\");\r\nconsole.log(bytes); // Uint8Array([...])\r\n```\r\n\r\n## ???? Licence\r\n\r\nThis project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.\r\n ","_attachments":{},"homepage":"https://github.com/Borewit/text-codec#readme","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"license":"MIT"}