Use bn types from @types (#153)

* Use bn.js definitions from @types

* Update isHex & isObservable
This commit is contained in:
Jaco Greeff
2018-06-27 15:05:55 +02:00
committed by GitHub
parent 7b840778b7
commit f0c34bea09
7 changed files with 20 additions and 9 deletions
+1 -1
View File
@@ -17,6 +17,6 @@
},
"devDependencies": {
"@polkadot/dev": "^0.20.8",
"@polkadot/ts": "^0.1.3"
"@polkadot/ts": "^0.1.5"
}
}
+1 -1
View File
@@ -18,7 +18,7 @@ export default function decode (encoded: string | Uint8Array): Uint8Array {
return u8aToU8a(encoded);
}
const decoded = bufferToU8a(bs58.decode(encoded as string));
const decoded = bufferToU8a(bs58.decode(encoded));
const error = (message: string) =>
`Decoding ${encoded}: ${message}`;
+1 -1
View File
@@ -36,7 +36,7 @@ export default function pairs (): KeyringPairs {
assert(pair, () => {
const formatted: string = isU8a(address) || isHex(address)
? u8aToHex(u8aToU8a(address))
: (address as string);
: address;
return `Unable to retrieve keypair '${formatted}'`;
});
+1
View File
@@ -34,6 +34,7 @@
},
"dependencies": {
"@babel/runtime": "^7.0.0-beta.51",
"@types/bn.js": "^4.11.1",
"@types/deasync": "^0.1.0",
"@types/ip-regex": "^2.0.0",
"@types/xxhashjs": "^0.1.1",
+1 -1
View File
@@ -18,7 +18,7 @@ const HEX_REGEX = /^0x[a-fA-F0-9]+$/;
* isHex('0x1234'); // => true
* isHex('0x1234', 8); // => false
*/
export default function isHex (_value: any, bitLength: number = -1, ignoreLength: boolean = false): _value is string {
export default function isHex (_value: any, bitLength: number = -1, ignoreLength: boolean = false): boolean {
const value = (_value as string);
const isValidHex = value === '0x' || (isString(value) && HEX_REGEX.test(value));
+6 -2
View File
@@ -5,6 +5,10 @@
import isFunction from './function';
import isObject from './object';
type Observable = {
next: (...paarams: any[]) => any
};
/**
* @name isBObservable
* @signature isObservable (value: any): boolean
@@ -16,6 +20,6 @@ import isObject from './object';
*
* console.log('isObservable', isObservable(...));
*/
export default function isObservable (value: any): boolean {
return isObject(value) && isFunction((value as any).next);
export default function isObservable (value: any): value is Observable {
return isObject(value) && isFunction((value as Observable).next);
}
+9 -3
View File
@@ -736,9 +736,9 @@
tslint-config-semistandard "^7.0.0"
typescript "^2.9.2"
"@polkadot/ts@^0.1.3":
version "0.1.3"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.3.tgz#e277fb89c43a64b244a6d1ae03fc4ede128b155d"
"@polkadot/ts@^0.1.5":
version "0.1.5"
resolved "https://registry.yarnpkg.com/@polkadot/ts/-/ts-0.1.5.tgz#bd944090a788d9379866059fb61b5708b4696cc7"
"@types/async@^2.0.49":
version "2.0.49"
@@ -748,6 +748,12 @@
version "1.0.29"
resolved "https://registry.yarnpkg.com/@types/base-x/-/base-x-1.0.29.tgz#8a2d73e4a5c3121757a5f8870cfa4509655186b6"
"@types/bn.js@^4.11.1":
version "4.11.1"
resolved "https://registry.yarnpkg.com/@types/bn.js/-/bn.js-4.11.1.tgz#6fd07b93490ecf0f3501a31ea9cfd330885b10fa"
dependencies:
"@types/node" "*"
"@types/bs58@^3.0.30":
version "3.0.30"
resolved "https://registry.yarnpkg.com/@types/bs58/-/bs58-3.0.30.tgz#916ba10992465e56f81afc735e7935fd749893e1"