{"name":"token-types","version":"5.0.0-alpha.1","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":{".":{"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","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":"b5528736c9c8395652443ff32680ac60d400ee82","homepage":"https://github.com/Borewit/token-types#readme","_id":"token-types@5.0.0-alpha.1","_nodeVersion":"12.22.7","_npmVersion":"6.14.5","dist":{"integrity":"sha512-7vlKSAMCNB1zO078fdjCOMyzgvFWWEUUB2Kmyj9VQKKIlDSOFQlWQeUy+lFzMzmXDiYX8DY99iwn8BQU3wCiog==","shasum":"9e59bfbb8dfc0c62f03fd39a804e142186824182","tarball":"http://registry-npm.ywwl.com/token-types/download/token-types-5.0.0-alpha.1.tgz","fileCount":5,"unpackedSize":24728,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhu6dDCRA9TVsSAnZWagAATScP/i+GvIqUhjqrvo75G5vb\ntgFMNuxAq/Otjkladu/FlEWS9R3xQvQAxPGclRyUQuoDVydkK4XIo9huvvy0\n5SelTi3RIhXz5TrIXYwsjIP60+Q0XbZpQ7dyyYpdChxDfGMuHLzqfomcKxSj\na77feEon+bgrHwDFAtFchR/FhROMMjAtnE7r+/TzDB4BfV5z0W2ioQUovea+\nfsPKNxRhbdFUUEjJGCy8wB7nwtBKFi7sGADMOwBqbTztZepP2s0RkH/dgkBc\nKlg5z6/HSb3CgfjlWGyT+ukD4DIZpcklgYaZ1jt6ihLx3lZZ7ceJDr/T7meA\n2xt2lscnHuS+CeqcNJQ/iTt3hLomohW4i/ijlHY3W31e7jb1v+OnkqAWS/dX\n61WX079B7TJLaPcXJ7k/+OTMaTSKipJJvF0WcYALYoa+mUFjirJaLF/41af2\nmczh1rC0sAgqM9exly4gbqk1RvSkKw87wXfqsqEPi+IlqnsbqpUV9RqdW4Nd\nlMNeIIz4zGpNNELbx7ByqvWiMbvJ9oBhO65H5otwgUotTUcjEP2ATm/h+fon\n8gHugFN5MZPoOF078RlT4oB2lYvaHV1Yt3XpYE5V6X43OVTIoKE0tw22bLJf\njzYp1soUDp5aAqlo60GydzPquXsVMGp7tRFRa9HXuo50zoSz/gY01Tej5Uvr\nY4X3\r\n=Iaon\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCUQpU8H2jZxrk0skXOTdc5lXYIAYIvA5RMa0lwKnNKhAIgC6h6s++n/LTLokedngdk3peBGIiPD107Faa9cM2166k="}],"size":5632,"noattachment":false,"key":"/token-types/-/token-types-5.0.0-alpha.1.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.1_1639688003165_0.7988448418168856"},"_hasShrinkwrap":false,"publish_time":1639688003308,"_cnpm_publish_time":1639688003308,"dist-tags":{"cjs":"4.2.1","esm":"5.0.0-alpha.3","latest":"6.2.0"}}