🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

@nxtedition/slice

Package Overview
Dependencies
Maintainers
12
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@nxtedition/slice - npm Package Compare versions

Comparing version
1.1.8
to
1.1.9
+1
-15
lib/index.d.ts

@@ -13,17 +13,3 @@ 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;
static from(buffer: Buffer, byteOffset?: number, byteLength?: number): Slice;
constructor(buffer?: Buffer<ArrayBufferLike>, byteOffset?: number, byteLength?: number, maxByteLength?: number);

@@ -30,0 +16,0 @@ reset(): void;

+10
-38

@@ -21,32 +21,3 @@ 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(
buffer = Slice.EMPTY_BUF,
byteOffset = 0,
byteLength = buffer.byteLength,
maxByteLength = byteLength,
) {
static from(buffer , byteOffset = 0, byteLength = buffer.byteLength - byteOffset) {
if (!(buffer instanceof Buffer)) {

@@ -64,10 +35,2 @@ throw new TypeError('buffer must be a Buffer')

if (
maxByteLength < byteLength ||
maxByteLength > buffer.byteLength ||
!Number.isInteger(maxByteLength)
) {
throw new RangeError(`Invalid maxByteLength: ${maxByteLength}`)
}
if (byteOffset + byteLength > buffer.byteLength) {

@@ -79,2 +42,11 @@ throw new RangeError(

return new Slice(buffer, byteOffset, byteLength)
}
constructor(
buffer = Slice.EMPTY_BUF,
byteOffset = 0,
byteLength = buffer.byteLength,
maxByteLength = byteLength,
) {
this.buffer = buffer

@@ -81,0 +53,0 @@ this.byteOffset = byteOffset

{
"name": "@nxtedition/slice",
"version": "1.1.8",
"version": "1.1.9",
"type": "module",

@@ -33,3 +33,3 @@ "main": "lib/index.js",

},
"gitHead": "088f6e6d615d4eeee0b2e317c9011dfa57308cc9"
"gitHead": "2c131da7ca8ea328fd681e975dd7caf57f9f4896"
}