{"name":"token-types","version":"5.0.0-alpha.0","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 *.d.ts test/**/*.d.ts test/**/*.js test/**/*.js.map .nyc_output","build":"npm run compile","compile-src":"tsc --p lib","compile-test":"tsc --p test","compile":"npm run compile-src && npm run compile-test","lint-ts":"tslint lib/index.ts --exclude '*.d.ts' 'test/**/*.ts' --exclude 'test/**/*.d.ts'","lint-md":"remark -u preset-lint-recommended .","lint":"npm run lint-ts && npm run lint-md","test":"mocha","test-coverage":"c8 npm run test","send-codacy":"c8 report --reports-dir=./.coverage --reporter=text-lcov | codacy-coverage","send-coveralls":"c8 report --reporter=text-lcov | coveralls"},"engines":{"node":"^12.20.0 || ^14.13.1 || >=16.0.0"},"repository":{"type":"git","url":"https://github.com/Borewit/token-types"},"license":"MIT","type":"module","exports":{".":{"node":"./lib/index.js","default":"./lib/core.js"},"./core":"./lib/core.js"},"types":"lib/index.d.ts","bugs":{"url":"https://github.com/Borewit/token-types/issues"},"devDependencies":{"@types/chai":"^4.3.0","@types/mocha":"^9.0.0","@types/node":"^16.11.12","chai":"^4.3.4","coveralls":"^3.1.1","del-cli":"^4.0.1","mocha":"^9.1.3","remark-cli":"^10.0.1","remark-preset-lint-recommended":"^6.1.2","ts-node":"^10.4.0","tslint":"^6.1.3","typescript":"^4.5.4"},"dependencies":{"@tokenizer/token":"^0.3.0","c8":"^7.10.0","ieee754":"^1.2.1"},"remarkConfig":{"plugins":["preset-lint-recommended"]},"keywords":["token","integer","unsigned","numeric","float","IEEE","754","strtok3"],"readmeFilename":"README.md","readme":"![Node.js CI](https://github.com/Borewit/token-types/workflows/Node.js%20CI/badge.svg)\n[![NPM version](https://badge.fury.io/js/token-types.svg)](https://npmjs.org/package/token-types)\n[![npm downloads](http://img.shields.io/npm/dm/token-types.svg)](https://npmcharts.com/compare/token-types,strtok3?start=1200&interval=30)\n[![coveralls](https://coveralls.io/repos/github/Borewit/token-types/badge.svg?branch=master)](https://coveralls.io/github/Borewit/token-types?branch=master)\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)\n[![Language grade: JavaScript](https://img.shields.io/lgtm/grade/javascript/g/Borewit/token-types.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Borewit/token-types/context:javascript)\n[![Total alerts](https://img.shields.io/lgtm/alerts/g/Borewit/token-types.svg?logo=lgtm&logoWidth=18)](https://lgtm.com/projects/g/Borewit/token-types/alerts/)\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)\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)\n\n# token-types\n\nA primitive token library used to read and write from a node `Buffer`.\nAlthough it is possible to use this module directly, it is primary designed to be used with [strtok3 tokenizer](https://github.com/Borewit/strtok3).\n\n## Installation\n\n```sh\nnpm install --save token-types\n```\nUsually in combination with [strtok3](https://github.com/Borewit/strtok3):\n```sh\nnpm install --save strtok3\n```\n\nUsing TypeScript you should also install [@tokenizer/token](https://github.com/Borewit/tokenizer-token) as a development\ndependency:\n\n```shell\nnpm install --save-dev @tokenizer/token\n```\n\n\n## Example\n\n```js\nconst strtok3 = require('strtok3');\nconst token = require('token-types');\n    \n(async () => {\n\n  const tokenizer = await strtok3.fromFile(\"somefile.bin\");\n  try {\n    const myNumber = await tokenizer.readToken(token.Float32_BE);\n    console.log(`My number: ${myNumber}`);\n  } finally {\n    tokenizer.close(); // Close the file\n  } \n})();\n```\n\n## Tokens\n\n### Numeric tokens\n\n`node-strtok` supports a wide variety of numerical tokens out of the box:\n\n| Token         | Number           | Bits | Endianness     |\n|---------------|------------------|------|----------------|\n| `UINT8`       | Unsigned integer |    8 | n/a            |\n| `UINT16_BE`   | Unsigned integer |   16 | big endian     |\n| `UINT16_LE`   | Unsigned integer |   16 | little endian  |\n| `UINT24_BE`   | Unsigned integer |   24 | big endian     |\n| `UINT24_LE`   | Unsigned integer |   24 | little endian  |\n| `UINT32_BE`   | Unsigned integer |   32 | big endian     |\n| `UINT32_LE`   | Unsigned integer |   32 | little endian  |\n| `UINT64_BE`   | Unsigned integer |   64 | big endian     |\n| `UINT64_LE`*  | Unsigned integer |   64 | little endian  |\n| `INT8`        | Signed integer   |    8 | n/a            |\n| `INT16_BE`    | Signed integer   |   16 | big endian     |\n| `INT16_LE`    | Signed integer   |   16 | little endian  |\n| `INT24_BE`    | Signed integer   |   24 | big endian     |\n| `INT24_LE`    | Signed integer   |   24 | little endian  |\n| `INT32_BE`    | Signed integer   |   32 | big endian     |\n| `INT32_LE`    | Signed integer   |   32 | little endian  |\n| `INT64_BE`    | Signed integer   |   64 | big endian     |\n| `INT64_LE`*   | Signed integer   |   64 | little endian  |\n| `Float16_BE`  | IEEE 754 float   |   16 | big endian     |\n| `Float16_LE`  | IEEE 754 float   |   16 | little endian  |\n| `Float32_BE`  | IEEE 754 float   |   32 | big endian     |\n| `Float32_LE`  | IEEE 754 float   |   32 | little endian  |\n| `Float64_BE`  | IEEE 754 float   |   64 | big endian     |\n| `Float64_LE`  | IEEE 754 float   |   64 | little endian  |\n| `Float80_BE`* | IEEE 754 float   |   80 | big endian     |\n| `Float80_LE`* | IEEE 754 float   |   80 | little endian  |\n\n### Other tokens\n\nString types:\n*   Windows-1252\n*   ISO-8859-1\n  \n*) The tokens exceed the JavaScript IEEE 754 64-bit Floating Point precision, decoding and encoding is best effort based.\n\n### Custom token\n\nComplex tokens can be added, which makes very suitable for reading binary files or network messages:\n```js\n ExtendedHeader = {\n    len: 10,\n\n    get: (buf, off) => {\n      return {\n        // Extended header size\n        size: Token.UINT32_BE.get(buf, off),\n        // Extended Flags\n        extendedFlags: Token.UINT16_BE.get(buf, off + 4),\n        // Size of padding\n        sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),\n        // CRC data present\n        crcDataPresent: common.strtokBITSET.get(buf, off + 4, 31)\n      };\n    }\n  };\n```\n","licenseText":"Copyright 2017 Borewit\n\nPermission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.","_id":"token-types@5.0.0-alpha.0","dist":{"shasum":"0a4a6d5ad52ed11d6bc478b01719f00aca3a6142","integrity":"sha512-VUwLd27Bs8+5/LLYTLAZikHeS88LwvPhs+mCG8sG9TPtbdzTDdZywIOUC3PkS92Hq3ZwzOa/Me6Y6efXS0vclg==","tarball":"http://registry-npm.ywwl.com/token-types/download/token-types-5.0.0-alpha.0.tgz","fileCount":7,"unpackedSize":24728,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhuLDUCRA9TVsSAnZWagAAcGcQAKEer59Cjz9Ug1VENs1b\ny8/74OPSR5GyI8rlFPG5apl0TAnkHfLWNOe28Rb0UmO0KR2Qtb/BydSQEU8x\ntqZzdC9OGNyU+2YNGwI/eSFDuwTr69ZzAKnMQ3A6lZgBwhfAjhKFLihtL/u/\nGouPxGql3GnR/s5Xa5a4V+Ew1OkTEzD/D2G8XCqK+q3BmV1+HrQSxtNLOyfT\nM4xQd7lcv3cTxHSfNIY2crcTvShwzxWxubx9R9v+l12+zKMqyZW1pNP9Y1Kn\nwlQXmWvkQ2PRn/R5WMmrF/D3RjdEAR2p/AI4jTgGTUv0ZMvacICeKLky1Oci\nAp6grra5Vt3AtC2MTUhP+lecJfDEonz2xJNjn8OT6yYo0tZc7jUl/afk9/Fo\nNKeit8uZaOy3NCvBBfBzICJ/tnKofKiiLrWQQYj12QdTV0BXHc8l9gcuvATI\n8N4KOZXXLd0STdr6xWK6NAAl128xqiKi8GL0Cq2tOaocJiFuVgUM5SB2vRqK\njNLvzkdDEtCDyirLEV+CS0V3bmRd2fwxrXfu9Rika8M5PdbLIK8o+t/LKloh\n0d1YVyH5N1g5FKiCYkb4D832OuDFF3TcQe84LgVIXwSbtiGUsaS3+sKJGfty\nmGhku8UmG+O0pQoACwsa+QjpQLdxLnKIjo0UhYocIeN5U0opF0RNntQ2/skV\nGrwG\r\n=V3ZR\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCNjn9HcmQE6jo2DQWx7fFMfhe30eHRXYrfoXqReuMpQgIhAOgL3xR+HLUit7TgfOjcgKNGy2oGHgTMm9O6lRJHkAML"}],"size":5666,"noattachment":false,"key":"/token-types/-/token-types-5.0.0-alpha.0.tgz"},"_npmUser":{"name":"borewit","email":"borewit@xs4all.nl"},"directories":{},"maintainers":[{"name":"borewit","email":"borewit@xs4all.nl"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/token-types_5.0.0-alpha.0_1639493844730_0.772519055528093"},"_hasShrinkwrap":false,"publish_time":1639493844890,"_cnpm_publish_time":1639493844890,"dist-tags":{"cjs":"4.2.1","esm":"5.0.0-alpha.3","latest":"6.2.0"}}