Package Exports
- token-types
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (token-types) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
A primitive token library used to read from, and to write a node Buffer
.
Tokens
node-strtok
supports a wide variety of numerical tokens out of the box:
UINT8
UINT16_BE
,UINT16_LE
UINT24_BE
,UINT24_LE
UINT32_BE
,UINT32_LE
UINT64_BE
,UINT64_LE
*INT8
INT16_BE
,INT16_LE
INT24_BE
,INT24_LE
INT32_BE
,INT32_LE
INT64_BE
,UINT64_LE
*
String types:
- Windows-1252
- ISO-8859-1
*) The 64-bit tokens are best effort based, since JavaScript limit value size to less than 2^64.
Complex tokens can be added, which makes very suitable for reading binary files or network messages:
ExtendedHeader = {
len: 10,
get: (buf, off) => {
return {
// Extended header size
size: Token.UINT32_BE.get(buf, off),
// Extended Flags
extendedFlags: Token.UINT16_BE.get(buf, off + 4),
// Size of padding
sizeOfPadding: Token.UINT32_BE.get(buf, off + 6),
// CRC data present
crcDataPresent: common.strtokBITSET.get(buf, off + 4, 31)
};
}
};