Socket
Socket
Sign inDemoInstall

@polkadot/util

Package Overview
Dependencies
9
Maintainers
2
Versions
1405
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 12.3.2 to 12.4.1

4

bi/toBigInt.d.ts
/// <reference types="bn.js" />
import type { BN } from '../bn/bn.js';
import type { HexString, ToBigInt, ToBn } from '../types.js';
import type { ToBigInt, ToBn } from '../types.js';
/**

@@ -8,2 +8,2 @@ * @name nToBigInt

*/
export declare function nToBigInt<ExtToBn extends ToBigInt | ToBn>(value?: HexString | ExtToBn | BN | bigint | string | number | null): bigint;
export declare function nToBigInt<ExtToBn extends ToBigInt | ToBn>(value?: ExtToBn | BN | bigint | string | number | null): bigint;
/// <reference types="bn.js" />
import type { HexString, ToBigInt, ToBn } from '../types.js';
import type { ToBigInt, ToBn } from '../types.js';
import { BN } from './bn.js';

@@ -20,2 +20,2 @@ /**

*/
export declare function bnToBn<ExtToBn extends ToBigInt | ToBn>(value?: HexString | ExtToBn | BN | bigint | string | number | null): BN;
export declare function bnToBn<ExtToBn extends ToBigInt | ToBn>(value?: ExtToBn | BN | bigint | string | number | null): BN;

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

