{"metapak":{"data":{"files":"src/*.ts","testFiles":"tests/*.test.ts","bundleFiles":["dist","src"],"ignore":["dist"]},"configs":["main","readme","jest","eslint","tsesm","codeclimate","ghactions"]},"name":"utf-8","description":"Encode/decode UTF8.","version":"3.0.0","author":{"name":"Nicolas Froidure","email":"nicolas.froidure@insertafter.com","url":"https://insertafter.com/en/index.html"},"license":"MIT","repository":{"type":"git","url":"git+ssh://git@github.com/nfroidure/utf-8.git"},"engines":{"node":">=20.11.1"},"devDependencies":{"@eslint/js":"^9.7.0","@swc/cli":"^0.4.0","@swc/core":"^1.6.13","@swc/helpers":"^0.5.12","@swc/jest":"^0.2.36","commitizen":"^4.3.0","conventional-changelog-cli":"^5.0.0","cz-conventional-changelog":"^3.3.0","eslint":"^9.7.0","eslint-config-prettier":"^9.1.0","eslint-plugin-jest":"^28.6.0","eslint-plugin-prettier":"^5.1.3","jest":"^29.7.0","metapak":"^6.0.1","metapak-nfroidure":"18.2.0","prettier":"^3.3.3","rimraf":"^6.0.1","typescript":"^5.5.3","typescript-eslint":"^7.16.0"},"scripts":{"build":"rimraf 'dist' && tsc --outDir dist","changelog":"conventional-changelog -p angular -i CHANGELOG.md -s && git add CHANGELOG.md","cli":"env NODE_ENV=${NODE_ENV:-cli}","cover":"npm run jest -- --coverage","cz":"env NODE_ENV=${NODE_ENV:-cli} git cz","format":"npm run prettier","jest":"NODE_OPTIONS=--experimental-vm-modules NODE_ENV=test jest","lint":"eslint src/*.ts","metapak":"metapak","precz":"npm run build && npm t && npm run lint && npm run metapak -- -s","prettier":"prettier --write src/*.ts","preversion":"npm run build && npm t && npm run lint && npm run metapak -s && npm run metapak -- -s","rebuild":"swc ./src -s -d dist -C jsc.target=es2022","test":"npm run jest","type-check":"tsc --pretty --noEmit","version":"npm run changelog && git add CHANGELOG.md"},"keywords":["utf-8","encode","decode","encoder","decoder","strict"],"main":"dist/index.js","config":{"commitizen":{"path":"./node_modules/cz-conventional-changelog"}},"greenkeeper":{"ignore":["commitizen","cz-conventional-changelog","conventional-changelog-cli","jest","@swc/jest","eslint","prettier","eslint-config-prettier","eslint-plugin-prettier","typescript-eslint","typescript","rimraf","@swc/cli","@swc/core","@swc/helpers"]},"jest":{"coverageReporters":["lcov"],"testPathIgnorePatterns":["/node_modules/"],"roots":["<rootDir>/src"],"transform":{"^.+\\.tsx?$":["@swc/jest",{}]},"testEnvironment":"node","moduleNameMapper":{"(.+)\\.js":"$1"},"extensionsToTreatAsEsm":[".ts"],"prettierPath":null},"type":"module","types":"dist/index.d.ts","overrides":{"eslint":"^9.7.0"},"prettier":{"semi":true,"printWidth":80,"singleQuote":true,"trailingComma":"all","proseWrap":"always"},"dependencies":{"yerror":"^8.0.0"},"contributors":[],"_id":"utf-8@3.0.0","gitHead":"f63d99b70b7b4aab51f7283bd9a21f30be0791c6","bugs":{"url":"https://github.com/nfroidure/utf-8/issues"},"homepage":"https://github.com/nfroidure/utf-8#readme","_nodeVersion":"20.14.0","_npmVersion":"10.7.0","dist":{"integrity":"sha512-0wd+rDF0tLpj5ZVepWv7C+mfnxqhTCLPMUD6uLMGEpZQeCev98d6AXjBKkO5YcfAIrNY/7bzny5dlj3YBnWesQ==","shasum":"d38d8eaeedd3d0a92a2e2bd6b6fce7b87deb9a2b","tarball":"http://registry-npm.ywwl.com/utf-8/download/utf-8-3.0.0.tgz","fileCount":12,"unpackedSize":66627,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEmoy95Q4MTbEAW2ZTNKANQmqtp2N2SAsnqer1+bh2GoAiEAw3daZsDdwrM1+NnWomcCt5Wf7Ex8W4utV8WF5fgibI8="}],"size":13312,"noattachment":false,"key":"/utf-8/-/utf-8-3.0.0.tgz"},"_npmUser":{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},"directories":{},"maintainers":[{"name":"nfroidure","email":"nicolas.froidure@insertafter.com"},{"name":"cipherboy","email":"alexander.m.scheel@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/utf-8_3.0.0_1723363877534_0.5270252924559009"},"_hasShrinkwrap":false,"readme":"[//]: # ( )\n[//]: # (This file is automatically generated by a `metapak`)\n[//]: # (module. Do not change it  except between the)\n[//]: # (`content:start/end` flags, your changes would)\n[//]: # (be overridden.)\n[//]: # ( )\n# utf-8\n> Encode/decode UTF8.\n\n[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/nfroidure/utf-8/blob/main/LICENSE)\n\n\n[//]: # (::contents:start)\n\nAs you probably noticed, there is already standards ways to\n encode/decode utf-8 strings into buffers in the NodeJS\n standard library.\n\nThis library can be useful if you need to write at given buffer\n indexes or to validate utf-8 encoded buffers.\n\nOtherwise, use NodeJS standard library.\n\n## Usage\n\n```sh\nnpm install utf-8\n```\n\n### Encoding\n\nA char:\n\n```js\nimport * as UTF8 from 'utf-8';\n\nUTF8.setBytesFromCharCode('é'.charCodeAt(0));\n// [0xC3, 0xA9]\n```\n\nA string:\n\n```js\nUTF8.setBytesFromString('1.3$ ~= 1€');\n// [49, 46, 51, 36, 32, 126, 61, 32, 49, 226, 130, 172]\n```\n\n### Decoding\n\nA char:\n\n```js\nString.fromCharCode(UTF8.getCharCode([0xc3, 0xa9]));\n// 'é'\n```\n\nA string:\n\n```js\nUTF8.getStringFromBytes([49, 46, 51, 36, 32, 126, 61, 32, 49, 226, 130, 172]);\n// '1.3$ ~= 1€'\n```\n\n### TypedArrays are welcome\n\nAs inputs:\n\n```js\nconst bytes = new Uint8Array([\n  0xc3, 0xa9, 49, 46, 51, 36, 32, 126, 61, 32, 49, 226, 130, 172,\n]);\n\n// The first char\nString.fromCharCode(UTF8.getCharCode(bytes));\n// é\n\n// The following string at the offset 2\nUTF8.getStringFromBytes(bytes, 2);\n// '1.3$ ~= 1€'\n```\n\nAs well as outputs :\n\n```js\nconst bytes = new Uint8Array(14);\n\n// First encoding a char\nUTF8.setBytesFromCharCode('é'.charCodeAt(0));\n\n// Then encoding a string\nUTF8.setBytesFromString('1.3$ ~= 1€', 2);\n```\n\n## UTF8 encoding detection\n\n```js\nUTF8.isNotUTF8(bytes);\n// true | false\n```\n\nThis function can prove the text contained by the given bytes is not UTF-8 (or\nbadly encoded UTF-8 string). It's not reciprocally true, especially for short\nstrings with which false positives are frequent.\n\n## Strict mode\n\nIf you try to encode an UTF8 string in an ArrayBuffer too short to contain the\ncomplete string, it will silently fail. To avoid this behavior, use the strict\nmode :\n\n```js\nUTF8.setBytesFromString('1.3$ ~= 1€', 2, null, true);\n```\n\n# Thanks\n\n- The Debian project for it's free (as freedom) russian/japanese man pages used\n  for real world files tests!\n\n[//]: # (::contents:end)\n\n# Authors\n- [Nicolas Froidure](https://insertafter.com/en/index.html)\n\n# License\n[MIT](https://github.com/nfroidure/utf-8/blob/main/LICENSE)\n","publish_time":1723363877719,"_cnpm_publish_time":1723363877719,"dist-tags":{"latest":"3.0.0"}}