Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rei-network/utils

Package Overview
Dependencies
Maintainers
2
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rei-network/utils - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

dist/initializer.d.ts

12

dist/functionalmap.d.ts

@@ -0,1 +1,4 @@

/// <reference types="node" />
/// <reference types="bn.js" />
import { BN, Address } from 'ethereumjs-util';
export declare class FunctionalMapIterator<T> implements IterableIterator<T> {

@@ -32,1 +35,10 @@ protected readonly rbtreeIt: any;

}
export declare class FunctionalBufferMap<V> extends FunctionalMap<Buffer, V> {
constructor();
}
export declare class FunctionalBNMap<V> extends FunctionalMap<BN, V> {
constructor();
}
export declare class FunctionalAddressMap<V> extends FunctionalMap<Address, V> {
constructor();
}

20

dist/functionalmap.js

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionalMap = exports.FunctionalMapIterator = void 0;
exports.FunctionalAddressMap = exports.FunctionalBNMap = exports.FunctionalBufferMap = exports.FunctionalMap = exports.FunctionalMapIterator = void 0;
const functional_red_black_tree_1 = __importDefault(require("functional-red-black-tree"));

@@ -121,2 +121,20 @@ class FunctionalMapIterator {

exports.FunctionalMap = FunctionalMap;
class FunctionalBufferMap extends FunctionalMap {
constructor() {
super((a, b) => a.compare(b));
}
}
exports.FunctionalBufferMap = FunctionalBufferMap;
class FunctionalBNMap extends FunctionalMap {
constructor() {
super((a, b) => a.cmp(b));
}
}
exports.FunctionalBNMap = FunctionalBNMap;
class FunctionalAddressMap extends FunctionalMap {
constructor() {
super((a, b) => a.buf.compare(b.buf));
}
}
exports.FunctionalAddressMap = FunctionalAddressMap;
//# sourceMappingURL=functionalmap.js.map

@@ -0,1 +1,4 @@

/// <reference types="node" />
/// <reference types="bn.js" />
import { BN, Address } from 'ethereumjs-util';
/**

@@ -20,1 +23,10 @@ * Key customizable map, implements `Set` interface

}
export declare class FunctionalBufferSet extends FunctionalSet<Buffer> {
constructor();
}
export declare class FunctionalBNSet extends FunctionalSet<BN> {
constructor();
}
export declare class FunctionalAddressSet extends FunctionalSet<Address> {
constructor();
}

@@ -6,3 +6,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.FunctionalSet = void 0;
exports.FunctionalAddressSet = exports.FunctionalBNSet = exports.FunctionalBufferSet = exports.FunctionalSet = void 0;
const functional_red_black_tree_1 = __importDefault(require("functional-red-black-tree"));

@@ -72,2 +72,20 @@ const functionalmap_1 = require("./functionalmap");

exports.FunctionalSet = FunctionalSet;
class FunctionalBufferSet extends FunctionalSet {
constructor() {
super((a, b) => a.compare(b));
}
}
exports.FunctionalBufferSet = FunctionalBufferSet;
class FunctionalBNSet extends FunctionalSet {
constructor() {
super((a, b) => a.cmp(b));
}
}
exports.FunctionalBNSet = FunctionalBNSet;
class FunctionalAddressSet extends FunctionalSet {
constructor() {
super((a, b) => a.buf.compare(b.buf));
}
}
exports.FunctionalAddressSet = FunctionalAddressSet;
//# sourceMappingURL=functionalset.js.map

31

dist/index.d.ts

@@ -5,4 +5,2 @@ /// <reference types="node" />

import tracer from 'tracer';
import { FunctionalMap } from './functionalmap';
import { FunctionalSet } from './functionalset';
interface Constructor<T = {}> {

@@ -26,2 +24,8 @@ new (...args: any[]): T;

/**
* Run function and ignore all errors
* @param fn - Function
* @returns Funtion result or undefined(if something goes wrong)
*/
export declare function ignoreError<T>(p?: Promise<T>): Promise<void | T> | undefined;
/**
* Convert hex string to buffer

@@ -39,22 +43,2 @@ * @param hex - Hex string to be converted

/**
* Create a functional map which has `Buffer` key
* @returns Functional map object
*/
export declare function createBufferFunctionalMap<T>(): FunctionalMap<Buffer, T>;
/**
* Create a functional map which has `BN` key
* @returns Functional map object
*/
export declare function createBNFunctionalMap<T>(): FunctionalMap<BN, T>;
/**
* Create a functional set which has `Buffer` key
* @returns Functional set object
*/
export declare function createBufferFunctionalSet(): FunctionalSet<Buffer>;
/**
* Create a functional set which has `BN` key
* @returns Functional set object
*/
export declare function createBNFunctionalSet(): FunctionalSet<BN>;
/**
* Get current timestamp

@@ -64,8 +48,9 @@ */

export declare const logger: tracer.Tracer.Logger;
export { setLevel } from 'tracer';
export { setLevel, getLevel } from 'tracer';
export * from './abort';
export * from './channel';
export * from './compress';
export * from './initializer';
export * from './functionalmap';
export * from './functionalset';
export * from './timeoutQueue';

@@ -16,7 +16,5 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.setLevel = exports.logger = exports.nowTimestamp = exports.createBNFunctionalSet = exports.createBufferFunctionalSet = exports.createBNFunctionalMap = exports.createBufferFunctionalMap = exports.hexStringToBN = exports.hexStringToBuffer = exports.getRandomIntInclusive = exports.mixin = void 0;
exports.getLevel = exports.setLevel = exports.logger = exports.nowTimestamp = exports.hexStringToBN = exports.hexStringToBuffer = exports.ignoreError = exports.getRandomIntInclusive = exports.mixin = void 0;
const ethereumjs_util_1 = require("ethereumjs-util");
const tracer_1 = __importDefault(require("tracer"));
const functionalmap_1 = require("./functionalmap");
const functionalset_1 = require("./functionalset");
/**

@@ -69,2 +67,11 @@ * This function implements multiple inheritance

/**
* Run function and ignore all errors
* @param fn - Function
* @returns Funtion result or undefined(if something goes wrong)
*/
function ignoreError(p) {
return p && p.catch((err) => { });
}
exports.ignoreError = ignoreError;
/**
* Convert hex string to buffer

@@ -75,3 +82,3 @@ * @param hex - Hex string to be converted

function hexStringToBuffer(hex) {
return hex.indexOf('0x') === 0 ? Buffer.from(hex.substr(2), 'hex') : Buffer.from(hex, 'hex');
return hex.startsWith('0x') ? Buffer.from(hex.substr(2), 'hex') : Buffer.from(hex, 'hex');
}

@@ -85,40 +92,6 @@ exports.hexStringToBuffer = hexStringToBuffer;

function hexStringToBN(hex) {
return hex.indexOf('0x') === 0 ? new ethereumjs_util_1.BN(hex.substr(2), 'hex') : new ethereumjs_util_1.BN(hex, 'hex');
return hex.startsWith('0x') ? new ethereumjs_util_1.BN(hex.substr(2), 'hex') : new ethereumjs_util_1.BN(hex, 'hex');
}
exports.hexStringToBN = hexStringToBN;
const bufferCompare = (a, b) => a.compare(b);
const bnCompare = (a, b) => a.cmp(b);
/**
* Create a functional map which has `Buffer` key
* @returns Functional map object
*/
function createBufferFunctionalMap() {
return new functionalmap_1.FunctionalMap(bufferCompare);
}
exports.createBufferFunctionalMap = createBufferFunctionalMap;
/**
* Create a functional map which has `BN` key
* @returns Functional map object
*/
function createBNFunctionalMap() {
return new functionalmap_1.FunctionalMap(bnCompare);
}
exports.createBNFunctionalMap = createBNFunctionalMap;
/**
* Create a functional set which has `Buffer` key
* @returns Functional set object
*/
function createBufferFunctionalSet() {
return new functionalset_1.FunctionalSet(bufferCompare);
}
exports.createBufferFunctionalSet = createBufferFunctionalSet;
/**
* Create a functional set which has `BN` key
* @returns Functional set object
*/
function createBNFunctionalSet() {
return new functionalset_1.FunctionalSet(bnCompare);
}
exports.createBNFunctionalSet = createBNFunctionalSet;
/**
* Get current timestamp

@@ -145,5 +118,7 @@ */

Object.defineProperty(exports, "setLevel", { enumerable: true, get: function () { return tracer_2.setLevel; } });
Object.defineProperty(exports, "getLevel", { enumerable: true, get: function () { return tracer_2.getLevel; } });
__exportStar(require("./abort"), exports);
__exportStar(require("./channel"), exports);
__exportStar(require("./compress"), exports);
__exportStar(require("./initializer"), exports);
__exportStar(require("./functionalmap"), exports);

@@ -150,0 +125,0 @@ __exportStar(require("./functionalset"), exports);

{
"name": "@rei-network/utils",
"version": "0.0.1",
"version": "0.0.2",
"main": "dist/index.js",

@@ -5,0 +5,0 @@ "types": "dist/index.d.ts",

import createRBTree from 'functional-red-black-tree';
import { BN, Address } from 'ethereumjs-util';

@@ -135,1 +136,19 @@ export class FunctionalMapIterator<T> implements IterableIterator<T> {

}
export class FunctionalBufferMap<V> extends FunctionalMap<Buffer, V> {
constructor() {
super((a, b) => a.compare(b));
}
}
export class FunctionalBNMap<V> extends FunctionalMap<BN, V> {
constructor() {
super((a, b) => a.cmp(b));
}
}
export class FunctionalAddressMap<V> extends FunctionalMap<Address, V> {
constructor() {
super((a, b) => a.buf.compare(b.buf));
}
}
import createRBTree from 'functional-red-black-tree';
import { BN, Address } from 'ethereumjs-util';
import { FunctionalMapIterator } from './functionalmap';

@@ -81,1 +82,19 @@

}
export class FunctionalBufferSet extends FunctionalSet<Buffer> {
constructor() {
super((a, b) => a.compare(b));
}
}
export class FunctionalBNSet extends FunctionalSet<BN> {
constructor() {
super((a, b) => a.cmp(b));
}
}
export class FunctionalAddressSet extends FunctionalSet<Address> {
constructor() {
super((a, b) => a.buf.compare(b.buf));
}
}
import { BN } from 'ethereumjs-util';
import tracer from 'tracer';
import { FunctionalMap } from './functionalmap';
import { FunctionalSet } from './functionalset';

@@ -56,2 +54,11 @@ interface Constructor<T = {}> {

/**
* Run function and ignore all errors
* @param fn - Function
* @returns Funtion result or undefined(if something goes wrong)
*/
export function ignoreError<T>(p?: Promise<T>): Promise<void | T> | undefined {
return p && p.catch((err) => {});
}
/**
* Convert hex string to buffer

@@ -62,3 +69,3 @@ * @param hex - Hex string to be converted

export function hexStringToBuffer(hex: string): Buffer {
return hex.indexOf('0x') === 0 ? Buffer.from(hex.substr(2), 'hex') : Buffer.from(hex, 'hex');
return hex.startsWith('0x') ? Buffer.from(hex.substr(2), 'hex') : Buffer.from(hex, 'hex');
}

@@ -72,42 +79,6 @@

export function hexStringToBN(hex: string): BN {
return hex.indexOf('0x') === 0 ? new BN(hex.substr(2), 'hex') : new BN(hex, 'hex');
return hex.startsWith('0x') ? new BN(hex.substr(2), 'hex') : new BN(hex, 'hex');
}
const bufferCompare = (a: Buffer, b: Buffer) => a.compare(b);
const bnCompare = (a: BN, b: BN) => a.cmp(b);
/**
* Create a functional map which has `Buffer` key
* @returns Functional map object
*/
export function createBufferFunctionalMap<T>() {
return new FunctionalMap<Buffer, T>(bufferCompare);
}
/**
* Create a functional map which has `BN` key
* @returns Functional map object
*/
export function createBNFunctionalMap<T>() {
return new FunctionalMap<BN, T>(bnCompare);
}
/**
* Create a functional set which has `Buffer` key
* @returns Functional set object
*/
export function createBufferFunctionalSet() {
return new FunctionalSet<Buffer>(bufferCompare);
}
/**
* Create a functional set which has `BN` key
* @returns Functional set object
*/
export function createBNFunctionalSet() {
return new FunctionalSet<BN>(bnCompare);
}
/**
* Get current timestamp

@@ -133,3 +104,3 @@ */

export { setLevel } from 'tracer';
export { setLevel, getLevel } from 'tracer';

@@ -139,4 +110,5 @@ export * from './abort';

export * from './compress';
export * from './initializer';
export * from './functionalmap';
export * from './functionalset';
export * from './timeoutQueue';

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc