token-types
Advanced tools
Comparing version 4.0.1 to 4.1.0
@@ -121,4 +121,9 @@ /// <reference types="node" /> | ||
constructor(len: number); | ||
get(array: Uint8Array, off: number): Uint8Array; | ||
get(array: Uint8Array, offset: number): Uint8Array; | ||
} | ||
export declare class BufferType implements IGetToken<Uint8Array, Buffer> { | ||
len: number; | ||
constructor(len: number); | ||
get(buffer: Buffer, off: number): Buffer; | ||
} | ||
/** | ||
@@ -131,3 +136,3 @@ * Consume a fixed number of bytes from the stream and return a string with a specified encoding. | ||
constructor(len: number, encoding: BufferEncoding); | ||
get(buffer: Buffer, offset: number): string; | ||
get(uint8Array: Uint8Array, offset: number): string; | ||
} | ||
@@ -134,0 +139,0 @@ /** |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.AnsiStringType = exports.StringType = exports.Uint8ArrayType = exports.IgnoreType = exports.Float80_LE = exports.Float80_BE = exports.Float64_LE = exports.Float64_BE = exports.Float32_LE = exports.Float32_BE = exports.Float16_LE = exports.Float16_BE = exports.INT64_BE = exports.UINT64_BE = exports.INT64_LE = exports.UINT64_LE = exports.INT32_LE = exports.INT32_BE = exports.INT24_BE = exports.INT24_LE = exports.INT16_LE = exports.INT16_BE = exports.INT8 = exports.UINT32_BE = exports.UINT32_LE = exports.UINT24_BE = exports.UINT24_LE = exports.UINT16_BE = exports.UINT16_LE = exports.UINT8 = void 0; | ||
exports.AnsiStringType = exports.StringType = exports.BufferType = exports.Uint8ArrayType = exports.IgnoreType = exports.Float80_LE = exports.Float80_BE = exports.Float64_LE = exports.Float64_BE = exports.Float32_LE = exports.Float32_BE = exports.Float16_LE = exports.Float16_BE = exports.INT64_BE = exports.UINT64_BE = exports.INT64_LE = exports.UINT64_LE = exports.INT32_LE = exports.INT32_BE = exports.INT24_BE = exports.INT24_LE = exports.INT16_LE = exports.INT16_BE = exports.INT8 = exports.UINT32_BE = exports.UINT32_LE = exports.UINT24_BE = exports.UINT24_LE = exports.UINT16_BE = exports.UINT16_LE = exports.UINT8 = void 0; | ||
const ieee754 = require("ieee754"); | ||
@@ -378,7 +378,16 @@ // Primitive types | ||
} | ||
get(array, off) { | ||
return Uint8Array.prototype.slice(off, off + this.len); | ||
get(array, offset) { | ||
return array.subarray(offset, offset + this.len); | ||
} | ||
} | ||
exports.Uint8ArrayType = Uint8ArrayType; | ||
class BufferType { | ||
constructor(len) { | ||
this.len = len; | ||
} | ||
get(buffer, off) { | ||
return buffer.slice(off, off + this.len); | ||
} | ||
} | ||
exports.BufferType = BufferType; | ||
/** | ||
@@ -392,4 +401,4 @@ * Consume a fixed number of bytes from the stream and return a string with a specified encoding. | ||
} | ||
get(buffer, offset) { | ||
return buffer.toString(this.encoding, offset, offset + this.len); | ||
get(uint8Array, offset) { | ||
return Buffer.from(uint8Array).toString(this.encoding, offset, offset + this.len); | ||
} | ||
@@ -396,0 +405,0 @@ } |
{ | ||
"name": "token-types", | ||
"version": "4.0.1", | ||
"version": "4.1.0", | ||
"description": "Common token types for decoding and encoding numeric and string values", | ||
@@ -5,0 +5,0 @@ "author": { |
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
25364
607