@nxtedition/slice
Advanced tools
+15
-0
@@ -13,2 +13,17 @@ import util from 'node:util'; | ||
| static get EMPTY_BUF(): Buffer; | ||
| /** | ||
| * Fast factory for the common case of wrapping a full Buffer with no | ||
| * offset and no separate maxByteLength. Skips all the constructor's | ||
| * validation (Buffer instanceof check, byteOffset/byteLength range | ||
| * checks, integer checks, maxByteLength bounds). Use only when the | ||
| * caller already knows the input is a Buffer — e.g. wrapping freshly | ||
| * received network frames on a hot path. | ||
| * | ||
| * Note: instances produced here have a slightly different V8 hidden | ||
| * class than instances produced via `new Slice(buf)`. That introduces | ||
| * polymorphism at any downstream IC that reads slice fields. Measure | ||
| * end-to-end before adopting in code paths where consumers do heavy | ||
| * field access. | ||
| */ | ||
| static fromBuffer(buffer: Buffer): Slice; | ||
| constructor(buffer?: Buffer<ArrayBufferLike>, byteOffset?: number, byteLength?: number, maxByteLength?: number); | ||
@@ -15,0 +30,0 @@ reset(): void; |
+24
-0
@@ -21,2 +21,26 @@ import util from 'node:util' | ||
| /** | ||
| * Fast factory for the common case of wrapping a full Buffer with no | ||
| * offset and no separate maxByteLength. Skips all the constructor's | ||
| * validation (Buffer instanceof check, byteOffset/byteLength range | ||
| * checks, integer checks, maxByteLength bounds). Use only when the | ||
| * caller already knows the input is a Buffer — e.g. wrapping freshly | ||
| * received network frames on a hot path. | ||
| * | ||
| * Note: instances produced here have a slightly different V8 hidden | ||
| * class than instances produced via `new Slice(buf)`. That introduces | ||
| * polymorphism at any downstream IC that reads slice fields. Measure | ||
| * end-to-end before adopting in code paths where consumers do heavy | ||
| * field access. | ||
| */ | ||
| static fromBuffer(buffer ) { | ||
| const slice = Object.create(Slice.prototype) | ||
| const len = buffer.byteLength | ||
| slice.buffer = buffer | ||
| slice.byteOffset = 0 | ||
| slice.byteLength = len | ||
| slice.maxByteLength = len | ||
| return slice | ||
| } | ||
| constructor( | ||
@@ -23,0 +47,0 @@ buffer = Slice.EMPTY_BUF, |
+2
-2
| { | ||
| "name": "@nxtedition/slice", | ||
| "version": "1.1.7", | ||
| "version": "1.1.8", | ||
| "type": "module", | ||
@@ -33,3 +33,3 @@ "main": "lib/index.js", | ||
| }, | ||
| "gitHead": "7c9c7457c885c644c7a1e70ef894d4727ce240d6" | ||
| "gitHead": "088f6e6d615d4eeee0b2e317c9011dfa57308cc9" | ||
| } |
25612
7.51%469
8.82%