{"name":"token-types","version":"5.0.0-alpha.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 *.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":"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":{"@types/chai":"^4.3.0","@types/mocha":"^9.0.0","@types/node":"^16.11.12","c8":"^7.10.0","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","ieee754":"^1.2.1"},"remarkConfig":{"plugins":["preset-lint-recommended"]},"keywords":["token","integer","unsigned","numeric","float","IEEE","754","strtok3"],"readme":"![Node.js CI](https://github.com/Borewit/token-types/workflows/Node.js%20CI/badge.svg)\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[![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)\r\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/)\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 node `Buffer`.\r\nAlthough it is possible to use this module directly, it is primary designed to be used with [strtok3 tokenizer](https://github.com/Borewit/strtok3).\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\nconst strtok3 = require('strtok3');\r\nconst token = require('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`node-strtok` supports a wide variety of numerical 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### Other tokens\r\n\r\nString types:\r\n*   Windows-1252\r\n*   ISO-8859-1\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### Custom token\r\n\r\nComplex tokens can be added, which makes very 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","readmeFilename":"README.md","gitHead":"8871fbc7861adb238eed4b6b89f40732622fbbf5","homepage":"https://github.com/Borewit/token-types#readme","_id":"token-types@5.0.0-alpha.2","_nodeVersion":"12.22.7","_npmVersion":"6.14.5","dist":{"integrity":"sha512-EsG9UxAW4M6VATrEEjhPFTKEUi1OiJqTUMIZOGBN49fGxYjZB36k0p7to3HZSmWRoHm1QfZgrg3e02fpqAt5fQ==","shasum":"e43d63b2a8223a593d1c782a5149bec18f1abf97","tarball":"http://registry-npm.ywwl.com/token-types/download/token-types-5.0.0-alpha.2.tgz","fileCount":5,"unpackedSize":24620,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhvK8cCRA9TVsSAnZWagAA1/cP/2NthR9/geT0RcBPsQni\n8jqziAHOxavLSnBz2C80naRMz8xWwTB6atV5aGXDiGcJTFZ8xAbc5x8nD4s4\ngpZniS+FDeaLS3RFSqNA8h6E535hczbkSnYWSlBJxmrKnGk7trAy/WzztglZ\n+PIunUiw48IaRHOL4uzeia5XT9VM5weYTRfTsK/3LxB1XpY67o18MLR5C/yH\nNjt0V93jgQeV+pXx9goHWMzV4jPxJqX0aCV/+vuG8ESQsipIKGTrv1NX/U9g\n3RMQ36uozsXRdHQTgs843S3h0Z+5zmDblC9B1u0TACAAYKuDX3hB23/xMYJj\nw2vx4hcDkv6mQAVxha5FxYPaIPu+F6HCz5pGqOgFc+amz68hAZkr4ihJnQ+P\ncJTj/TXlOIkVup4W+Qa8C0Px+38YHQG8vbwCtfHHXsBmlVKINescES/6JV1y\nQeC2DBtSiJL0bf6ObYuJpMII5PNww8CoGZLttD1Lf4Ghqjk1lGCAQDLeSrpb\nzVaf6yZYSpsTpQfGCpfULpkH0qqRjoMIhip3zMBRamf+aSqNiUM18wRBQhfC\nTcgPEySSPN0gbFc7MllqIXLw/D4505jfGIsYESkLL3AaboN6FhmTlW4q3ZCw\n3zdKaGUeGR/Xwl5518D+ftgJaqSL40tRxB3ah4Pbidikb4zrNoiz5u9ZKV/2\nFxpS\r\n=jMcC\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIDUn1gavgHAu+nlKh9sZ/KVqBdNIvsidQkPzuPU0osa/AiEAga+HoyNGLfq5QIMxSBhlvd/G881yteIQGAoTmBSCs8s="}],"size":5602,"noattachment":false,"key":"/token-types/-/token-types-5.0.0-alpha.2.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.2_1639755548778_0.8203299830279349"},"_hasShrinkwrap":false,"publish_time":1639755548941,"_cnpm_publish_time":1639755548941,"dist-tags":{"cjs":"4.2.1","esm":"5.0.0-alpha.3","latest":"6.2.0"}}