bytestreamjs
Advanced tools
Comparing version 1.1.2 to 1.1.3
@@ -71,3 +71,3 @@ "use strict"; | ||
this.prevLength = this._length; | ||
this._length -= ((this.backward) ? (this._start - value) : (value - this._start)); | ||
this._length -= (this.backward) ? (this._start - value) : (value - this._start); | ||
this._start = value; | ||
@@ -79,3 +79,3 @@ } | ||
get buffer() { | ||
return this._stream.buffer; | ||
return this._stream.buffer.slice(0, this._length); | ||
} | ||
@@ -291,8 +291,3 @@ resetPosition() { | ||
append(stream) { | ||
if ((this._start + stream.length) > this._stream.length) { | ||
if (stream.length > this.appendBlock) { | ||
this.appendBlock = (stream.length + 1000); | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(stream.length); | ||
this._stream.view.set(stream.view, this._start); | ||
@@ -304,8 +299,3 @@ this._length += (stream.length * 2); | ||
appendView(view) { | ||
if ((this._start + view.length) > this._stream.length) { | ||
if (view.length > this.appendBlock) { | ||
this.appendBlock = (view.length + 1000); | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(view.length); | ||
this._stream.view.set(view, this._start); | ||
@@ -317,8 +307,3 @@ this._length += (view.length * 2); | ||
appendChar(char) { | ||
if ((this._start + 1) > this._stream.length) { | ||
if (1 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(1); | ||
this._stream.view[this._start] = char; | ||
@@ -330,23 +315,13 @@ this._length += 2; | ||
appendUint16(number) { | ||
if ((this._start + 2) > this._stream.length) { | ||
if (2 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(2); | ||
const value = new Uint16Array([number]); | ||
const view = new Uint8Array(value.buffer); | ||
this._stream.view[this._start] = view[1]; | ||
this.stream.view[this._start] = view[1]; | ||
this._stream.view[this._start + 1] = view[0]; | ||
this._length += 4; | ||
this.start = (this._start + 2); | ||
this.start = this._start + 2; | ||
this.prevLength -= 4; | ||
} | ||
appendUint24(number) { | ||
if ((this._start + 3) > this._stream.length) { | ||
if (3 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(3); | ||
const value = new Uint32Array([number]); | ||
@@ -362,8 +337,3 @@ const view = new Uint8Array(value.buffer); | ||
appendUint32(number) { | ||
if ((this._start + 4) > this._stream.length) { | ||
if (4 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(4); | ||
const value = new Uint32Array([number]); | ||
@@ -380,8 +350,3 @@ const view = new Uint8Array(value.buffer); | ||
appendInt16(number) { | ||
if ((this._start + 2) > this._stream.length) { | ||
if (2 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(2); | ||
const value = new Int16Array([number]); | ||
@@ -396,8 +361,3 @@ const view = new Uint8Array(value.buffer); | ||
appendInt32(number) { | ||
if ((this._start + 4) > this._stream.length) { | ||
if (4 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(4); | ||
const value = new Int32Array([number]); | ||
@@ -490,3 +450,12 @@ const view = new Uint8Array(value.buffer); | ||
} | ||
beforeAppend(size) { | ||
if ((this._start + size) > this._stream.length) { | ||
if (size > this.appendBlock) { | ||
this.appendBlock = size + SeqStream.APPEND_BLOCK; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
} | ||
} | ||
exports.SeqStream = SeqStream; | ||
SeqStream.APPEND_BLOCK = 1000; |
@@ -68,3 +68,3 @@ import { ByteStream } from "./byte_stream"; | ||
this.prevLength = this._length; | ||
this._length -= ((this.backward) ? (this._start - value) : (value - this._start)); | ||
this._length -= (this.backward) ? (this._start - value) : (value - this._start); | ||
this._start = value; | ||
@@ -76,3 +76,3 @@ } | ||
get buffer() { | ||
return this._stream.buffer; | ||
return this._stream.buffer.slice(0, this._length); | ||
} | ||
@@ -288,8 +288,3 @@ resetPosition() { | ||
append(stream) { | ||
if ((this._start + stream.length) > this._stream.length) { | ||
if (stream.length > this.appendBlock) { | ||
this.appendBlock = (stream.length + 1000); | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(stream.length); | ||
this._stream.view.set(stream.view, this._start); | ||
@@ -301,8 +296,3 @@ this._length += (stream.length * 2); | ||
appendView(view) { | ||
if ((this._start + view.length) > this._stream.length) { | ||
if (view.length > this.appendBlock) { | ||
this.appendBlock = (view.length + 1000); | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(view.length); | ||
this._stream.view.set(view, this._start); | ||
@@ -314,8 +304,3 @@ this._length += (view.length * 2); | ||
appendChar(char) { | ||
if ((this._start + 1) > this._stream.length) { | ||
if (1 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(1); | ||
this._stream.view[this._start] = char; | ||
@@ -327,23 +312,13 @@ this._length += 2; | ||
appendUint16(number) { | ||
if ((this._start + 2) > this._stream.length) { | ||
if (2 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(2); | ||
const value = new Uint16Array([number]); | ||
const view = new Uint8Array(value.buffer); | ||
this._stream.view[this._start] = view[1]; | ||
this.stream.view[this._start] = view[1]; | ||
this._stream.view[this._start + 1] = view[0]; | ||
this._length += 4; | ||
this.start = (this._start + 2); | ||
this.start = this._start + 2; | ||
this.prevLength -= 4; | ||
} | ||
appendUint24(number) { | ||
if ((this._start + 3) > this._stream.length) { | ||
if (3 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(3); | ||
const value = new Uint32Array([number]); | ||
@@ -359,8 +334,3 @@ const view = new Uint8Array(value.buffer); | ||
appendUint32(number) { | ||
if ((this._start + 4) > this._stream.length) { | ||
if (4 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(4); | ||
const value = new Uint32Array([number]); | ||
@@ -377,8 +347,3 @@ const view = new Uint8Array(value.buffer); | ||
appendInt16(number) { | ||
if ((this._start + 2) > this._stream.length) { | ||
if (2 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(2); | ||
const value = new Int16Array([number]); | ||
@@ -393,8 +358,3 @@ const view = new Uint8Array(value.buffer); | ||
appendInt32(number) { | ||
if ((this._start + 4) > this._stream.length) { | ||
if (4 > this.appendBlock) { | ||
this.appendBlock = 1000; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
this.beforeAppend(4); | ||
const value = new Int32Array([number]); | ||
@@ -487,2 +447,11 @@ const view = new Uint8Array(value.buffer); | ||
} | ||
beforeAppend(size) { | ||
if ((this._start + size) > this._stream.length) { | ||
if (size > this.appendBlock) { | ||
this.appendBlock = size + SeqStream.APPEND_BLOCK; | ||
} | ||
this._stream.realloc(this._stream.length + this.appendBlock); | ||
} | ||
} | ||
} | ||
SeqStream.APPEND_BLOCK = 1000; |
@@ -27,2 +27,3 @@ import { ByteStream, FindFirstNotInResult, FindFirstSequenceResult, FindPairedArraysResult, FindPairedPatternsResult } from "./byte_stream"; | ||
export declare class SeqStream { | ||
static APPEND_BLOCK: number; | ||
/** | ||
@@ -85,3 +86,3 @@ * Major stream | ||
* Return ArrayBuffer with having value of existing SeqStream length | ||
* @return} | ||
* @return | ||
*/ | ||
@@ -103,3 +104,3 @@ get buffer(): ArrayBuffer; | ||
* @param patterns Array with patterns which should be found | ||
* @param ga Maximum gap between start position and position of nearest object | ||
* @param gap Maximum gap between start position and position of nearest object | ||
* @returns | ||
@@ -256,2 +257,3 @@ */ | ||
getInt32(changeLength?: boolean): number; | ||
protected beforeAppend(size: number): void; | ||
} |
@@ -61,3 +61,3 @@ { | ||
"name": "bytestreamjs", | ||
"version": "1.1.2", | ||
"version": "1.1.3", | ||
"module": "./build/mjs/index.js", | ||
@@ -64,0 +64,0 @@ "main": "./build/cjs/index.js", |
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
171201
4371