Socket
Socket
Sign inDemoInstall

@ganache/utils

Package Overview
Dependencies
6
Maintainers
3
Versions
64
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.1.1-alpha.0 to 0.1.1-beta.0

2

lib/src/common.js
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.toBigIntBE = exports.toBufferBE = void 0;
var bigint_buffer_1 = require("bigint-buffer");
var bigint_buffer_1 = require("@trufflesuite/bigint-buffer");
Object.defineProperty(exports, "toBufferBE", { enumerable: true, get: function () { return bigint_buffer_1.toBufferBE; } });
Object.defineProperty(exports, "toBigIntBE", { enumerable: true, get: function () { return bigint_buffer_1.toBigIntBE; } });
//# sourceMappingURL=common.js.map

@@ -39,8 +39,19 @@ "use strict";

}
toBuffer(byteLength = null) {
toBuffer() {
// 0x0, 0x00, 0x000, etc should return BUFFER_EMPTY
if (Buffer.isBuffer(this.value)) {
return this.value;
// trim zeros from start
let best = 0;
for (best = 0; best < this.value.length; best++) {
if (this.value[best] !== 0)
break;
}
if (best > 0) {
return this.value.slice(best);
}
else {
return this.value;
}
}
else if (typeof this.value === "string" && byteLength == null) {
else if (typeof this.value === "string") {
let val = this.value.slice(2).replace(/^(?:0+(.+?))?$/, "$1");

@@ -47,0 +58,0 @@ if (val === "" || val === "0") {

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.bufferToBigInt = void 0;
const bigint_buffer_1 = require("bigint-buffer");
const bigint_buffer_1 = require("@trufflesuite/bigint-buffer");
/**

@@ -6,0 +6,0 @@ * note: this doesn't handle negative values

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.KNOWN_CHAINIDS = exports.WEI = exports.RPCQUANTITY_ONE = exports.RPCQUANTITY_ZERO = exports.RPCQUANTITY_EMPTY = exports.BUFFER_8_ZERO = exports.BUFFER_32_ZERO = exports.BUFFER_ZERO = exports.BUFFER_EMPTY = exports.ACCOUNT_ZERO = exports.BUFFER_256_ZERO = void 0;
exports.KNOWN_CHAINIDS = exports.WEI = exports.RPCQUANTITY_ONE = exports.RPCQUANTITY_ZERO = exports.RPCQUANTITY_EMPTY = exports.DATA_EMPTY = exports.BUFFER_8_ZERO = exports.BUFFER_32_ZERO = exports.BUFFER_ZERO = exports.BUFFER_EMPTY = exports.ACCOUNT_ZERO = exports.BUFFER_256_ZERO = void 0;
const json_rpc_data_1 = require("../things/json-rpc/json-rpc-data");
const json_rpc_quantity_1 = require("../things/json-rpc/json-rpc-quantity");

@@ -11,2 +12,3 @@ exports.BUFFER_256_ZERO = Buffer.allocUnsafe(256).fill(0);

exports.BUFFER_8_ZERO = exports.BUFFER_256_ZERO.slice(0, 8);
exports.DATA_EMPTY = json_rpc_data_1.Data.from(exports.BUFFER_EMPTY);
exports.RPCQUANTITY_EMPTY = json_rpc_quantity_1.Quantity.from(exports.BUFFER_EMPTY, true);

@@ -13,0 +15,0 @@ exports.RPCQUANTITY_ZERO = json_rpc_quantity_1.Quantity.from(exports.BUFFER_ZERO);

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.hasOwn = void 0;
const _hasOwn = {}.hasOwnProperty.call.bind({}.hasOwnProperty);
/**

@@ -15,3 +16,6 @@ * /**

*/
exports.hasOwn = {}.hasOwnProperty.call.bind({}.hasOwnProperty);
const hasOwn = (obj, prop) => {
return obj != null && _hasOwn(obj, prop);
};
exports.hasOwn = hasOwn;
//# sourceMappingURL=has-own.js.map

@@ -10,9 +10,10 @@ "use strict";

* read and remove the element call `shift()`
* @param size the size of the heap
* @param less the comparator function
* @param refresher the refresher function
*/
constructor(less) {
constructor(less, refresher) {
this.length = 0;
this.array = [];
this.less = less;
this.refresher = refresher;
}

@@ -27,2 +28,23 @@ init(array) {

/**
* Updates all entries by calling the Heap's `refresher` function for each
* item in the heap and then re-sorting.
* @param context
*/
/**
* Updates all entries by calling the Heap's `refresher` function for each
* item in the heap and then re-sorting.
* @param context
*/
refresh(context) {
const length = this.length;
const mid = (length / 2) | 0;
for (let i = mid; i < length; i++) {
this.refresher(this.array[i], context);
}
for (let i = mid - 1; i >= 0;) {
this.refresher(this.array[i], context);
this.down(i--, length);
}
}
/**
* Pushes a new element onto the heap

@@ -187,5 +209,6 @@ * @param value

* @param less
* @param refresher
*/
static from(item, less) {
const heap = new Heap(less);
static from(item, less, refresher) {
const heap = new Heap(less, refresher);
heap.array = [item];

@@ -192,0 +215,0 @@ heap.length = 1;

@@ -6,3 +6,3 @@ {

},
"version": "0.1.1-alpha.0",
"version": "0.1.1-beta.0",
"description": "Utility functions for @ganache packages",

@@ -30,3 +30,4 @@ "author": "David Murdoch <david@trufflesuite.com> (https://davidmurdoch.com)",

"tsc": "ttsc --build",
"test": "echo 'no tests'"
"test": "npm run mocha",
"mocha": "cross-env TS_NODE_COMPILER=ttypescript TS_NODE_FILES=true mocha -s 0 -t 0 --exit --check-leaks --throw-deprecation --trace-warnings --require ts-node/register 'tests/**/*.test.ts'"
},

@@ -56,7 +57,8 @@ "bugs": {

"devDependencies": {
"@trufflesuite/uws-js-unofficial": "18.14.0-unofficial.10",
"@types/mocha": "8.2.2",
"@types/seedrandom": "2.4.28",
"@trufflesuite/uws-js-unofficial": "20.4.0-unofficial.2",
"@types/mocha": "9.0.0",
"@types/seedrandom": "3.0.1",
"cross-env": "7.0.3",
"mocha": "8.4.0",
"mocha": "9.1.3",
"sinon": "11.1.2",
"ts-node": "9.1.1",

@@ -67,5 +69,5 @@ "ttypescript": "1.5.12",

"optionalDependencies": {
"bigint-buffer": "1.1.5"
"@trufflesuite/bigint-buffer": "1.1.9"
},
"gitHead": "2110fd2b7fc9b2b41ba5e2a85dfecd13650dadb7"
"gitHead": "3a2646f7aeed85e8ad0af20cb12c239109ba9005"
}

@@ -1,2 +0,2 @@

export { toBufferBE, toBigIntBE } from "bigint-buffer";
export { toBufferBE, toBigIntBE } from "@trufflesuite/bigint-buffer";
//# sourceMappingURL=common.d.ts.map

@@ -7,3 +7,3 @@ /// <reference types="node" />

toString(): string | null;
toBuffer(byteLength?: number | null): Buffer;
toBuffer(): Buffer;
toBigInt(): bigint | null;

@@ -10,0 +10,0 @@ toNumber(): number;

@@ -41,2 +41,3 @@ /// <reference types="node" />

*/
format(result: ResponseFormat, payload: RequestFormat): RecognizedString | Generator<RecognizedString>;
format(result: ResponseFormat, payload: RequestFormat): RecognizedString;

@@ -43,0 +44,0 @@ /**

@@ -12,3 +12,3 @@ /// <reference types="node" />

interface JSON {
parse(text: Buffer, reviver?: (key: any, value: any) => any): any;
parse(text: string | Buffer, reviver?: (key: any, value: any) => any): any;
}

@@ -15,0 +15,0 @@ }

/// <reference types="node" />
import { Data } from "../things/json-rpc/json-rpc-data";
import { Quantity } from "../things/json-rpc/json-rpc-quantity";

@@ -9,2 +10,3 @@ export declare const BUFFER_256_ZERO: Buffer;

export declare const BUFFER_8_ZERO: Buffer;
export declare const DATA_EMPTY: Data;
export declare const RPCQUANTITY_EMPTY: Quantity;

@@ -11,0 +13,0 @@ export declare const RPCQUANTITY_ZERO: Quantity;

declare type Comparator<T> = (values: T[], a: number, b: number) => boolean;
export declare class Heap<T> {
export declare class Heap<T, U = any> {
length: number;
array: T[];
protected readonly less: Comparator<T>;
protected less: Comparator<T>;
protected refresher: (item: T, context: U) => void;
/**

@@ -11,8 +12,19 @@ * Creates a priority-queue heap where the highest priority element,

* read and remove the element call `shift()`
* @param size the size of the heap
* @param less the comparator function
* @param refresher the refresher function
*/
constructor(less: Comparator<T>);
constructor(less: Comparator<T>, refresher?: (item: T, context: U) => void);
init(array: T[]): void;
/**
* Updates all entries by calling the Heap's `refresher` function for each
* item in the heap and then re-sorting.
* @param context
*/
/**
* Updates all entries by calling the Heap's `refresher` function for each
* item in the heap and then re-sorting.
* @param context
*/
refresh(context: U): void;
/**
* Pushes a new element onto the heap

@@ -88,6 +100,7 @@ * @param value

* @param less
* @param refresher
*/
static from<T>(item: T, less: Comparator<T>): Heap<T>;
static from<T, U>(item: T, less: Comparator<T>, refresher?: (item: T, context: U) => void): Heap<T, U>;
}
export {};
//# sourceMappingURL=heap.d.ts.map
/// <reference types="node" />
import seedrandom from "seedrandom";
export declare class RandomNumberGenerator {
readonly rng: seedrandom.prng;
readonly rng: ReturnType<seedrandom.Callback>;
constructor(seed?: string | null, state?: seedrandom.State);

@@ -6,0 +6,0 @@ getNumber(upperExclusiveBound?: number): number;

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 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 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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc