@bnaya/objectbuffer
Advanced tools
Comparing version 0.4.0 to 0.5.0
@@ -8,3 +8,3 @@ import { ArrayEntry } from "./interfaces"; | ||
export declare function getFinalValueAtArrayIndex(dataView: DataView, textDecoder: any, textEncoder: any, arrayAdditionalAllocation: number, pointerToArrayEntry: number, indexToGet: number): any; | ||
export declare function setValuePointerAtArrayIndex(dataView: DataView, textDecoder: any, textEncoder: any, pointerToArrayEntry: number, indexToSet: number, pointerToEntry: number): void; | ||
export declare function setValuePointerAtArrayIndex(dataView: DataView, textDecoder: any, pointerToArrayEntry: number, indexToSet: number, pointerToEntry: number): void; | ||
export declare function setValueAtArrayIndex(dataView: DataView, textDecoder: any, textEncoder: any, arrayAdditionalAllocation: number, pointerToArrayEntry: number, indexToSet: number, value: any): void; | ||
@@ -20,2 +20,3 @@ /** | ||
export declare function arraySort(dataView: DataView, textDecoder: any, textEncoder: any, arrayAdditionalAllocation: number, pointerToArrayEntry: number, sortComparator?: (a: any, b: any) => 1 | -1 | 0): void; | ||
export declare function arrayReverse(dataView: DataView, textDecoder: any, pointerToArrayEntry: number): void; | ||
//# sourceMappingURL=arrayHelpers.d.ts.map |
@@ -34,3 +34,3 @@ import { readEntry, reserveMemory, writeEntry } from "./store"; | ||
} | ||
export function setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
export function setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
const pointers = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet); | ||
@@ -42,3 +42,3 @@ assertNonNull(pointers); | ||
const saveValueResult = saveValue(textEncoder, dataView, arrayAdditionalAllocation, value); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
} | ||
@@ -133,2 +133,16 @@ /** | ||
return obj.toString(); | ||
} | ||
export function arrayReverse(dataView, textDecoder, pointerToArrayEntry) { | ||
const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
for (let i = 0; i < Math.floor(metadata.length / 2); i += 1) { | ||
const theOtherIndex = metadata.length - i - 1; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const a = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, i); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const b = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, i, b.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex, a.pointer); | ||
} | ||
} |
@@ -29,3 +29,3 @@ import { arrayGetMetadata, getFinalValueAtArrayIndex, setValueAtArrayIndex, shrinkArray, extendArrayIfNeeded, arrayGetPointersToValueInIndex, setValuePointerAtArrayIndex } from "./arrayHelpers"; | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
} | ||
@@ -43,3 +43,3 @@ } // copy-down items | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
@@ -46,0 +46,0 @@ dataView.setUint32(valueToCopyPointers.pointerToThePointer, 0); // using that is wastefull |
@@ -27,4 +27,7 @@ export declare class ArrayWrapper implements ProxyHandler<{}> { | ||
splice(start: number, deleteCount?: number, ...items: any[]): any[]; | ||
reverse(): this; | ||
shift(): any; | ||
unshift(...elements: any): number; | ||
} | ||
export declare function createArrayWrapper(dataView: DataView, arrayAdditionalAllocation: number, entryPointer: number, textDecoder: any, textEncoder: any): Array<any>; | ||
//# sourceMappingURL=arrayWrapper.d.ts.map |
@@ -1,2 +0,2 @@ | ||
import { getFinalValueAtArrayIndex, arrayGetMetadata, setValueAtArrayIndex, arraySort, extendArrayIfNeeded } from "./arrayHelpers"; | ||
import { getFinalValueAtArrayIndex, arrayGetMetadata, setValueAtArrayIndex, arraySort, extendArrayIfNeeded, arrayReverse } from "./arrayHelpers"; | ||
import { GET_UNDERLYING_POINTER_SYMBOL } from "./symbols"; | ||
@@ -135,17 +135,22 @@ import { arraySplice } from "./arraySplice"; | ||
return arraySplice(this.dataView, this.textDecoder, this.textEncoder, this.arrayAdditionalAllocation, this.entryPointer, start, deleteCount, ...items); | ||
} // // copy methods | ||
// private concat() { | ||
// throw new Error("unsupported"); | ||
} | ||
reverse() { | ||
arrayReverse(this.dataView, this.textDecoder, this.entryPointer); | ||
return this; | ||
} // no copy inside array is needed, so we can live with the built-in impl | ||
// public push() { | ||
// } | ||
// private slice() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private map() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private reduce() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// public pop() {} | ||
shift() { | ||
return this.splice(0, 1)[0]; | ||
} | ||
unshift(...elements) { | ||
this.splice(0, 0, ...elements); | ||
return arrayGetMetadata(this.dataView, this.textDecoder, this.entryPointer).length; | ||
} | ||
} | ||
@@ -152,0 +157,0 @@ export function createArrayWrapper(dataView, arrayAdditionalAllocation, entryPointer, textDecoder, textEncoder) { |
@@ -593,3 +593,3 @@ 'use strict'; | ||
} | ||
function setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
function setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
const pointers = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet); | ||
@@ -601,3 +601,3 @@ assertNonNull(pointers); | ||
const saveValueResult = saveValue(textEncoder, dataView, arrayAdditionalAllocation, value); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
} | ||
@@ -694,2 +694,16 @@ /** | ||
function arrayReverse(dataView, textDecoder, pointerToArrayEntry) { | ||
const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
for (let i = 0; i < Math.floor(metadata.length / 2); i += 1) { | ||
const theOtherIndex = metadata.length - i - 1; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const a = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, i); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const b = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, i, b.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex, a.pointer); | ||
} | ||
} | ||
function arraySplice(dataView, textDecoder, textEncoder, arrayAdditionalAllocation, pointerToArrayEntry, startArg, deleteCountArg, ...itemsToAddArg) { | ||
@@ -720,3 +734,3 @@ const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
} | ||
@@ -734,3 +748,3 @@ } // copy-down items | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
@@ -908,17 +922,22 @@ dataView.setUint32(valueToCopyPointers.pointerToThePointer, 0); // using that is wastefull | ||
return arraySplice(this.dataView, this.textDecoder, this.textEncoder, this.arrayAdditionalAllocation, this.entryPointer, start, deleteCount, ...items); | ||
} // // copy methods | ||
// private concat() { | ||
// throw new Error("unsupported"); | ||
} | ||
reverse() { | ||
arrayReverse(this.dataView, this.textDecoder, this.entryPointer); | ||
return this; | ||
} // no copy inside array is needed, so we can live with the built-in impl | ||
// public push() { | ||
// } | ||
// private slice() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private map() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private reduce() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// public pop() {} | ||
shift() { | ||
return this.splice(0, 1)[0]; | ||
} | ||
unshift(...elements) { | ||
this.splice(0, 0, ...elements); | ||
return arrayGetMetadata(this.dataView, this.textDecoder, this.entryPointer).length; | ||
} | ||
} | ||
@@ -925,0 +944,0 @@ function createArrayWrapper(dataView, arrayAdditionalAllocation, entryPointer, textDecoder, textEncoder) { |
@@ -589,3 +589,3 @@ const primitives = ["string", "number", "bigint", "boolean", "undefined"]; | ||
} | ||
function setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
function setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
const pointers = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet); | ||
@@ -597,3 +597,3 @@ assertNonNull(pointers); | ||
const saveValueResult = saveValue(textEncoder, dataView, arrayAdditionalAllocation, value); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
} | ||
@@ -690,2 +690,16 @@ /** | ||
function arrayReverse(dataView, textDecoder, pointerToArrayEntry) { | ||
const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
for (let i = 0; i < Math.floor(metadata.length / 2); i += 1) { | ||
const theOtherIndex = metadata.length - i - 1; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const a = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, i); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const b = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, i, b.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex, a.pointer); | ||
} | ||
} | ||
function arraySplice(dataView, textDecoder, textEncoder, arrayAdditionalAllocation, pointerToArrayEntry, startArg, deleteCountArg, ...itemsToAddArg) { | ||
@@ -716,3 +730,3 @@ const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
} | ||
@@ -730,3 +744,3 @@ } // copy-down items | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
@@ -904,17 +918,22 @@ dataView.setUint32(valueToCopyPointers.pointerToThePointer, 0); // using that is wastefull | ||
return arraySplice(this.dataView, this.textDecoder, this.textEncoder, this.arrayAdditionalAllocation, this.entryPointer, start, deleteCount, ...items); | ||
} // // copy methods | ||
// private concat() { | ||
// throw new Error("unsupported"); | ||
} | ||
reverse() { | ||
arrayReverse(this.dataView, this.textDecoder, this.entryPointer); | ||
return this; | ||
} // no copy inside array is needed, so we can live with the built-in impl | ||
// public push() { | ||
// } | ||
// private slice() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private map() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private reduce() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// public pop() {} | ||
shift() { | ||
return this.splice(0, 1)[0]; | ||
} | ||
unshift(...elements) { | ||
this.splice(0, 0, ...elements); | ||
return arrayGetMetadata(this.dataView, this.textDecoder, this.entryPointer).length; | ||
} | ||
} | ||
@@ -921,0 +940,0 @@ function createArrayWrapper(dataView, arrayAdditionalAllocation, entryPointer, textDecoder, textEncoder) { |
@@ -595,3 +595,3 @@ (function (global, factory) { | ||
} | ||
function setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
function setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, pointerToEntry) { | ||
const pointers = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet); | ||
@@ -603,3 +603,3 @@ assertNonNull(pointers); | ||
const saveValueResult = saveValue(textEncoder, dataView, arrayAdditionalAllocation, value); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, indexToSet, saveValueResult.start); | ||
} | ||
@@ -696,2 +696,16 @@ /** | ||
function arrayReverse(dataView, textDecoder, pointerToArrayEntry) { | ||
const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
for (let i = 0; i < Math.floor(metadata.length / 2); i += 1) { | ||
const theOtherIndex = metadata.length - i - 1; // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const a = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, i); // eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const b = arrayGetPointersToValueInIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, i, b.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, theOtherIndex, a.pointer); | ||
} | ||
} | ||
function arraySplice(dataView, textDecoder, textEncoder, arrayAdditionalAllocation, pointerToArrayEntry, startArg, deleteCountArg, ...itemsToAddArg) { | ||
@@ -722,3 +736,3 @@ const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); | ||
} | ||
@@ -736,3 +750,3 @@ } // copy-down items | ||
assertNonNull(valueToCopyPointers); | ||
setValuePointerAtArrayIndex(dataView, textDecoder, textEncoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
setValuePointerAtArrayIndex(dataView, textDecoder, pointerToArrayEntry, writeValueToIndex, valueToCopyPointers.pointer); // empty old array index, its still allocated! | ||
@@ -910,17 +924,22 @@ dataView.setUint32(valueToCopyPointers.pointerToThePointer, 0); // using that is wastefull | ||
return arraySplice(this.dataView, this.textDecoder, this.textEncoder, this.arrayAdditionalAllocation, this.entryPointer, start, deleteCount, ...items); | ||
} // // copy methods | ||
// private concat() { | ||
// throw new Error("unsupported"); | ||
} | ||
reverse() { | ||
arrayReverse(this.dataView, this.textDecoder, this.entryPointer); | ||
return this; | ||
} // no copy inside array is needed, so we can live with the built-in impl | ||
// public push() { | ||
// } | ||
// private slice() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private map() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private reduce() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// public pop() {} | ||
shift() { | ||
return this.splice(0, 1)[0]; | ||
} | ||
unshift(...elements) { | ||
this.splice(0, 0, ...elements); | ||
return arrayGetMetadata(this.dataView, this.textDecoder, this.entryPointer).length; | ||
} | ||
} | ||
@@ -927,0 +946,0 @@ function createArrayWrapper(dataView, arrayAdditionalAllocation, entryPointer, textDecoder, textEncoder) { |
{ | ||
"name": "@bnaya/objectbuffer", | ||
"description": "Object-like api, backed by an array buffer", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"main": "dist/objectbuffer.cjs.js", | ||
@@ -6,0 +6,0 @@ "module": "dist/index.js", |
@@ -80,3 +80,2 @@ import { readEntry, reserveMemory, writeEntry } from "./store"; | ||
textDecoder: any, | ||
textEncoder: any, | ||
pointerToArrayEntry: number, | ||
@@ -117,3 +116,2 @@ indexToSet: number, | ||
textDecoder, | ||
textEncoder, | ||
pointerToArrayEntry, | ||
@@ -308,1 +306,45 @@ indexToSet, | ||
} | ||
export function arrayReverse( | ||
dataView: DataView, | ||
textDecoder: any, | ||
pointerToArrayEntry: number | ||
) { | ||
const metadata = arrayGetMetadata(dataView, textDecoder, pointerToArrayEntry); | ||
for (let i = 0; i < Math.floor(metadata.length / 2); i += 1) { | ||
const theOtherIndex = metadata.length - i - 1; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const a = arrayGetPointersToValueInIndex( | ||
dataView, | ||
textDecoder, | ||
pointerToArrayEntry, | ||
i | ||
)!; | ||
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion | ||
const b = arrayGetPointersToValueInIndex( | ||
dataView, | ||
textDecoder, | ||
pointerToArrayEntry, | ||
theOtherIndex | ||
)!; | ||
setValuePointerAtArrayIndex( | ||
dataView, | ||
textDecoder, | ||
pointerToArrayEntry, | ||
i, | ||
b.pointer | ||
); | ||
setValuePointerAtArrayIndex( | ||
dataView, | ||
textDecoder, | ||
pointerToArrayEntry, | ||
theOtherIndex, | ||
a.pointer | ||
); | ||
} | ||
} |
@@ -89,3 +89,2 @@ import { | ||
textDecoder, | ||
textEncoder, | ||
pointerToArrayEntry, | ||
@@ -121,3 +120,2 @@ writeValueToIndex, | ||
textDecoder, | ||
textEncoder, | ||
pointerToArrayEntry, | ||
@@ -124,0 +122,0 @@ writeValueToIndex, |
@@ -327,2 +327,38 @@ /* eslint-env jest */ | ||
}); | ||
test("arrayWrapper - reverse", () => { | ||
const arrayBuffer = new ArrayBuffer(128); | ||
const dataView = new DataView(arrayBuffer); | ||
initializeArrayBuffer(arrayBuffer); | ||
const arrayToSave = [1, 2, 3, 4, 5, 6, 7]; | ||
const saverOutput = arraySaver(textEncoder, dataView, 0, arrayToSave); | ||
const arrayWrapper = createArrayWrapper( | ||
dataView, | ||
3, | ||
saverOutput.start, | ||
textDecoder, | ||
textEncoder | ||
); | ||
arrayWrapper.reverse(); | ||
arrayWrapper.reverse(); | ||
arrayWrapper.reverse(); | ||
expect(arrayWrapper).toMatchInlineSnapshot(` | ||
Array [ | ||
7, | ||
6, | ||
5, | ||
4, | ||
3, | ||
2, | ||
1, | ||
] | ||
`); | ||
expect(getFirstFreeByte(arrayBuffer)).toMatchInlineSnapshot(`128`); | ||
}); | ||
}); |
@@ -6,3 +6,4 @@ import { | ||
arraySort, | ||
extendArrayIfNeeded | ||
extendArrayIfNeeded, | ||
arrayReverse | ||
} from "./arrayHelpers"; | ||
@@ -231,15 +232,23 @@ import { GET_UNDERLYING_POINTER_SYMBOL } from "./symbols"; | ||
// // copy methods | ||
// private concat() { | ||
// throw new Error("unsupported"); | ||
public reverse() { | ||
arrayReverse(this.dataView, this.textDecoder, this.entryPointer); | ||
return this; | ||
} | ||
// no copy inside array is needed, so we can live with the built-in impl | ||
// public push() { | ||
// } | ||
// private slice() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private map() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// private reduce() { | ||
// throw new Error("unsupported"); | ||
// } | ||
// public pop() {} | ||
public shift() { | ||
return this.splice(0, 1)[0]; | ||
} | ||
public unshift(...elements: any) { | ||
this.splice(0, 0, ...elements); | ||
return arrayGetMetadata(this.dataView, this.textDecoder, this.entryPointer) | ||
.length; | ||
} | ||
} | ||
@@ -246,0 +255,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
313272
8387