@polkadot/util
Advanced tools
Comparing version 12.2.1 to 12.2.2
@@ -16,7 +16,8 @@ /** | ||
export function arrayFlatten(arrays) { | ||
const num = arrays.length; | ||
// shortcuts for the empty & single-entry case | ||
if (arrays.length === 0) { | ||
if (num === 0) { | ||
return []; | ||
} | ||
else if (arrays.length === 1) { | ||
else if (num === 1) { | ||
return arrays[0]; | ||
@@ -26,3 +27,3 @@ } | ||
let size = 0; | ||
for (let i = 0; i < arrays.length; i++) { | ||
for (let i = 0; i < num; i++) { | ||
size += arrays[i].length; | ||
@@ -32,6 +33,6 @@ } | ||
let i = -1; | ||
for (let j = 0; j < arrays.length; j++) { | ||
for (let j = 0; j < num; j++) { | ||
const a = arrays[j]; | ||
// instead of pushing, we just set the entries | ||
for (let e = 0; e < a.length; e++) { | ||
for (let e = 0, count = a.length; e < count; e++) { | ||
output[++i] = a[e]; | ||
@@ -38,0 +39,0 @@ } |
/** @internal */ | ||
export function createCmp(cmp) { | ||
return (...items) => { | ||
if (items.length === 0) { | ||
const count = items.length; | ||
if (count === 0) { | ||
throw new Error('Must provide one or more arguments'); | ||
} | ||
let result = items[0]; | ||
for (let i = 1; i < items.length; i++) { | ||
for (let i = 1; i < count; i++) { | ||
if (cmp(items[i], result)) { | ||
@@ -10,0 +11,0 @@ result = items[i]; |
@@ -19,7 +19,8 @@ "use strict"; | ||
function arrayFlatten(arrays) { | ||
const num = arrays.length; | ||
// shortcuts for the empty & single-entry case | ||
if (arrays.length === 0) { | ||
if (num === 0) { | ||
return []; | ||
} | ||
else if (arrays.length === 1) { | ||
else if (num === 1) { | ||
return arrays[0]; | ||
@@ -29,3 +30,3 @@ } | ||
let size = 0; | ||
for (let i = 0; i < arrays.length; i++) { | ||
for (let i = 0; i < num; i++) { | ||
size += arrays[i].length; | ||
@@ -35,6 +36,6 @@ } | ||
let i = -1; | ||
for (let j = 0; j < arrays.length; j++) { | ||
for (let j = 0; j < num; j++) { | ||
const a = arrays[j]; | ||
// instead of pushing, we just set the entries | ||
for (let e = 0; e < a.length; e++) { | ||
for (let e = 0, count = a.length; e < count; e++) { | ||
output[++i] = a[e]; | ||
@@ -41,0 +42,0 @@ } |
@@ -7,7 +7,8 @@ "use strict"; | ||
return (...items) => { | ||
if (items.length === 0) { | ||
const count = items.length; | ||
if (count === 0) { | ||
throw new Error('Must provide one or more arguments'); | ||
} | ||
let result = items[0]; | ||
for (let i = 1; i < items.length; i++) { | ||
for (let i = 1; i < count; i++) { | ||
if (cmp(items[i], result)) { | ||
@@ -14,0 +15,0 @@ result = items[i]; |
@@ -29,3 +29,3 @@ "use strict"; | ||
// use a loop here, better RN support (which doesn't have [].find) | ||
for (let i = 0; i < exports.SI.length; i++) { | ||
for (let i = 0, count = exports.SI.length; i < count; i++) { | ||
if (exports.SI[i].value === type) { | ||
@@ -32,0 +32,0 @@ return exports.SI[i]; |
@@ -7,3 +7,3 @@ "use strict"; | ||
const U16 = new Uint8Array(256 * 256); | ||
for (let i = 0; i < CHR.length; i++) { | ||
for (let i = 0, count = CHR.length; i < count; i++) { | ||
U8[CHR[i].charCodeAt(0) | 0] = i | 0; | ||
@@ -10,0 +10,0 @@ if (i > 9) { |
@@ -9,4 +9,3 @@ "use strict"; | ||
function isAsciiStr(str) { | ||
const count = str.length | 0; | ||
for (let i = 0; i < count; i++) { | ||
for (let i = 0, count = str.length; i < count; i++) { | ||
const b = str.charCodeAt(i); | ||
@@ -22,4 +21,3 @@ // check is inlined here, it is faster than making a call | ||
function isAsciiBytes(u8a) { | ||
const count = u8a.length | 0; | ||
for (let i = 0; i < count; i++) { | ||
for (let i = 0, count = u8a.length; i < count; i++) { | ||
const b = u8a[i] | 0; | ||
@@ -26,0 +24,0 @@ // check is inlined here, it is faster than making a call |
@@ -51,3 +51,3 @@ "use strict"; | ||
function lazyMethods(result, items, creator, getName) { | ||
for (let i = 0; i < items.length; i++) { | ||
for (let i = 0, count = items.length; i < count; i++) { | ||
lazyMethod(result, items[i], creator, getName, i); | ||
@@ -54,0 +54,0 @@ } |
@@ -10,3 +10,3 @@ "use strict"; | ||
const keys = Object.keys(value); | ||
for (let i = 0; i < keys.length; i++) { | ||
for (let i = 0, count = keys.length; i < count; i++) { | ||
delete value[keys[i]]; | ||
@@ -13,0 +13,0 @@ } |
@@ -35,3 +35,3 @@ "use strict"; | ||
function objectProperties(that, keys, getter, getName) { | ||
for (let i = 0; i < keys.length; i++) { | ||
for (let i = 0, count = keys.length; i < count; i++) { | ||
objectProperty(that, keys[i], getter, getName, i); | ||
@@ -38,0 +38,0 @@ } |
@@ -9,3 +9,3 @@ "use strict"; | ||
function objectSpread(dest, ...sources) { | ||
for (let i = 0; i < sources.length; i++) { | ||
for (let i = 0, count = sources.length; i < count; i++) { | ||
const src = sources[i]; | ||
@@ -12,0 +12,0 @@ if (src) { |
"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.2.1' }; | ||
exports.packageInfo = { name: '@polkadot/util', path: typeof __dirname === 'string' ? __dirname : 'auto', type: 'cjs', version: '12.2.2' }; |
@@ -6,3 +6,3 @@ "use strict"; | ||
exports.CC_TO_LO = new Array(256); | ||
for (let i = 0; i < exports.CC_TO_UP.length; i++) { | ||
for (let i = 0, count = exports.CC_TO_UP.length; i < count; i++) { | ||
exports.CC_TO_LO[i] = String.fromCharCode(i).toLowerCase(); | ||
@@ -38,5 +38,4 @@ exports.CC_TO_UP[i] = String.fromCharCode(i).toUpperCase(); | ||
.split(' '); | ||
const count = parts.length; | ||
let result = ''; | ||
for (let i = 0; i < count; i++) { | ||
for (let i = 0, count = parts.length; i < count; i++) { | ||
const w = parts[i]; | ||
@@ -43,0 +42,0 @@ // apply the formatting |
@@ -38,5 +38,6 @@ "use strict"; | ||
function u8aConcatStrict(u8as, length = 0) { | ||
const count = u8as.length; | ||
let offset = 0; | ||
if (!length) { | ||
for (let i = 0; i < u8as.length; i++) { | ||
for (let i = 0; i < count; i++) { | ||
length += u8as[i].length; | ||
@@ -46,3 +47,3 @@ } | ||
const result = new Uint8Array(length); | ||
for (let i = 0; i < u8as.length; i++) { | ||
for (let i = 0; i < count; i++) { | ||
result.set(u8as[i], offset); | ||
@@ -49,0 +50,0 @@ offset += u8as[i].length; |
@@ -32,3 +32,3 @@ "use strict"; | ||
} | ||
for (let i = length; i < u8aa.length; i++) { | ||
for (let i = length, count = u8aa.length; i < count; i++) { | ||
if (u8aa[i] !== u8ab[i]) { | ||
@@ -35,0 +35,0 @@ return false; |
@@ -1,2 +0,1 @@ | ||
type AnyFloat = number | Number; | ||
interface Options { | ||
@@ -11,3 +10,3 @@ bitLength?: 32 | 64; | ||
*/ | ||
export declare function floatToU8a(value?: string | AnyFloat, { bitLength, isLe }?: Options): Uint8Array; | ||
export declare function floatToU8a(value?: String | string | number | Number, { bitLength, isLe }?: Options): Uint8Array; | ||
export {}; |
@@ -26,3 +26,3 @@ /** @internal */ | ||
// use a loop here, better RN support (which doesn't have [].find) | ||
for (let i = 0; i < SI.length; i++) { | ||
for (let i = 0, count = SI.length; i < count; i++) { | ||
if (SI[i].value === type) { | ||
@@ -29,0 +29,0 @@ return SI[i]; |
const CHR = '0123456789abcdef'; | ||
const U8 = new Uint8Array(256); | ||
const U16 = new Uint8Array(256 * 256); | ||
for (let i = 0; i < CHR.length; i++) { | ||
for (let i = 0, count = CHR.length; i < count; i++) { | ||
U8[CHR[i].charCodeAt(0) | 0] = i | 0; | ||
@@ -6,0 +6,0 @@ if (i > 9) { |
@@ -6,4 +6,3 @@ import { u8aToU8a } from '../u8a/toU8a.js'; | ||
function isAsciiStr(str) { | ||
const count = str.length | 0; | ||
for (let i = 0; i < count; i++) { | ||
for (let i = 0, count = str.length; i < count; i++) { | ||
const b = str.charCodeAt(i); | ||
@@ -19,4 +18,3 @@ // check is inlined here, it is faster than making a call | ||
function isAsciiBytes(u8a) { | ||
const count = u8a.length | 0; | ||
for (let i = 0; i < count; i++) { | ||
for (let i = 0, count = u8a.length; i < count; i++) { | ||
const b = u8a[i] | 0; | ||
@@ -23,0 +21,0 @@ // check is inlined here, it is faster than making a call |
@@ -47,3 +47,3 @@ /** | ||
export function lazyMethods(result, items, creator, getName) { | ||
for (let i = 0; i < items.length; i++) { | ||
for (let i = 0, count = items.length; i < count; i++) { | ||
lazyMethod(result, items[i], creator, getName, i); | ||
@@ -50,0 +50,0 @@ } |
@@ -7,3 +7,3 @@ /** | ||
const keys = Object.keys(value); | ||
for (let i = 0; i < keys.length; i++) { | ||
for (let i = 0, count = keys.length; i < count; i++) { | ||
delete value[keys[i]]; | ||
@@ -10,0 +10,0 @@ } |
@@ -31,5 +31,5 @@ /** | ||
export function objectProperties(that, keys, getter, getName) { | ||
for (let i = 0; i < keys.length; i++) { | ||
for (let i = 0, count = keys.length; i < count; i++) { | ||
objectProperty(that, keys[i], getter, getName, i); | ||
} | ||
} |
@@ -6,3 +6,3 @@ /** | ||
export function objectSpread(dest, ...sources) { | ||
for (let i = 0; i < sources.length; i++) { | ||
for (let i = 0, count = sources.length; i < count; i++) { | ||
const src = sources[i]; | ||
@@ -9,0 +9,0 @@ if (src) { |
@@ -21,3 +21,3 @@ { | ||
"type": "module", | ||
"version": "12.2.1", | ||
"version": "12.2.2", | ||
"main": "./cjs/index.js", | ||
@@ -877,10 +877,10 @@ "module": "./index.js", | ||
"dependencies": { | ||
"@polkadot/x-bigint": "12.2.1", | ||
"@polkadot/x-global": "12.2.1", | ||
"@polkadot/x-textdecoder": "12.2.1", | ||
"@polkadot/x-textencoder": "12.2.1", | ||
"@polkadot/x-bigint": "12.2.2", | ||
"@polkadot/x-global": "12.2.2", | ||
"@polkadot/x-textdecoder": "12.2.2", | ||
"@polkadot/x-textencoder": "12.2.2", | ||
"@types/bn.js": "^5.1.1", | ||
"bn.js": "^5.2.1", | ||
"tslib": "^2.5.0" | ||
"tslib": "^2.5.3" | ||
} | ||
} |
@@ -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.2.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.2.2' }; |
@@ -16,2 +16,2 @@ /** | ||
*/ | ||
export declare function promisify<R = any>(self: unknown, fn: (...params: any) => any, ...params: any[]): Promise<R>; | ||
export declare function promisify<R = any>(self: unknown, fn: (...params: any[]) => any, ...params: any[]): Promise<R>; |
export const CC_TO_UP = new Array(256); | ||
export const CC_TO_LO = new Array(256); | ||
for (let i = 0; i < CC_TO_UP.length; i++) { | ||
for (let i = 0, count = CC_TO_UP.length; i < count; i++) { | ||
CC_TO_LO[i] = String.fromCharCode(i).toLowerCase(); | ||
@@ -34,5 +34,4 @@ CC_TO_UP[i] = String.fromCharCode(i).toUpperCase(); | ||
.split(' '); | ||
const count = parts.length; | ||
let result = ''; | ||
for (let i = 0; i < count; i++) { | ||
for (let i = 0, count = parts.length; i < count; i++) { | ||
const w = parts[i]; | ||
@@ -39,0 +38,0 @@ // apply the formatting |
@@ -57,4 +57,4 @@ /// <reference types="bn.js" /> | ||
export interface BufferObj extends Uint8Array { | ||
equals(otherBuffer: Uint8Array): boolean; | ||
readDoubleLE(offset?: number): number; | ||
equals: (otherBuffer: Uint8Array) => boolean; | ||
readDoubleLE: (offset?: number) => number; | ||
} | ||
@@ -61,0 +61,0 @@ export interface BufferObjConstructor extends Constructor<BufferObj> { |
@@ -34,5 +34,6 @@ import { u8aToU8a } from './toU8a.js'; | ||
export function u8aConcatStrict(u8as, length = 0) { | ||
const count = u8as.length; | ||
let offset = 0; | ||
if (!length) { | ||
for (let i = 0; i < u8as.length; i++) { | ||
for (let i = 0; i < count; i++) { | ||
length += u8as[i].length; | ||
@@ -42,3 +43,3 @@ } | ||
const result = new Uint8Array(length); | ||
for (let i = 0; i < u8as.length; i++) { | ||
for (let i = 0; i < count; i++) { | ||
result.set(u8as[i], offset); | ||
@@ -45,0 +46,0 @@ offset += u8as[i].length; |
@@ -29,3 +29,3 @@ import { u8aToU8a } from './toU8a.js'; | ||
} | ||
for (let i = length; i < u8aa.length; i++) { | ||
for (let i = length, count = u8aa.length; i < count; i++) { | ||
if (u8aa[i] !== u8ab[i]) { | ||
@@ -32,0 +32,0 @@ return false; |
Sorry, the diff of this file is too big to display
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
544678
+ Added@polkadot/x-bigint@12.2.2(transitive)
+ Added@polkadot/x-global@12.2.2(transitive)
+ Added@polkadot/x-textdecoder@12.2.2(transitive)
+ Added@polkadot/x-textencoder@12.2.2(transitive)
- Removed@polkadot/x-bigint@12.2.1(transitive)
- Removed@polkadot/x-global@12.2.1(transitive)
- Removed@polkadot/x-textdecoder@12.2.1(transitive)
- Removed@polkadot/x-textencoder@12.2.1(transitive)
Updated@polkadot/x-bigint@12.2.2
Updated@polkadot/x-global@12.2.2
Updatedtslib@^2.5.3