{"_id":"@borewit/text-codec","_rev":"6-41a7a431e8f0b2d08bf2a598bf662ca2","name":"@borewit/text-codec","dist-tags":{"latest":"0.2.3"},"versions":{"0.1.0":{"name":"@borewit/text-codec","version":"0.1.0","keywords":["TextDecoder","decoder","decode","text","ascii","utf-8","utf8","utf-16le","ascii","latin1","iso-8859-1","windows-1252"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.1.0","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/text-codec#readme","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"dist":{"shasum":"330588f897eebce5170fe341daf0efbe800a362c","tarball":"https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.1.0.tgz","fileCount":5,"integrity":"sha512-al2HPqmF2XY572gilSWfYRG7ZKFsHOytNoiYqV+bxcT2CgNxj6zNHUOfyjY1hRtjkH6PVYw7vzeqkj75tWQMvA==","signatures":[{"sig":"MEQCIHp5qvYsVvb4Eo7543pCUUN/0ZmyMza+9+IYY3vyaUjbAiByWPmmw3elu2gFx0mlZUxxqIgKuo1Cip+mrdD+or+khA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10872},"type":"module","types":"lib/index.d.ts","exports":"./lib/index.js","funding":{"url":"https://github.com/sponsors/Borewit","type":"github"},"gitHead":"104503f83c8f92e9207db1449425595ff6a802bc","scripts":{"lint":"biome check","test":"mocha","build":"npm run compile","clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","compile":"npm run compile:src && npm run compile:test","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","update-biome":"npm install --save-dev --save-exact @biomejs/biome && npx @biomejs/biome migrate --write"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"_npmVersion":"10.9.2","description":"Text Decoder","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"packageManager":"yarn@1.22.22+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e","devDependencies":{"chai":"^5.2.1","mocha":"^11.7.1","ts-node":"^10.9.2","typescript":"^5.9.2","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@biomejs/biome":"2.1.4"},"_npmOperationalInternal":{"tmp":"tmp/text-codec_0.1.0_1755110057960_0.4759801411111966","host":"s3://npm-registry-packages-npm-production"}},"0.1.1":{"name":"@borewit/text-codec","version":"0.1.1","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"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.1.1","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/text-codec#readme","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"dist":{"shasum":"7e7f27092473d5eabcffef693a849f2cc48431da","tarball":"https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.1.1.tgz","fileCount":5,"integrity":"sha512-5L/uBxmjaCIX5h8Z+uu+kA9BQLkc/Wl06UGR5ajNRxu+/XjonB5i8JpgFMrPj3LXTCPA0pv8yxUvbUi+QthGGA==","signatures":[{"sig":"MEQCIEbeVlyvDVxfXqEoyS1v3nsQ8PGS9hrU2nobIwTEDIFtAiA3w7PCK3w1uQ4wZUNJGHg56sJfM6AZJ/IxK8CVa/qLog==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":10572},"type":"module","types":"lib/index.d.ts","exports":"./lib/index.js","funding":{"url":"https://github.com/sponsors/Borewit","type":"github"},"gitHead":"d3fc20d59baef32c175d7a6db5b4da3aed17d61a","scripts":{"lint":"biome check","test":"mocha","build":"npm run compile","clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","compile":"npm run compile:src && npm run compile:test","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","update-biome":"npm install --save-dev --save-exact @biomejs/biome && npx @biomejs/biome migrate --write"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"_npmVersion":"10.9.2","description":"Text Decoder","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^5.2.1","mocha":"^11.7.1","ts-node":"^10.9.2","typescript":"^5.9.2","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@biomejs/biome":"2.1.4"},"_npmOperationalInternal":{"tmp":"tmp/text-codec_0.1.1_1755121557663_0.8907179255768902","host":"s3://npm-registry-packages-npm-production"}},"0.2.0":{"name":"@borewit/text-codec","version":"0.2.0","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"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.2.0","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/text-codec#readme","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"dist":{"shasum":"1dbf3097b136b0dda56bce3ef53886c338ea3202","tarball":"https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.0.tgz","fileCount":5,"integrity":"sha512-X999CKBxGwX8wW+4gFibsbiNdwqmdQEXmUejIWaIqdrHBgS5ARIOOeyiQbHjP9G58xVEPcuvP6VwwH3A0OFTOA==","signatures":[{"sig":"MEYCIQDdR8C6ZCFsC0tW5eg4qeruZ82cxiNkDT0c9A4v499x3AIhAN3BtR7kt1UGWLhW2Z/jdbc1DktVd7peHfgR+7MsUpCj","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":11900},"type":"module","types":"lib/index.d.ts","exports":"./lib/index.js","funding":{"url":"https://github.com/sponsors/Borewit","type":"github"},"gitHead":"6c171230fc738dd0c744869ec1e2801b52bbf8d9","scripts":{"lint":"biome check","test":"mocha","build":"npm run compile","clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","compile":"npm run compile:src && npm run compile:test","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","update-biome":"npm install --save-dev --save-exact @biomejs/biome && npx @biomejs/biome migrate --write","prepublishOnly":"npm run build"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"_npmVersion":"10.9.2","description":"Text Decoder","directories":{},"_nodeVersion":"22.14.0","_hasShrinkwrap":false,"devDependencies":{"chai":"^5.2.1","mocha":"^11.7.1","ts-node":"^10.9.2","typescript":"^5.9.2","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@biomejs/biome":"2.1.4"},"_npmOperationalInternal":{"tmp":"tmp/text-codec_0.2.0_1755168530499_0.7250109019521032","host":"s3://npm-registry-packages-npm-production"}},"0.2.1":{"name":"@borewit/text-codec","version":"0.2.1","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"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.2.1","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/text-codec#readme","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"dist":{"shasum":"5d171538907a8cb395fdc2eb5e8f7947d96c7f2f","tarball":"https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.1.tgz","fileCount":5,"integrity":"sha512-k7vvKPbf7J2fZ5klGRD9AeKfUvojuZIQ3BT5u7Jfv+puwXkUBUT5PVyMDfJZpy30CBDXGMgw7fguK/lpOMBvgw==","signatures":[{"sig":"MEUCIQCndQ9lHDbDXeZddukQ10i08/c5ujDpy7q346Yiaw8vVAIgVUyuE/ecESLJEJ46VHdURxGcv2CmJ8ZedblEzRxcbwE=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":15004},"type":"module","types":"lib/index.d.ts","exports":"./lib/index.js","funding":{"url":"https://github.com/sponsors/Borewit","type":"github"},"gitHead":"ec17227bc2890b27eb433a3c74d230d0a4657ac5","scripts":{"lint":"biome check","test":"mocha","build":"npm run compile","clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","compile":"npm run compile:src && npm run compile:test","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","update-biome":"npm install --save-dev --save-exact @biomejs/biome@latest && npx @biomejs/biome migrate --write","prepublishOnly":"npm run build"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"_npmVersion":"10.9.4","description":"Text Decoder","directories":{},"_nodeVersion":"22.21.1","_hasShrinkwrap":false,"devDependencies":{"chai":"^5.2.1","mocha":"^11.7.5","ts-node":"^10.9.2","typescript":"^5.9.3","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@biomejs/biome":"2.3.10"},"_npmOperationalInternal":{"tmp":"tmp/text-codec_0.2.1_1767044220831_0.5084084615917925","host":"s3://npm-registry-packages-npm-production"}},"0.2.2":{"name":"@borewit/text-codec","version":"0.2.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"],"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","_id":"@borewit/text-codec@0.2.2","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"homepage":"https://github.com/Borewit/text-codec#readme","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"dist":{"shasum":"75025f735c0983b3a871668804a57387e3649375","tarball":"https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.2.tgz","fileCount":5,"integrity":"sha512-DDaRehssg1aNrH4+2hnj1B7vnUGEjU6OIlyRdkMd0aUdIUvKXrJfXsy8LVtXAy7DRvYVluWbMspsRhz2lcW0mQ==","signatures":[{"sig":"MEQCIBFow/HEhh2YpLoe2emkwfvrJfPhYiIADcYgV90osSQEAiAeLzK+HxceSbi02WwG7DT6JXkmoJ7LCzWYxKU4q+hp9w==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":17838},"type":"module","types":"lib/index.d.ts","exports":"./lib/index.js","funding":{"url":"https://github.com/sponsors/Borewit","type":"github"},"gitHead":"c2ce9c502abb9276e832220ee6e4fa9c4105301a","scripts":{"lint":"biome check","test":"mocha","build":"npm run compile","clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","compile":"npm run compile:src && npm run compile:test","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","update-biome":"npm install --save-dev --save-exact @biomejs/biome@latest && npx @biomejs/biome migrate --write","prepublishOnly":"npm run build"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"repository":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"_npmVersion":"10.9.4","description":"Text Decoder","directories":{},"_nodeVersion":"22.21.1","_hasShrinkwrap":false,"devDependencies":{"chai":"^6.2.2","mocha":"^11.7.5","ts-node":"^10.9.2","typescript":"^5.9.3","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@biomejs/biome":"2.4.6"},"_npmOperationalInternal":{"tmp":"tmp/text-codec_0.2.2_1773260113446_0.695235941988475","host":"s3://npm-registry-packages-npm-production"}},"0.2.3":{"_id":"@borewit/text-codec@0.2.3","bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"dist":{"shasum":"f5675fe4eae610670bbb635c6b75c6a4dd41ed73","tarball":"https://registry.npmjs.org/@borewit/text-codec/-/text-codec-0.2.3.tgz","fileCount":5,"integrity":"sha512-49CycTz1aAZmvFcwkeFyhud1HUmRIB5Tabf7ALV+VA4Iu85MTfz2cUwzPagMFAdVBvrWdkCxG67I30tUwwpKsw==","signatures":[{"sig":"MEQCIHGJOW1NlL2/TdwH5DXE2ccBEzLS81n5hBGFkHA5pgsXAiAspP8GQxIuFPLN9dRyqOGep2WsxkdhcCAh+o2DtjRcHA==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"},{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCIBfRBbqd+8rb5cpgoU4zwsXeLm9Gz/Ax07QiDta7aQFbAiAMZqXiNPv3iooCY8PBvR3gVpF/bP7j0f2gSdveF5QMNg=="}],"unpackedSize":16527},"name":"@borewit/text-codec","type":"module","types":"lib/index.d.ts","author":{"url":"https://github.com/Borewit","name":"Borewit"},"exports":"./lib/index.js","funding":{"url":"https://github.com/sponsors/Borewit","type":"github"},"gitHead":"caaa5d47ab7976b3742ecfd1dc8cb746404ef321","license":"MIT","scripts":{"lint":"biome check --error-on-warnings","test":"mocha","build":"npm run compile","clean":"del-cli lib/**/*.js lib/***.js.map test/**/*.d.ts test/**/*.js test/**/*.js.map","compile":"npm run compile:src && npm run compile:test","pretest":"npm run build","lint:fix":"biome check --write","compile:src":"tsc --p lib --sourceMap false","compile:test":"tsc --p test","update-biome":"npm install --save-dev --save-exact @biomejs/biome@latest && npx @biomejs/biome migrate --write","prepublishOnly":"npm run build"},"version":"0.2.3","_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"homepage":"https://github.com/Borewit/text-codec#readme","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":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"_npmVersion":"10.9.9","description":"Text Decoder","directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_nodeVersion":"22.23.3","_hasShrinkwrap":false,"devDependencies":{"chai":"^6.3.0","mocha":"^11.8.0","typescript":"7.0.2","@types/chai":"^5.2.3","@types/mocha":"^10.0.10","@biomejs/biome":"2.6.3"},"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/text-codec_0.2.3_1793218223607_0.6548117012760553"}}},"time":{"created":"2025-08-13T18:34:17.900Z","modified":"2026-10-28T20:10:23.962Z","0.1.0":"2025-08-13T18:34:18.122Z","0.1.1":"2025-08-13T21:45:57.885Z","0.2.0":"2025-08-14T10:48:50.670Z","0.2.1":"2025-12-29T21:37:00.959Z","0.2.2":"2026-03-11T20:15:13.627Z","0.2.3":"2026-10-28T20:10:23.703Z"},"bugs":{"url":"https://github.com/Borewit/text-codec/issues"},"author":{"url":"https://github.com/Borewit","name":"Borewit"},"license":"MIT","homepage":"https://github.com/Borewit/text-codec#readme","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":{"url":"git+https://github.com/Borewit/text-codec.git","type":"git"},"description":"Text Decoder","maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"readme":"[![CI](https://github.com/Borewit/text-codec/actions/workflows/ci.yml/badge.svg)](https://github.com/Borewit/text-codec/actions/workflows/ci.yml)\n[![npm version](https://img.shields.io/npm/v/%40borewit%2Ftext-codec.svg)](https://www.npmjs.com/package/@borewit/text-codec)\n[![npm downloads](http://img.shields.io/npm/dm/@borewit/text-codec.svg)](https://npmcharts.com/compare/@borewit/text-codec?interval=30)\n![bundlejs](https://deno.bundlejs.com/?q=@borewit/text-codec&badge)\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg?logo=open-source-initiative&logoColor=white)](LICENSE.txt)\n\n# `@borewit/text-codec`\n\nA **lightweight polyfill for text encoders and decoders** covering a small set of commonly used encodings.\n\nSome JavaScript runtimes provide limited or inconsistent encoding support through `TextEncoder` and `TextDecoder`.  \nExamples include environments like **Hermes (React Native)** or certain **Node.js builds with limited ICU support**.\n\nThis module provides **reliable encode/decode support for a small set of encodings that may be missing or unreliable in those environments**.\n\n- If a native UTF-8 `TextEncoder` / `TextDecoder` is available, it is used.\n- All other encodings are implemented by this library.\n\n## Supported encodings\n\n- `utf-8` / `utf8`\n- `utf-16le`\n- `ascii`\n- `latin1` / `iso-8859-1`\n- `windows-1252`\n\nThese encodings are commonly encountered in metadata formats and legacy text data.\n\n## ✨ Features\n\n- Encoding and decoding utilities\n- Lightweight\n- Typed API\n\n## 📦 Installation\n\n```sh\nnpm install @borewit/text-codec\n```\n\n# 📚 API Documentation\n\n## `textDecode(bytes, encoding): string`\n\nDecodes binary data into a JavaScript string.\n\n**Parameters**\n- `bytes` (`Uint8Array`) — The binary data to decode.\n- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `\"utf-8\"`.  \n\n**Returns**\n- `string` — The decoded text.\n\n**Example**\n```js\nimport { textDecode } from \"@borewit/text-codec\";\n\nconst bytes = new Uint8Array([0x48, 0x65, 0x6c, 0x6c, 0x6f]);\nconst text = textDecode(bytes, \"ascii\");\nconsole.log(text); // \"Hello\"\n```\n\n## `textEncode(input, encoding): Uint8Array`\n\nEncodes a JavaScript string into binary form using the specified encoding.\n\n**Parameters**\n\n- `input` (`string`) — The string to encode.\n- `encoding` (`SupportedEncoding`, optional) — Encoding type. Defaults to `\"utf-8\"`.\n\n**Returns**\n\n`Uint8Array` — The encoded binary data.\n\nExample:\n```js\nimport { textEncode } from \"@borewit/text-codec\";\n\nconst bytes = textEncode(\"Hello\", \"utf-16le\");\nconsole.log(bytes); // Uint8Array([...])\n```\n\n## 📜 Licence\n\nThis project is licensed under the [MIT License](LICENSE.txt). Feel free to use, modify, and distribute as needed.\n ","readmeFilename":"README.md"}