{"name":"token-types","version":"6.1.2","description":"Common token types for decoding and encoding numeric and string values","author":{"name":"Borewit","url":"https://github.com/Borewit"},"funding":{"type":"github","url":"https://github.com/sponsors/Borewit"},"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:ts":"biome check","lint:md":"remark -u preset-lint-recommended .","lint":"npm run lint:md && npm run lint:ts","test":"mocha","test-coverage":"c8 npm run test","send-codacy":"c8 report --reports-dir=./.coverage --reporter=text-lcov | codacy-coverage","update-biome":"yarn add -D --exact @biomejs/biome && npx @biomejs/biome migrate --write"},"engines":{"node":">=14.16"},"repository":{"type":"git","url":"git+https://github.com/Borewit/token-types.git"},"license":"MIT","type":"module","exports":"./lib/index.js","types":"lib/index.d.ts","bugs":{"url":"https://github.com/Borewit/token-types/issues"},"devDependencies":{"@biomejs/biome":"2.3.10","@types/chai":"^5.2.2","@types/mocha":"^10.0.10","@types/node":"^25.0.3","c8":"^10.1.3","chai":"^6.2.2","del-cli":"^6.0.0","mocha":"^11.7.5","remark-cli":"^12.0.1","remark-preset-lint-recommended":"^7.0.0","source-map-support":"^0.5.21","ts-node":"^10.9.1","typescript":"^5.9.3"},"dependencies":{"@borewit/text-codec":"^0.2.1","@tokenizer/token":"^0.3.0","ieee754":"^1.2.1"},"remarkConfig":{"plugins":["preset-lint-recommended"]},"keywords":["token","integer","unsigned","numeric","float","IEEE","754","strtok3"],"packageManager":"yarn@4.9.2","_id":"token-types@6.1.2","gitHead":"2278d7e43fc56702d39d10c4e2b89f9cdcef7cf2","homepage":"https://github.com/Borewit/token-types#readme","_nodeVersion":"22.21.1","_npmVersion":"10.9.4","dist":{"integrity":"sha512-dRXchy+C0IgK8WPC6xvCHFRIWYUbqqdEIKPaKo/AcTUNzwLTK6AH7RjdLWsEZcAN/TBdtfUw3PYEgPr5VPr6ww==","shasum":"18d0fd59b996d421f9f83914d6101c201bd08129","tarball":"http://registry-npm.ywwl.com/token-types/download/token-types-6.1.2.tgz","fileCount":5,"unpackedSize":22231,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEUCIQDhvFzSV3V3ws2rgzNunKIgKmv6duHgTjjvizPVULRU2gIgeeUPmbAER7mDwqSs+/gtAH6BzQoX03v5b5i4MOxrVJw="}],"size":5118,"noattachment":false,"key":"/token-types/-/token-types-6.1.2.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/token-types_6.1.2_1767278600361_0.0670334469411844"},"_hasShrinkwrap":false,"readme":"[![Node.js CI](https://github.com/Borewit/token-types/actions/workflows/nodejs-ci.yml/badge.svg?branch=master)](https://github.com/Borewit/token-types/actions/workflows/nodejs-ci.yml?query=branch%3Amaster)\r\n[![NPM version](https://badge.fury.io/js/token-types.svg)](https://npmjs.org/package/token-types)\r\n[![npm downloads](http://img.shields.io/npm/dm/token-types.svg)](https://npmcharts.com/compare/token-types,strtok3?start=1200&interval=30)\r\n[![coveralls](https://coveralls.io/repos/github/Borewit/token-types/badge.svg?branch=master)](https://coveralls.io/github/Borewit/token-types?branch=master)\r\n[![Codacy Badge](https://api.codacy.com/project/badge/Grade/4723ce4613fc49cda8db5eed29f18834)](https://www.codacy.com/app/Borewit/token-types?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=Borewit/token-types&amp;utm_campaign=Badge_Grade)\r\n[![DeepScan grade](https://deepscan.io/api/teams/5165/projects/6940/branches/61852/badge/grade.svg)](https://deepscan.io/dashboard#view=project&tid=5165&pid=6940&bid=61852)\r\n[![Known Vulnerabilities](https://snyk.io/test/github/Borewit/token-types/badge.svg?targetFile=package.json)](https://snyk.io/test/github/Borewit/token-types?targetFile=package.json)\r\n\r\n# token-types\r\n\r\nA primitive token library used to read and write from a `Uint8Array`.\r\nAlthough it is possible to use this module directly, it is primarily designed to be used with [strtok3 tokenizer](https://github.com/Borewit/strtok3).\r\n\r\n## Compatibility\r\n\r\nModule: version 5 migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).\r\nJavaScript is compliant with [ECMAScript 2019 (ES10)](https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019).\r\n\r\n## Installation\r\n\r\n```sh\r\nnpm install --save token-types\r\n```\r\nUsually in combination with [strtok3](https://github.com/Borewit/strtok3):\r\n```sh\r\nnpm install --save strtok3\r\n```\r\n\r\nUsing TypeScript you should also install [@tokenizer/token](https://github.com/Borewit/tokenizer-token) as a development\r\ndependency:\r\n\r\n```shell\r\nnpm install --save-dev @tokenizer/token\r\n```\r\n\r\n\r\n## Example\r\n\r\n```js\r\nimport * as strtok3 from 'strtok3';\r\nimport * as token from 'token-types';\r\n\r\n(async () => {\r\n\r\n  const tokenizer = await strtok3.fromFile(\"somefile.bin\");\r\n  try {\r\n    const myNumber = await tokenizer.readToken(token.Float32_BE);\r\n    console.log(`My number: ${myNumber}`);\r\n  } finally {\r\n    tokenizer.close(); // Close the file\r\n  }\r\n})();\r\n```\r\n\r\n## Tokens\r\n\r\n### Numeric tokens\r\n\r\n`token-types` supports a wide variety of numeric tokens out of the box:\r\n\r\n| Token         | Number           | Bits | Endianness     |\r\n|---------------|------------------|------|----------------|\r\n| `UINT8`       | Unsigned integer |    8 | n/a            |\r\n| `UINT16_BE`   | Unsigned integer |   16 | big endian     |\r\n| `UINT16_LE`   | Unsigned integer |   16 | little endian  |\r\n| `UINT24_BE`   | Unsigned integer |   24 | big endian     |\r\n| `UINT24_LE`   | Unsigned integer |   24 | little endian  |\r\n| `UINT32_BE`   | Unsigned integer |   32 | big endian     |\r\n| `UINT32_LE`   | Unsigned integer |   32 | little endian  |\r\n| `UINT64_BE`   | Unsigned integer |   64 | big endian     |\r\n| `UINT64_LE`*  | Unsigned integer |   64 | little endian  |\r\n| `INT8`        | Signed integer   |    8 | n/a            |\r\n| `INT16_BE`    | Signed integer   |   16 | big endian     |\r\n| `INT16_LE`    | Signed integer   |   16 | little endian  |\r\n| `INT24_BE`    | Signed integer   |   24 | big endian     |\r\n| `INT24_LE`    | Signed integer   |   24 | little endian  |\r\n| `INT32_BE`    | Signed integer   |   32 | big endian     |\r\n| `INT32_LE`    | Signed integer   |   32 | little endian  |\r\n| `INT64_BE`    | Signed integer   |   64 | big endian     |\r\n| `INT64_LE`*   | Signed integer   |   64 | little endian  |\r\n| `Float16_BE`  | IEEE 754 float   |   16 | big endian     |\r\n| `Float16_LE`  | IEEE 754 float   |   16 | little endian  |\r\n| `Float32_BE`  | IEEE 754 float   |   32 | big endian     |\r\n| `Float32_LE`  | IEEE 754 float   |   32 | little endian  |\r\n| `Float64_BE`  | IEEE 754 float   |   64 | big endian     |\r\n| `Float64_LE`  | IEEE 754 float   |   64 | little endian  |\r\n| `Float80_BE`* | IEEE 754 float   |   80 | big endian     |\r\n| `Float80_LE`* | IEEE 754 float   |   80 | little endian  |\r\n\r\n(*) The tokens exceed the JavaScript IEEE 754 64-bit Floating Point precision, decoding and encoding is best effort based.\r\n\r\n### String tokens\r\n\r\nStringType decoding is using [@borewit/text-codec](https://github.com/Borewit/text-codec).\r\n\r\n### Custom tokens\r\n\r\nCustom tokens can be added, suitable for reading binary files or network messages:\r\n```js\r\n  ExtendedHeader = {\r\n    len: 10,\r\n\r\n    get: (buf, off) => {\r\n      return {\r\n        // Extended header size\r\n        size: Token.UINT32_BE.get(buf, off),\r\n        // Extended Flags\r\n        extendedFlags: Token.UINT16_BE.get(buf, off + 4),\r\n        // Size of padding\r\n        sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),\r\n        // CRC data present\r\n        crcDataPresent: common.strtokBITSET.get(buf, off + 4, 31)\r\n      };\r\n    }\r\n  };\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","publish_time":1767278600492,"_cnpm_publish_time":1767278600492,"dist-tags":{"cjs":"4.2.1","esm":"5.0.0-alpha.3","latest":"6.2.0"}}