{"_id":"utf8-codec","name":"utf8-codec","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"utf8-codec","version":"1.0.0","description":"utf8 to/from bytes codec (esm/cjs)","main":"index.js","module":"index.mjs","types":"./types/index.d.ts","exports":{"require":"./index.js","import":"./index.mjs","types":"./types/index.d.ts"},"scripts":{"test":"npm run lint && npm run unit","lint":"standard &&  dtslint types --localTs node_modules/typescript/lib","unit":"node test.mjs","coverage":"c8 -r html -r text npm run unit","prepare":"esm2umd utf8Codec"},"keywords":["utf8","codec","bytes","encoding","buffer","uint8array"],"author":{"name":"Martin Heidegger","email":"martin.heidegger@gmail.com"},"license":"MIT","devDependencies":{"@definitelytyped/dtslint":"^0.0.112","@leichtgewicht/esm2umd":"^0.3.4","c8":"^7.11.3","fresh-tape":"^5.5.3","standard":"^17.0.0","typescript":"^4.7.2"},"repository":{"type":"git","url":"git+https://github.com/martinheidegger/utf8-codec.git"},"bugs":{"url":"https://github.com/martinheidegger/utf8-codec/issues"},"homepage":"https://github.com/martinheidegger/utf8-codec#readme","gitHead":"07cd4aa2771cebf55118fdc5feb46f4c64e6c013","_id":"utf8-codec@1.0.0","_nodeVersion":"18.2.0","_npmVersion":"8.9.0","dist":{"integrity":"sha512-S/QSLezp3qvG4ld5PUfXiH7mCFxLKjSVZRFkB3DOjgwHuJPFDkInAXc/anf7BAbHt/D38ozDzL+QMZ6/7gsI6w==","shasum":"b30252507271cd612dbf5b58f04620a5e1e7bb89","tarball":"https://registry.npmjs.org/utf8-codec/-/utf8-codec-1.0.0.tgz","fileCount":7,"unpackedSize":15113,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCHIKzQOvrIaTNP8zwtMatSo836z+aXUuuqm/4ppy+Y5gIhALR4fHREgsrKjVkH3+/ZIfchMR6Hn9gXdXCYMEZBRl1y"}],"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJilGMCACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2Vmr0Mg//a/m+N8Y4fWLhvlupWDjShOTNMSxGwazszqv8YV7KB8aomJlA\r\n2FwwF+UYtOMKRP/W23Y+cV8+qe/qLESbdsAJ5YGDAUz6z/RmR6PaMENlTgXG\r\nqU7tN5nXt3c/6/NJ4TpX764Wp9mDhFVINulhPmoNyUxGfwYKpC+/Htvhsh92\r\nKclqdRyfzSOoybyAHfrREFYQCGTaYG+0ZVFMG6k/7+CHN893rCa6TlDcP+sV\r\ndB64uWr5zwn5DRCjKmuc5kzMEY4KGSZh2Y9Mi/I33jMfNY3FP4vgSj71D/Lb\r\nlgtaaMIMnaDZDQ+4/0ut3QHtViIWo7AKp62Cw+eDYopgBe9zqgYYR50q3LZ+\r\nVhKcv5Ge0KRsVWQXHwHHVLV267a0POXlR0YrmEFmI8ynZ7XS2Qp7aAiniLaH\r\nWLOPMDZiYeMpJ9HqTLLUvjyNWvvGlHid2xk5IwJCRnspCw1/3IB00hIaNpID\r\no0uWL59FhJGO2i/+AMIqVaCR9CytLvSt+5TKa90Eoc0STV1fTFUGbiIrTm2U\r\nMSslxAeyKU2sZrenshFbj76/W2LR9KHIJKH3QRMgu+TsRTA7E2g6fOtvez9R\r\nJ23Q1FVaezS6q8tenWBuw+cML0IahhTZ5H15xFybTnHspyxTmeJDG9j5wtLx\r\nlNI1eTdnUpXTBHd8pcDDR8Lof7KskN3FKBA=\r\n=2cFl\r\n-----END PGP SIGNATURE-----\r\n"},"_npmUser":{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"},"directories":{},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utf8-codec_1.0.0_1653891842526_0.9910669669389884"},"_hasShrinkwrap":false}},"time":{"created":"2022-05-30T06:24:02.480Z","1.0.0":"2022-05-30T06:24:02.669Z","modified":"2022-05-30T06:24:02.774Z"},"maintainers":[{"name":"leichtgewicht","email":"martin.heidegger@gmail.com"}],"description":"utf8 to/from bytes codec (esm/cjs)","homepage":"https://github.com/martinheidegger/utf8-codec#readme","keywords":["utf8","codec","bytes","encoding","buffer","uint8array"],"repository":{"type":"git","url":"git+https://github.com/martinheidegger/utf8-codec.git"},"author":{"name":"Martin Heidegger","email":"martin.heidegger@gmail.com"},"bugs":{"url":"https://github.com/martinheidegger/utf8-codec/issues"},"license":"MIT","readme":"# utf8-codec\n\nA javascript-only (esm/cjs) utf8 codec that is [abstract-encoding][] compatible,\nwell-tested and pretty efficient. Bonus: It doesn't use Nodejs' Buffer object\nand comes with typescript types.\n\n[abstract-encoding]: https://github.com/mafintosh/abstract-encoding\n\n## Usage\n\n```js\nimport { encode, encodingLength, decode } from 'utf8-codec' // require works too!\n\nconst str = 'Hello World / こんにちは世界'\nconst bytes = encode(\n  str,\n  new Uint8Array(endcodingLength(str)), // own buffer supplied, optional\n  0 // offset, at which to write the str, optional\n)\nstr === decode(bytes, 0, bytes.length)\n```\n\n## Why?\n\nThe [TextEncoder][] and [TextDecoder][] classes _exist_ to encode utf8 strings but\nthey are not optimized for bigger byte processing and don't offer APIs to figure\nout how preemptively how many bytes are supposed to be written/read. Surprisingly\nthis algorithm is even faster.\n\nThe other implementations found at the time do either not implement the edge cases\nproperly and/or both directions of the codec.\n\n[TextEncoder]: https://developer.mozilla.org/en-US/docs/Web/API/TextEncoder\n[TextDecoder]: https://developer.mozilla.org/en-US/docs/Web/API/TextDecoder\n\n## License\n\n[MIT](./LICENSE)\n","readmeFilename":"README.md"}