function formatElapsed(now, value) {
const tsNow = (now && now.getTime()) || 0;
const tsNow = now?.getTime() || 0;
const tsValue = value instanceof Date

@@ -26,0 +26,0 @@ ? value.getTime()

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

const instanceId = getInstanceId();
if (cache[instanceId] && cache[instanceId][stringParams] !== undefined) {
if (cache[instanceId]?.[stringParams] !== undefined) {
delete cache[instanceId][stringParams];

@@ -31,0 +31,0 @@ }

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.packageInfo = void 0;
exports.packageInfo = { name: '@polkadot/util', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '12.3.2' };
exports.packageInfo = { name: '@polkadot/util', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '12.4.1' };
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.u8aToBuffer = void 0;
const x_global_1 = require("@polkadot/x-global");
/**

@@ -15,8 +16,8 @@ * @name u8aToBuffer

*
* console.log('Buffer', u8aToBuffer('0x123480001f'));
* console.log('Buffer', u8aToBuffer(new Uint8Array([1, 2, 3])));
* ```
*/
function u8aToBuffer(value) {
return Buffer.from(value || []);
return x_global_1.xglobal.Buffer.from(value || []);
}
exports.u8aToBuffer = u8aToBuffer;

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

: '';
if (!value || !value.length) {
if (!value?.length) {
return empty;

@@ -49,0 +49,0 @@ }

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

const length = Math.ceil(bitLength / 8);
return `${isPrefixed ? '0x' : ''}${!value || !value.length
return `${isPrefixed ? '0x' : ''}${!value?.length
? ''

@@ -23,0 +23,0 @@ : (bitLength > 0 && value.length > length)

@@ -38,7 +38,9 @@ "use strict";

* @name u8aWrapBytes
* @description Adds a <Bytes>...</Bytes> wrapper to the supplied value (if not already existing)
* @description
* Adds a <Bytes>...</Bytes> wrapper to the supplied value, if
* - We don't already have a Bytes wrapper
* - The message is not an Ethereum-style message
*/
function u8aWrapBytes(bytes) {
const u8a = (0, toU8a_js_1.u8aToU8a)(bytes);
// if Ethereum-wrapping, we don't add our wrapping bytes
return u8aIsWrapped(u8a, true)

@@ -45,0 +47,0 @@ ? u8a

@@ -20,3 +20,3 @@ import { bnToBn } from '../bn/toBn.js';

export function formatElapsed(now, value) {
const tsNow = (now && now.getTime()) || 0;
const tsNow = now?.getTime() || 0;
const tsValue = value instanceof Date

@@ -23,0 +23,0 @@ ? value.getTime()

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

import type { HexString } from '../types.js';
/**

@@ -17,2 +16,2 @@ * @name hexToU8a

*/
export declare function hexToU8a(value?: HexString | string | null, bitLength?: number): Uint8Array;
export declare function hexToU8a(value?: string | null, bitLength?: number): Uint8Array;

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

import type { HexString } from '../types.js';
/**

@@ -17,2 +16,2 @@ * @name hexToU8a

*/
export declare function hexToU8a(_value?: HexString | string | null, bitLength?: number): Uint8Array;
export declare function hexToU8a(_value?: string | null, bitLength?: number): Uint8Array;

@@ -5,2 +5,2 @@ /**

*/
export declare function isArray<T>(value?: unknown): value is Array<T>;
export declare function isArray<T>(value?: unknown): value is T[];

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

/// <reference types="node" resolution-mode="require"/>
import type { BufferObject } from '../types.js';
/**

@@ -16,2 +16,2 @@ * @name isBuffer

*/
export declare function isBuffer(value: unknown): value is Buffer;
export declare function isBuffer<T = BufferObject>(value: unknown): value is T;

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

interface ObjectIndexed {
[index: string]: any;
}
type ObjectIndexed = Record<string, any>;
/**

@@ -5,0 +3,0 @@ * @name isJsonObject

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

interface ObjectIndexed {
[index: string]: any;
}
type ObjectIndexed = Record<string, any>;
/**

@@ -5,0 +3,0 @@ * @name isObject

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

import type { HexString } from '../types.js';
/**

@@ -8,2 +7,2 @@ * @name isUtf8

*/
export declare function isUtf8(value?: HexString | number[] | Uint8Array | string | null): boolean;
export declare function isUtf8(value?: number[] | Uint8Array | string | null): boolean;

@@ -25,3 +25,3 @@ import { stringify } from './stringify.js';

const instanceId = getInstanceId();
if (cache[instanceId] && cache[instanceId][stringParams] !== undefined) {
if (cache[instanceId]?.[stringParams] !== undefined) {
delete cache[instanceId][stringParams];

@@ -28,0 +28,0 @@ }

@@ -21,3 +21,3 @@ {

"type": "module",
"version": "12.3.2",
"version": "12.4.1",
"main": "./cjs/index.js",

@@ -877,10 +877,10 @@ "module": "./index.js",

"dependencies": {
"@polkadot/x-bigint": "12.3.2",
"@polkadot/x-global": "12.3.2",
"@polkadot/x-textdecoder": "12.3.2",
"@polkadot/x-textencoder": "12.3.2",
"@polkadot/x-bigint": "12.4.1",
"@polkadot/x-global": "12.4.1",
"@polkadot/x-textdecoder": "12.4.1",
"@polkadot/x-textencoder": "12.4.1",
"@types/bn.js": "^5.1.1",
"bn.js": "^5.2.1",
"tslib": "^2.5.3"
"tslib": "^2.6.1"
}
}

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

export const packageInfo = { name: '@polkadot/util', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '12.3.2' };
export const packageInfo = { name: '@polkadot/util', path: (import.meta && import.meta.url) ? new URL(import.meta.url).pathname.substring(0, new URL(import.meta.url).pathname.lastIndexOf('/') + 1) : 'auto', type: 'esm', version: '12.4.1' };

@@ -57,12 +57,13 @@ /// <reference types="bn.js" />

export type HexString = `0x${string}`;
export interface BufferObj extends Uint8Array {
export interface BufferObject extends Uint8Array {
equals: (otherBuffer: Uint8Array) => boolean;
readDoubleLE: (offset?: number) => number;
}
export interface BufferObjClass extends Class<BufferObj> {
export interface BufferClass extends Class<BufferObject> {
from: <T = BufferObject>(value: unknown) => T;
isBuffer: (value: unknown) => boolean;
}
export type U8aLike = HexString | number[] | Uint8Array | AnyString;
export type U8aLike = number[] | Uint8Array | AnyString;
export interface Observable {
next: (...params: unknown[]) => unknown;
}

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

import type { HexString } from '../types.js';
/**

@@ -18,2 +17,2 @@ * @name u8aCmp

*/
export declare function u8aCmp(a: HexString | Uint8Array | string, b: HexString | Uint8Array | string): number;
export declare function u8aCmp(a: string | Uint8Array, b: string | Uint8Array): number;

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

import type { HexString } from '../types.js';
/**

@@ -16,2 +15,2 @@ * @name u8aEq

*/
export declare function u8aEq(a: HexString | Uint8Array | string, b: HexString | Uint8Array | string): boolean;
export declare function u8aEq(a: string | Uint8Array, b: string | Uint8Array): boolean;

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

/// <reference types="node" resolution-mode="require"/>
import type { BufferObject } from '../types.js';
/**

@@ -13,5 +13,5 @@ * @name u8aToBuffer

*
* console.log('Buffer', u8aToBuffer('0x123480001f'));
* console.log('Buffer', u8aToBuffer(new Uint8Array([1, 2, 3])));
* ```
*/
export declare function u8aToBuffer(value?: Uint8Array | null): Buffer;
export declare function u8aToBuffer<T = BufferObject>(value?: Uint8Array | null): T;

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

import { xglobal } from '@polkadot/x-global';
/**

@@ -12,7 +13,7 @@ * @name u8aToBuffer

*
* console.log('Buffer', u8aToBuffer('0x123480001f'));
* console.log('Buffer', u8aToBuffer(new Uint8Array([1, 2, 3])));
* ```
*/
export function u8aToBuffer(value) {
return Buffer.from(value || []);
return xglobal.Buffer.from(value || []);
}

@@ -43,3 +43,3 @@ const U8 = new Array(256);

: '';
if (!value || !value.length) {
if (!value?.length) {
return empty;

@@ -46,0 +46,0 @@ }

@@ -17,3 +17,3 @@ /**

const length = Math.ceil(bitLength / 8);
return `${isPrefixed ? '0x' : ''}${!value || !value.length
return `${isPrefixed ? '0x' : ''}${!value?.length
? ''

@@ -20,0 +20,0 @@ : (bitLength > 0 && value.length > length)

@@ -17,4 +17,7 @@ import type { U8aLike } from '../types.js';

* @name u8aWrapBytes
* @description Adds a <Bytes>...</Bytes> wrapper to the supplied value (if not already existing)
* @description
* Adds a <Bytes>...</Bytes> wrapper to the supplied value, if
* - We don't already have a Bytes wrapper
* - The message is not an Ethereum-style message
*/
export declare function u8aWrapBytes(bytes: U8aLike): Uint8Array;

@@ -33,7 +33,9 @@ import { u8aConcatStrict } from './concat.js';

* @name u8aWrapBytes
* @description Adds a <Bytes>...</Bytes> wrapper to the supplied value (if not already existing)
* @description
* Adds a <Bytes>...</Bytes> wrapper to the supplied value, if
* - We don't already have a Bytes wrapper
* - The message is not an Ethereum-style message
*/
export function u8aWrapBytes(bytes) {
const u8a = u8aToU8a(bytes);
// if Ethereum-wrapping, we don't add our wrapping bytes
return u8aIsWrapped(u8a, true)

@@ -40,0 +42,0 @@ ? u8a

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

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