You're Invited: Meet the Socket team at BSidesSF and RSAC - April 27 - May 1.RSVP
Socket
Sign inDemoInstall
Socket

@bnaya/objectbuffer

Package Overview
Dependencies
Maintainers
1
Versions
122
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bnaya/objectbuffer - npm Package Compare versions

Comparing version

to
0.0.0-2a35d64

4

dist/internal/getAllLinkedAddresses.js
import { readEntry } from "./store";
import { ENTRY_TYPE } from "./entry-types";
import { hashMapGetPointersToFree } from "./hashmap/hashmap";
import { UNDEFINED_KNOWN_ADDRESS, NULL_KNOWN_ADDRESS, TRUE_KNOWN_ADDRESS, FALSE_KNOWN_ADDRESS } from "./consts";
import { isKnownAddressValuePointer } from "./utils";
export function getAllLinkedAddresses(carrier, ignoreRefCount, entryPointer) {

@@ -16,3 +16,3 @@ const leafAddresses = [];

function getAllLinkedAddressesStep(carrier, ignoreRefCount, entryPointer, leafAddresses, arcAddresses) {
if (entryPointer === UNDEFINED_KNOWN_ADDRESS || entryPointer === NULL_KNOWN_ADDRESS || entryPointer === TRUE_KNOWN_ADDRESS || entryPointer === FALSE_KNOWN_ADDRESS) {
if (isKnownAddressValuePointer(entryPointer)) {
return;

@@ -19,0 +19,0 @@ }

import { ENTRY_TYPE, isPrimitiveEntryType } from "./entry-types";
import { isPrimitive, primitiveValueToEntry, strByteLength } from "./utils";
import { isPrimitive, primitiveValueToEntry, isKnownAddressValuePointer } from "./utils";
import { BigInt64OverflowError } from "./exceptions";
import { INITIAL_ENTRY_POINTER_TO_POINTER, INITIAL_ENTRY_POINTER_VALUE, UNDEFINED_KNOWN_ADDRESS, NULL_KNOWN_ADDRESS, TRUE_KNOWN_ADDRESS, FALSE_KNOWN_ADDRESS } from "./consts";
import { INITIAL_ENTRY_POINTER_TO_POINTER, INITIAL_ENTRY_POINTER_VALUE } from "./consts";
import { saveValue } from "./saveValue";

@@ -256,7 +256,11 @@ import { getAllLinkedAddresses } from "./getAllLinkedAddresses";

return true;
}
} // kill for strings for now
// if (
// entryA.type === ENTRY_TYPE.STRING &&
// typeofTheValue === "string" &&
// entryA.allocatedBytes >= strByteLength(value as string)
// ) {
// return true;
// }
if (entryA.type === ENTRY_TYPE.STRING && typeofTheValue === "string" && entryA.allocatedBytes >= strByteLength(value)) {
return true;
}

@@ -269,3 +273,3 @@ return false;

if (isPrimitive(value) && isPrimitiveEntryType(existingValueEntry.type) && canReuseMemoryOfEntry(existingValueEntry, value) && existingEntryPointer !== 0) {
if (!isKnownAddressValuePointer(existingEntryPointer) && isPrimitive(value) && isPrimitiveEntryType(existingValueEntry.type) && canReuseMemoryOfEntry(existingValueEntry, value)) {
const newEntry = primitiveValueToEntry(value);

@@ -317,3 +321,3 @@ writeEntry(carrier, existingEntryPointer, newEntry);

// No memory to free/ARC
if (deletedValuePointer === UNDEFINED_KNOWN_ADDRESS || deletedValuePointer === NULL_KNOWN_ADDRESS || deletedValuePointer === TRUE_KNOWN_ADDRESS || deletedValuePointer === FALSE_KNOWN_ADDRESS) {
if (isKnownAddressValuePointer(deletedValuePointer)) {
return;

@@ -320,0 +324,0 @@ }

@@ -12,2 +12,3 @@ import { primitive, Entry, ExternalArgs, InternalAPI, ExternalArgsApi } from "./interfaces";

export declare function align(value: number, alignTo?: number): number;
export declare function isKnownAddressValuePointer(entryPointer: number): boolean;
//# sourceMappingURL=utils.d.ts.map
import { ENTRY_TYPE } from "./entry-types";
import { INTERNAL_API_SYMBOL } from "./symbols";
import { UNDEFINED_KNOWN_ADDRESS, NULL_KNOWN_ADDRESS, TRUE_KNOWN_ADDRESS, FALSE_KNOWN_ADDRESS } from "./consts";
const primitives = ["string", "number", "bigint", "boolean", "undefined"];

@@ -93,2 +94,5 @@ export function isPrimitive(value) {

return Math.ceil(value / alignTo) * alignTo;
}
export function isKnownAddressValuePointer(entryPointer) {
return entryPointer === UNDEFINED_KNOWN_ADDRESS || entryPointer === NULL_KNOWN_ADDRESS || entryPointer === TRUE_KNOWN_ADDRESS || entryPointer === FALSE_KNOWN_ADDRESS;
}
{
"name": "@bnaya/objectbuffer",
"description": "Object-like api, backed by an array buffer",
"version": "0.0.0-136a848",
"version": "0.0.0-2a35d64",
"main": "dist/objectbuffer.cjs.js",

@@ -6,0 +6,0 @@ "module": "dist/index.js",

@@ -11,3 +11,2 @@ import {

} from "./interfaces";
import { IMemPool } from "@thi.ng/malloc";
import { incrementRefCount, decrementRefCount, readEntry } from "./store";

@@ -14,0 +13,0 @@ import { WrapperDestroyed } from "./exceptions";

@@ -5,8 +5,3 @@ import { readEntry } from "./store";

import { hashMapGetPointersToFree } from "./hashmap/hashmap";
import {
UNDEFINED_KNOWN_ADDRESS,
NULL_KNOWN_ADDRESS,
TRUE_KNOWN_ADDRESS,
FALSE_KNOWN_ADDRESS
} from "./consts";
import { isKnownAddressValuePointer } from "./utils";

@@ -39,8 +34,3 @@ export function getAllLinkedAddresses(

) {
if (
entryPointer === UNDEFINED_KNOWN_ADDRESS ||
entryPointer === NULL_KNOWN_ADDRESS ||
entryPointer === TRUE_KNOWN_ADDRESS ||
entryPointer === FALSE_KNOWN_ADDRESS
) {
if (isKnownAddressValuePointer(entryPointer)) {
return;

@@ -47,0 +37,0 @@ }

import { ENTRY_TYPE } from "./entry-types";
import { TextDecoder, TextEncoder } from "./textEncoderDecoderTypes";
import { IMemPool } from "@thi.ng/malloc";

@@ -5,0 +4,0 @@ export type primitive = string | number | bigint | boolean | undefined | null;

@@ -127,3 +127,3 @@ /* eslint-env jest */

expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`704`);
expect(carrier.allocator.stats().top).toMatchInlineSnapshot(`728`);
});

@@ -130,0 +130,0 @@

import { ENTRY_TYPE, isPrimitiveEntryType } from "./entry-types";
import { Entry, primitive, DataViewAndAllocatorCarrier } from "./interfaces";
import { isPrimitive, primitiveValueToEntry, strByteLength } from "./utils";
import {
isPrimitive,
primitiveValueToEntry,
isKnownAddressValuePointer
} from "./utils";
import { ExternalArgs } from "./interfaces";

@@ -8,7 +12,3 @@ import { BigInt64OverflowError } from "./exceptions";

INITIAL_ENTRY_POINTER_TO_POINTER,
INITIAL_ENTRY_POINTER_VALUE,
UNDEFINED_KNOWN_ADDRESS,
NULL_KNOWN_ADDRESS,
TRUE_KNOWN_ADDRESS,
FALSE_KNOWN_ADDRESS
INITIAL_ENTRY_POINTER_VALUE
} from "./consts";

@@ -318,9 +318,10 @@ import { saveValue } from "./saveValue";

if (
entryA.type === ENTRY_TYPE.STRING &&
typeofTheValue === "string" &&
entryA.allocatedBytes >= strByteLength(value as string)
) {
return true;
}
// kill for strings for now
// if (
// entryA.type === ENTRY_TYPE.STRING &&
// typeofTheValue === "string" &&
// entryA.allocatedBytes >= strByteLength(value as string)
// ) {
// return true;
// }

@@ -341,6 +342,6 @@ return false;

if (
!isKnownAddressValuePointer(existingEntryPointer) &&
isPrimitive(value) &&
isPrimitiveEntryType(existingValueEntry.type) &&
canReuseMemoryOfEntry(existingValueEntry, value) &&
existingEntryPointer !== 0
canReuseMemoryOfEntry(existingValueEntry, value)
) {

@@ -420,8 +421,3 @@ const newEntry = primitiveValueToEntry(value);

// No memory to free/ARC
if (
deletedValuePointer === UNDEFINED_KNOWN_ADDRESS ||
deletedValuePointer === NULL_KNOWN_ADDRESS ||
deletedValuePointer === TRUE_KNOWN_ADDRESS ||
deletedValuePointer === FALSE_KNOWN_ADDRESS
) {
if (isKnownAddressValuePointer(deletedValuePointer)) {
return;

@@ -428,0 +424,0 @@ }

@@ -10,2 +10,8 @@ import {

import { INTERNAL_API_SYMBOL } from "./symbols";
import {
UNDEFINED_KNOWN_ADDRESS,
NULL_KNOWN_ADDRESS,
TRUE_KNOWN_ADDRESS,
FALSE_KNOWN_ADDRESS
} from "./consts";

@@ -134,1 +140,10 @@ const primitives = [

}
export function isKnownAddressValuePointer(entryPointer: number) {
return (
entryPointer === UNDEFINED_KNOWN_ADDRESS ||
entryPointer === NULL_KNOWN_ADDRESS ||
entryPointer === TRUE_KNOWN_ADDRESS ||
entryPointer === FALSE_KNOWN_ADDRESS
);
}

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

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 too big to display

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display