{"name":"token-types","version":"3.0.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 --require ts-node/register --require source-map-support/register --full-trace --recursive test/test-*.ts","test-coverage":"nyc npm run test","coveralls":"npm run test-coverage && nyc report --reporter=text-lcov | coveralls"},"engines":{"node":">=10"},"repository":{"type":"git","url":"git+https://github.com/Borewit/token-types.git"},"license":"MIT","main":"lib/index.js","types":"lib/index.d.ts","bugs":{"url":"https://github.com/Borewit/token-types/issues"},"devDependencies":{"@types/chai":"^4.2.19","@types/mocha":"^8.2.1","@types/node":"^15.12.5","chai":"^4.3.4","coveralls":"^3.1.0","del-cli":"^4.0.0","mocha":"^7.2.0","nyc":"^15.1.0","remark-cli":"^9.0.0","remark-preset-lint-recommended":"^5.0.0","source-map-support":"^0.5.19","ts-node":"^10.0.0","tslint":"^6.1.3","typescript":"^4.3.4"},"dependencies":{"@tokenizer/token":"^0.1.1","ieee754":"^1.2.1"},"remarkConfig":{"plugins":["preset-lint-recommended"]},"nyc":{"exclude":["test/**/*.ts","lib/**/*.*.js"],"extension":[".ts"],"sourceMap":true,"instrument":true,"reporter":["lcov","text"],"report-dir":"coverage"},"keywords":["token","integer","unsigned","numeric","float","IEEE","754","strtok3"],"gitHead":"1d7fda1f89753aa4d77bc49d0b6ca8c36723f109","homepage":"https://github.com/Borewit/token-types#readme","_id":"token-types@3.0.0","_nodeVersion":"14.17.1","_npmVersion":"6.14.5","dist":{"integrity":"sha512-1cV7R6TRKfCG1++se5xGy9fUpD+L1u/7XgmViGA1Y5bubHt6W4w1r1j0uOk+5ngM6yhssRJ+qR+IaviVgAizJA==","shasum":"982fb4e705103bc647fd281b06de213ea06ce65a","tarball":"http://registry-npm.ywwl.com/token-types/download/token-types-3.0.0.tgz","fileCount":5,"unpackedSize":23260,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJg6aGaCRA9TVsSAnZWagAAUbkP/jcX3G9CfX2TzQLAkPO3\nAo3VUrNR9PpE2UKJ+NaGRxAD8/COarB/X8gJ0khwG2PI8K62MCjFbZ/fdgOJ\nOVwxe1KwidgodnicCJ6ZC7gRqrPEFOXkxQ/sa617FZJQcB2Z91LzsCIWUuls\nh6tkjQ6LYdVb/j2t6EGSTEjd3qeJafdNoj+8O+i6DITNsSYkJOlAPoDHMQ5x\nh7FnRlFiQXMtxOCb/hM/D6Jxn5zn7yEnX61LraU39Jqw1owEUy2ZBiMe3YrQ\n0G7z+r88kMe0lXqdEeScQu3vT3l8F67Z0ZIRKU2K62liyLHmLpjEyBkxO79i\n29zS2I7IhzimYYX061W1rSTFVDgehvHu0og3ZVS3CxqM2Dow4FbdlaVZfeJo\nGHx5si//osgjhbg67gUzdL5mTLTD2a5Zr4wmyZpSDYIUVPTrR61ehY98OpTL\n4wJrq9k+NXX4D9bFeYPF8kw/9nkHk6f4o4e6esW3WRyI3qDCkTnaMLEi5MKh\ni8G+BSmhstliyJKddffti/ZkWx+Dq9+iow6tTLq42q6fBp4jTmWK48FT19ID\nqPHhMb6Ri/pe60w9jiC+gbEP6CsZjDFZ9ShvpbscesgrXXsi+5BsQQBwauo8\nLlUtDlGnZc6Ybz48vCuRZISboeuoelVSe0ZkZR87tm2fB/tiNsLXFLFduSrh\nELGB\r\n=lmdv\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCMs2GpMhuyV1w1R2pKQ/NuVvFJI3MBFT5BOrqyc4zToAIgOft2yCXsTNpK915yvofG0BMfjMhlBMlZWARDFlSx+zc="}],"size":5543,"noattachment":false,"key":"/token-types/-/token-types-3.0.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_3.0.0_1625923993377_0.4636375700704789"},"_hasShrinkwrap":false,"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## Compatibility\n\nModule: version 5 migrated from [CommonJS](https://en.wikipedia.org/wiki/CommonJS) to [pure ECMAScript Module (ESM)](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c).\nJavaScript is compliant with [ECMAScript 2019 (ES10)](https://en.wikipedia.org/wiki/ECMAScript#10th_Edition_%E2%80%93_ECMAScript_2019).\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\nimport * as strtok3 from 'strtok3';\nimport * as token from '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","publish_time":1625923993503,"_cnpm_publish_time":1625923993503,"dist-tags":{"cjs":"4.2.1","esm":"5.0.0-alpha.3","latest":"6.2.0"}}