token-types
Advanced tools
Comparing version 1.2.0 to 1.2.1
{ | ||
"name": "token-types", | ||
"version": "1.2.0", | ||
"description": "Common token types for decoding and encoding binairy values", | ||
"version": "1.2.1", | ||
"description": "Common token types for decoding and encoding numeric and string values", | ||
"author": { | ||
@@ -6,0 +6,0 @@ "name": "Borewit", |
[![Build Status](https://travis-ci.org/Borewit/token-types.svg?branch=master)](https://travis-ci.org/Borewit/token-types) | ||
[![NPM version](https://badge.fury.io/js/token-types.svg)](https://npmjs.org/package/token-types) | ||
[![npm downloads](http://img.shields.io/npm/dm/token-types.svg)](https://npmjs.org/package/token-types) | ||
[![npm downloads](http://img.shields.io/npm/dm/token-types.svg)](https://npmcharts.com/compare/token-types,strtok3?start=1200&interval=30) | ||
[![Dependencies](https://david-dm.org/Borewit/token-types.svg)](https://david-dm.org/Borewit/token-types) | ||
@@ -12,6 +12,6 @@ [![coveralls](https://coveralls.io/repos/github/Borewit/token-types/badge.svg?branch=master)](https://coveralls.io/github/Borewit/token-types?branch=master) | ||
# strtok3 | ||
# token-types | ||
A primitive token library used to read from, and to write a node `Buffer`. | ||
Although it is possible to use this module directly, it is designed to be used with [strtok3 tokenizer](https://github.com/Borewit/strtok3). | ||
A primitive token library used to read and write from a node `Buffer`. | ||
Although it is possible to use this module directly, it is primary designed to be used with [strtok3 tokenizer](https://github.com/Borewit/strtok3). | ||
@@ -23,5 +23,24 @@ ## Installation | ||
``` | ||
## Example | ||
```js | ||
const strtok3 = require('strtok3'); | ||
const token = require('token-types'); | ||
(async () => { | ||
const tokenizer = await strtok3.fromFile("somefile.bin"); | ||
try { | ||
const myNumber = await tokenizer.readToken(token.Float32_BE); | ||
console.log(`My number: ${myNumber}`); | ||
} finally { | ||
tokenizer.close(); // Close the file | ||
} | ||
})(); | ||
``` | ||
## Tokens | ||
### Numeric tokens | ||
`node-strtok` supports a wide variety of numerical tokens out of the box: | ||
@@ -58,2 +77,4 @@ | ||
### Other tokens | ||
String types: | ||
@@ -65,4 +86,6 @@ * Windows-1252 | ||
### Custom token | ||
Complex tokens can be added, which makes very suitable for reading binary files or network messages: | ||
```javascript | ||
```jS | ||
ExtendedHeader = { | ||
@@ -69,0 +92,0 @@ len: 10, |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
31282
104