Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
611b1be481 | ||
|
|
73b35fc188 | ||
|
|
6c30d5b9fd | ||
|
|
56d151fe66 | ||
|
|
cd20fe6c8b | ||
|
|
28f8ca73aa | ||
|
|
f4a8bfc0c0 | ||
|
|
94b058d6a3 | ||
|
|
3d7ddb85a2 | ||
|
|
f7a2bb895f | ||
|
|
c1bfcc00b6 | ||
|
|
b16d8e7c26 | ||
|
|
2a4b363fcd | ||
|
|
de689b8e6f | ||
|
|
2e72ab920b | ||
|
|
565e6baecd | ||
|
|
1e15203b6c |
@@ -1,5 +1,15 @@
|
|||||||
# CHANGELOG
|
# CHANGELOG
|
||||||
|
|
||||||
|
## 2.14.1 Jun 16, 2020
|
||||||
|
|
||||||
|
- Add `extractTime` utility conversion (Thanks to https://github.com/kwingram25)
|
||||||
|
|
||||||
|
## 2.13.1 Jun 8, 2020
|
||||||
|
|
||||||
|
- Fix JS blake2 fallback (non-wasm) to correctly deal with hex inputs
|
||||||
|
- Align `bnToHex` signature with `bnToU8a` (with old/new style)
|
||||||
|
- Allow `bnTo{Hex,U8a}` to take any value with `.toBn()` signatures
|
||||||
|
|
||||||
## 2.12.2 Jun 1, 2020
|
## 2.12.2 Jun 1, 2020
|
||||||
|
|
||||||
- Fix `isFunction` signature to assert `Function`
|
- Fix `isFunction` signature to assert `Function`
|
||||||
|
|||||||
+1
-1
@@ -9,5 +9,5 @@
|
|||||||
"packages": [
|
"packages": [
|
||||||
"packages/*"
|
"packages/*"
|
||||||
],
|
],
|
||||||
"version": "2.12.2"
|
"version": "2.14.1"
|
||||||
}
|
}
|
||||||
|
|||||||
+5
-5
@@ -21,10 +21,10 @@
|
|||||||
"test:one": "polkadot-dev-run-test"
|
"test:one": "polkadot-dev-run-test"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@babel/core": "^7.9.6",
|
"@babel/core": "^7.10.2",
|
||||||
"@polkadot/dev": "^0.55.6",
|
"@polkadot/dev": "^0.55.10",
|
||||||
"@polkadot/ts": "^0.3.25",
|
"@polkadot/ts": "^0.3.26",
|
||||||
"@types/jest": "^25.2.3"
|
"@types/jest": "^26.0.0"
|
||||||
},
|
},
|
||||||
"version": "2.12.2"
|
"version": "2.14.1"
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/keyring",
|
"name": "@polkadot/keyring",
|
||||||
"version": "2.12.2",
|
"version": "2.14.1",
|
||||||
"description": "Keyring management",
|
"description": "Keyring management",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
@@ -27,8 +27,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/keyring#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.9.6",
|
"@babel/runtime": "^7.10.2",
|
||||||
"@polkadot/util": "2.12.2",
|
"@polkadot/util": "2.14.1",
|
||||||
"@polkadot/util-crypto": "2.12.2"
|
"@polkadot/util-crypto": "2.14.1"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/util-crypto",
|
"name": "@polkadot/util-crypto",
|
||||||
"version": "2.12.2",
|
"version": "2.14.1",
|
||||||
"description": "A collection of useful crypto utilities for @polkadot",
|
"description": "A collection of useful crypto utilities for @polkadot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -25,8 +25,8 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
|
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util-crypto#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.9.6",
|
"@babel/runtime": "^7.10.2",
|
||||||
"@polkadot/util": "2.12.2",
|
"@polkadot/util": "2.14.1",
|
||||||
"@polkadot/wasm-crypto": "^1.2.1",
|
"@polkadot/wasm-crypto": "^1.2.1",
|
||||||
"base-x": "^3.0.8",
|
"base-x": "^3.0.8",
|
||||||
"bip39": "^3.0.2",
|
"bip39": "^3.0.2",
|
||||||
@@ -35,7 +35,7 @@
|
|||||||
"bs58": "^4.0.1",
|
"bs58": "^4.0.1",
|
||||||
"elliptic": "^6.5.2",
|
"elliptic": "^6.5.2",
|
||||||
"js-sha3": "^0.8.0",
|
"js-sha3": "^0.8.0",
|
||||||
"pbkdf2": "^3.0.17",
|
"pbkdf2": "^3.1.1",
|
||||||
"tweetnacl": "^1.0.3",
|
"tweetnacl": "^1.0.3",
|
||||||
"xxhashjs": "^0.2.2"
|
"xxhashjs": "^0.2.2"
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -43,4 +43,18 @@ describe('blake2AsU8a', (): void => {
|
|||||||
hexToU8a('0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923')
|
hexToU8a('0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923')
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('has equivalent Wasm/Js outputs on hex inputs', (): void => {
|
||||||
|
const a = blake2AsU8a('0x123456', 256, null, false);
|
||||||
|
const b = blake2AsU8a('0x123456', 256, null, true);
|
||||||
|
|
||||||
|
expect(a).toEqual(b);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('has equivalent Wasm/Js outputs with key inputs', (): void => {
|
||||||
|
const a = blake2AsU8a('0x123456', 256, new Uint8Array([1, 2]), false);
|
||||||
|
const b = blake2AsU8a('0x123456', 256, new Uint8Array([1, 2]), true);
|
||||||
|
|
||||||
|
expect(a).toEqual(b);
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -20,10 +20,10 @@ import { blake2b, isReady } from '@polkadot/wasm-crypto';
|
|||||||
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d]
|
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d]
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export default function blake2AsU8a (data: Uint8Array | string, bitLength = 256, key: Uint8Array | null = null): Uint8Array {
|
export default function blake2AsU8a (data: Uint8Array | string, bitLength = 256, key: Uint8Array | null = null, onlyJs = false): Uint8Array {
|
||||||
const byteLength = Math.ceil(bitLength / 8);
|
const byteLength = Math.ceil(bitLength / 8);
|
||||||
|
|
||||||
return isReady()
|
return isReady() && !onlyJs
|
||||||
? blake2b(u8aToU8a(data), u8aToU8a(key), byteLength)
|
? blake2b(u8aToU8a(data), u8aToU8a(key), byteLength)
|
||||||
: blakejs.blake2b(data, key, byteLength);
|
: blakejs.blake2b(u8aToU8a(data), key, byteLength);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "@polkadot/util",
|
"name": "@polkadot/util",
|
||||||
"version": "2.12.2",
|
"version": "2.14.1",
|
||||||
"description": "A collection of useful utilities for @polkadot",
|
"description": "A collection of useful utilities for @polkadot",
|
||||||
"main": "index.js",
|
"main": "index.js",
|
||||||
"keywords": [
|
"keywords": [
|
||||||
@@ -25,11 +25,11 @@
|
|||||||
},
|
},
|
||||||
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
"homepage": "https://github.com/polkadot-js/common/tree/master/packages/util#readme",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.9.6",
|
"@babel/runtime": "^7.10.2",
|
||||||
"@types/bn.js": "^4.11.6",
|
"@types/bn.js": "^4.11.6",
|
||||||
"bn.js": "^5.1.2",
|
"bn.js": "^5.1.2",
|
||||||
"camelcase": "^5.3.1",
|
"camelcase": "^5.3.1",
|
||||||
"chalk": "^4.0.0",
|
"chalk": "^4.1.0",
|
||||||
"ip-regex": "^4.1.0"
|
"ip-regex": "^4.1.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,38 @@
|
|||||||
|
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||||
|
// This software may be modified and distributed under the terms
|
||||||
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import { BN_ZERO, BN_ONE, BN_TEN, BN_HUNDRED, BN_THOUSAND } from '.';
|
||||||
|
import BN from 'bn.js';
|
||||||
|
|
||||||
|
describe('consts', (): void => {
|
||||||
|
it('BN_ZERO equals 0', (): void => {
|
||||||
|
expect(
|
||||||
|
BN_ZERO
|
||||||
|
).toEqual(new BN(0));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('BN_ONE equals 1', (): void => {
|
||||||
|
expect(
|
||||||
|
BN_ONE
|
||||||
|
).toEqual(new BN(1));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('BN_TEN equals 10', (): void => {
|
||||||
|
expect(
|
||||||
|
BN_TEN
|
||||||
|
).toEqual(new BN(10));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('BN_HUNDRED equals 100', (): void => {
|
||||||
|
expect(
|
||||||
|
BN_HUNDRED
|
||||||
|
).toEqual(new BN(100));
|
||||||
|
});
|
||||||
|
|
||||||
|
it('BN_THOUSAND equals 1000', (): void => {
|
||||||
|
expect(
|
||||||
|
BN_THOUSAND
|
||||||
|
).toEqual(new BN(1000));
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||||
|
// This software may be modified and distributed under the terms
|
||||||
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import BN from 'bn.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name BN_ZERO
|
||||||
|
* @summary BN constant for 0.
|
||||||
|
*/
|
||||||
|
const BN_ZERO: BN = new BN(0);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name BN_ONE
|
||||||
|
* @summary BN constant for 1.
|
||||||
|
*/
|
||||||
|
const BN_ONE: BN = new BN(1);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name BN_TEN
|
||||||
|
* @summary BN constant for 10.
|
||||||
|
*/
|
||||||
|
const BN_TEN: BN = new BN(10);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name BN_HUNDRED
|
||||||
|
* @summary BN constant for 100.
|
||||||
|
*/
|
||||||
|
const BN_HUNDRED: BN = new BN(100);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name BN_THOUSAND
|
||||||
|
* @summary BN constant for 1000.
|
||||||
|
*/
|
||||||
|
const BN_THOUSAND: BN = new BN(1000);
|
||||||
|
|
||||||
|
export {
|
||||||
|
BN_ZERO,
|
||||||
|
BN_ONE,
|
||||||
|
BN_TEN,
|
||||||
|
BN_HUNDRED,
|
||||||
|
BN_THOUSAND
|
||||||
|
};
|
||||||
@@ -6,6 +6,7 @@
|
|||||||
* @summary Utility methods to convert to and from `BN` objects
|
* @summary Utility methods to convert to and from `BN` objects
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
export * from './consts';
|
||||||
export { default as bnFromHex } from './fromHex';
|
export { default as bnFromHex } from './fromHex';
|
||||||
export { default as bnMax } from './max';
|
export { default as bnMax } from './max';
|
||||||
export { default as bnMin } from './min';
|
export { default as bnMin } from './min';
|
||||||
|
|||||||
@@ -25,6 +25,12 @@ describe('bnToHex', (): void => {
|
|||||||
).toBe('0x0080');
|
).toBe('0x0080');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('converts BN values to a prefixed hex representation (bitLength + le)', (): void => {
|
||||||
|
expect(
|
||||||
|
bnToHex(new BN(128), 16, true)
|
||||||
|
).toBe('0x8000');
|
||||||
|
});
|
||||||
|
|
||||||
it('converts BN values to a prefixed hex representation (LE)', (): void => {
|
it('converts BN values to a prefixed hex representation (LE)', (): void => {
|
||||||
expect(
|
expect(
|
||||||
bnToHex(new BN(128), { bitLength: 16, isLe: true })
|
bnToHex(new BN(128), { bitLength: 16, isLe: true })
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
// This software may be modified and distributed under the terms
|
// This software may be modified and distributed under the terms
|
||||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import { ToBn, ToBnOptions } from '../types';
|
||||||
|
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
|
|
||||||
import isNumber from '../is/number';
|
import isNumber from '../is/number';
|
||||||
import bnToU8a from './toU8a';
|
import bnToU8a from './toU8a';
|
||||||
import { ToBnOptions } from '../types';
|
|
||||||
import { u8aToHex } from '../u8a';
|
import { u8aToHex } from '../u8a';
|
||||||
|
|
||||||
const ZERO_STR = '0x00';
|
const ZERO_STR = '0x00';
|
||||||
@@ -30,7 +31,9 @@ interface Options extends ToBnOptions {
|
|||||||
* bnToHex(new BN(0x123456)); // => '0x123456'
|
* bnToHex(new BN(0x123456)); // => '0x123456'
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
export default function bnToHex (value?: BN | BigInt | number | null, options: number | Options = { bitLength: -1, isLe: false, isNegative: false }): string {
|
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, options?: Options): string;
|
||||||
|
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): string;
|
||||||
|
function bnToHex <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: false, isNegative: false }, arg2?: boolean): string {
|
||||||
if (!value) {
|
if (!value) {
|
||||||
return ZERO_STR;
|
return ZERO_STR;
|
||||||
}
|
}
|
||||||
@@ -39,8 +42,10 @@ export default function bnToHex (value?: BN | BigInt | number | null, options: n
|
|||||||
isLe: false,
|
isLe: false,
|
||||||
isNegative: false,
|
isNegative: false,
|
||||||
// Backwards-compatibility
|
// Backwards-compatibility
|
||||||
...(isNumber(options) ? { bitLength: options } : options)
|
...(isNumber(arg1) ? { bitLength: arg1, isLe: arg2 } : arg1)
|
||||||
};
|
};
|
||||||
|
|
||||||
return u8aToHex(bnToU8a(value, _options));
|
return u8aToHex(bnToU8a(value, _options));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export default bnToHex;
|
||||||
|
|||||||
@@ -2,11 +2,12 @@
|
|||||||
// This software may be modified and distributed under the terms
|
// This software may be modified and distributed under the terms
|
||||||
// of the Apache-2.0 license. See the LICENSE file for details.
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import { ToBn, ToBnOptions } from '../types';
|
||||||
|
|
||||||
import BN from 'bn.js';
|
import BN from 'bn.js';
|
||||||
|
|
||||||
import isNumber from '../is/number';
|
import isNumber from '../is/number';
|
||||||
import bnToBn from './toBn';
|
import bnToBn from './toBn';
|
||||||
import { ToBnOptions } from '../types';
|
|
||||||
|
|
||||||
interface Options extends ToBnOptions {
|
interface Options extends ToBnOptions {
|
||||||
bitLength?: number;
|
bitLength?: number;
|
||||||
@@ -26,9 +27,9 @@ interface Options extends ToBnOptions {
|
|||||||
* bnToU8a(new BN(0x1234)); // => [0x12, 0x34]
|
* bnToU8a(new BN(0x1234)); // => [0x12, 0x34]
|
||||||
* ```
|
* ```
|
||||||
*/
|
*/
|
||||||
function bnToU8a (value: BN | BigInt | number | null, options?: Options): Uint8Array;
|
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, options?: Options): Uint8Array;
|
||||||
function bnToU8a (value: BN | BigInt | number | null, bitLength?: number, isLe?: boolean): Uint8Array;
|
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, bitLength?: number, isLe?: boolean): Uint8Array;
|
||||||
function bnToU8a (value: BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array {
|
function bnToU8a <ExtToBn extends ToBn> (value?: ExtToBn | BN | BigInt | number | null, arg1: number | Options = { bitLength: -1, isLe: true, isNegative: false }, arg2?: boolean): Uint8Array {
|
||||||
const _options: Options = {
|
const _options: Options = {
|
||||||
bitLength: -1,
|
bitLength: -1,
|
||||||
isLe: true,
|
isLe: true,
|
||||||
|
|||||||
@@ -0,0 +1,20 @@
|
|||||||
|
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||||
|
// This software may be modified and distributed under the terms
|
||||||
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import { extractTime } from '.';
|
||||||
|
|
||||||
|
describe('extractTime', (): void => {
|
||||||
|
const milliseconds = 1e9 + 123;
|
||||||
|
|
||||||
|
it('extracts time components correctly', (): void => {
|
||||||
|
expect(extractTime(milliseconds))
|
||||||
|
.toEqual({
|
||||||
|
days: 11,
|
||||||
|
hours: 13,
|
||||||
|
milliseconds: 123,
|
||||||
|
minutes: 46,
|
||||||
|
seconds: 40
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
@@ -0,0 +1,73 @@
|
|||||||
|
// Copyright 2017-2020 @polkadot/util authors & contributors
|
||||||
|
// This software may be modified and distributed under the terms
|
||||||
|
// of the Apache-2.0 license. See the LICENSE file for details.
|
||||||
|
|
||||||
|
import { Time } from './types';
|
||||||
|
|
||||||
|
const HRS = 60 * 60;
|
||||||
|
const DAY = HRS * 24;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name addTime
|
||||||
|
* @summary Add together two Time arrays
|
||||||
|
*/
|
||||||
|
|
||||||
|
function addTime (a: Time, b: Time): Time {
|
||||||
|
return {
|
||||||
|
days: a.days + b.days,
|
||||||
|
hours: a.hours + b.hours,
|
||||||
|
milliseconds: a.milliseconds + b.milliseconds,
|
||||||
|
minutes: a.minutes + b.minutes,
|
||||||
|
seconds: a.seconds + b.seconds
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
const ZERO = { days: 0, hours: 0, milliseconds: 0, minutes: 0, seconds: 0 };
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @name extractTime
|
||||||
|
* @summary Convert a quantity of seconds to Time array representing accumulated {days, minutes, hours, seconds, milliseconds}
|
||||||
|
* @example
|
||||||
|
* <BR>
|
||||||
|
*
|
||||||
|
* ```javascript
|
||||||
|
* import { extractTime } from '@polkadot/util';
|
||||||
|
*
|
||||||
|
* const { days, minutes, hours, seconds, milliseconds } = extractTime(6000); // 0, 0, 10, 0, 0
|
||||||
|
* ```
|
||||||
|
*/
|
||||||
|
export default function extractTime (milliseconds?: number): Time {
|
||||||
|
if (!milliseconds) {
|
||||||
|
return ZERO;
|
||||||
|
} else if (milliseconds < 1000) {
|
||||||
|
return { ...ZERO, milliseconds };
|
||||||
|
}
|
||||||
|
|
||||||
|
const secs = milliseconds / 1000;
|
||||||
|
|
||||||
|
if (secs < 60) {
|
||||||
|
const seconds = Math.floor(secs);
|
||||||
|
|
||||||
|
return addTime({ ...ZERO, seconds }, extractTime(milliseconds - (seconds * 1000)));
|
||||||
|
}
|
||||||
|
|
||||||
|
const mins = secs / 60;
|
||||||
|
|
||||||
|
if (mins < 60) {
|
||||||
|
const minutes = Math.floor(mins);
|
||||||
|
|
||||||
|
return addTime({ ...ZERO, minutes }, extractTime(milliseconds - (minutes * 60 * 1000)));
|
||||||
|
}
|
||||||
|
|
||||||
|
const hrs = mins / 60;
|
||||||
|
|
||||||
|
if (hrs < 24) {
|
||||||
|
const hours = Math.floor(hrs);
|
||||||
|
|
||||||
|
return addTime({ ...ZERO, hours }, extractTime(milliseconds - (hours * HRS * 1000)));
|
||||||
|
}
|
||||||
|
|
||||||
|
const days = Math.floor(hrs / 24);
|
||||||
|
|
||||||
|
return addTime({ ...ZERO, days }, extractTime(milliseconds - (days * DAY * 1000)));
|
||||||
|
}
|
||||||
@@ -10,6 +10,7 @@ import './polyfill';
|
|||||||
|
|
||||||
export { default as assert } from './assert';
|
export { default as assert } from './assert';
|
||||||
export { default as detectPackage } from './detectPackage';
|
export { default as detectPackage } from './detectPackage';
|
||||||
|
export { default as extractTime } from './extractTime';
|
||||||
export { default as logger } from './logger';
|
export { default as logger } from './logger';
|
||||||
export { default as promisify } from './promisify';
|
export { default as promisify } from './promisify';
|
||||||
|
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe('TextDecoder', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('polyfills with no exceptions (with TextDecoder)', (): void => {
|
it('polyfills with no exceptions (with TextDecoder)', (): void => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
||||||
(global as any).TextDecoder = require('util').TextDecoder;
|
(global as any).TextDecoder = require('util').TextDecoder;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ describe('TextEncoder', (): void => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
it('polyfills with no exceptions (with TextEncoder)', (): void => {
|
it('polyfills with no exceptions (with TextEncoder)', (): void => {
|
||||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any,@typescript-eslint/no-var-requires,@typescript-eslint/no-unsafe-assignment,@typescript-eslint/no-unsafe-member-access
|
||||||
(global as any).TextEncoder = require('util').TextEncoder;
|
(global as any).TextEncoder = require('util').TextEncoder;
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
// eslint-disable-next-line @typescript-eslint/no-var-requires
|
||||||
|
|||||||
@@ -40,3 +40,11 @@ export type BnList = {
|
|||||||
0: BN;
|
0: BN;
|
||||||
1: BN;
|
1: BN;
|
||||||
} & BN[];
|
} & BN[];
|
||||||
|
|
||||||
|
export interface Time {
|
||||||
|
days: number;
|
||||||
|
hours: number;
|
||||||
|
minutes: number;
|
||||||
|
seconds: number;
|
||||||
|
milliseconds: number;
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user