Converts tests to TypeScript (#300)

This commit is contained in:
Jaco Greeff
2019-02-14 10:48:08 +01:00
committed by GitHub
parent 2a14a8b553
commit 1e6eb2c283
158 changed files with 89 additions and 183 deletions
+1 -2
View File
@@ -6,7 +6,6 @@ import blake2bAsHex from './blake2b/asHex';
/**
* @name blake2AsHex
* @signature blake2AsHex (data: Uint8Array, bitLength: number = 256): string
* @summary Creates a blake2b hex from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a hex string with the specified `bitLength`.
@@ -19,6 +18,6 @@ import blake2bAsHex from './blake2b/asHex';
* blake2AsHex('abc'); // => 0xba80a53f981c4d0d
* ```
*/
export default function blake2AsHex (data: Uint8Array, bitLength: number = 256): string {
export default function blake2AsHex (data: Uint8Array | string, bitLength: number = 256): string {
return blake2bAsHex(data, bitLength);
}
+1 -2
View File
@@ -6,7 +6,6 @@ import blake2bAsU8a from './blake2b/asU8a';
/**
* @name blake2AsU8a
* @signature blake2AsU8a (data: Uint8Array, bitLength: number = 256): Uint8Array
* @summary Creates a blake2b u8a from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a u8a with the specified `bitLength`.
@@ -19,6 +18,6 @@ import blake2bAsU8a from './blake2b/asU8a';
* blake2AsU8a('abc'); // => [0xba, 0x80, 0xa53, 0xf98, 0x1c, 0x4d, 0x0d]
* ```
*/
export default function blake2AsU8a (data: Uint8Array, bitLength: number = 256, key?: Uint8Array): Uint8Array {
export default function blake2AsU8a (data: Uint8Array | string, bitLength: number = 256, key?: Uint8Array): Uint8Array {
return blake2bAsU8a(data, bitLength, key);
}
@@ -8,7 +8,6 @@ import blake2bAsU8a from './asU8a';
/**
* @name blake2bAsHex
* @signature blake2bAsHex (value: Uint8Array): string
* @summary Creates a blake2b hex string from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a hex string.
@@ -21,7 +20,7 @@ import blake2bAsU8a from './asU8a';
* blake2bAsHex('abc'); // => '0xba80a53f981c4d0d6a2797b69f12f6e94c212f14685ac4b74b12bb6fdbffa2d17d87c5392aab792dc252d5de4533cc9518d38aa8dbf1925ab92386edd4009923'
* ```
*/
export default function blake2bAsHex (data: Uint8Array, bitLength: number = 512): string {
export default function blake2bAsHex (data: Uint8Array | string, bitLength: number = 512): string {
return u8aToHex(
blake2bAsU8a(data, bitLength)
);
@@ -7,7 +7,6 @@ import blakejs from 'blakejs';
/**
* @name blake2bAsU8a
* @signature blake2bAsU8a (value: Uint8Array): Uint8Array
* @summary Creates a blake2b Uint8Array from the input.
* @description
* From a `Uint8Array` input, create the blake2b and return the result as a `Uint8Array`.
@@ -20,6 +19,6 @@ import blakejs from 'blakejs';
* blake2bAsU8a('abc'); // => Uint8Array('508c5e8c327c14e2e1a72ba34eeb452f37458b209ed63a294d999b4c86675982')
* ```
*/
export default function blake2bAsU8a (data: Uint8Array, bitLength: number = 512, key: Uint8Array | null = null): Uint8Array {
export default function blake2bAsU8a (data: Uint8Array | string, bitLength: number = 512, key: Uint8Array | null = null): Uint8Array {
return blakejs.blake2b(data, key, bitLength / 8);
}
-1
View File
@@ -8,7 +8,6 @@ import keccakAsU8a from './asU8a';
/**
* @name keccakAsHex
* @signature keccakAsHex (value: Buffer | Uint8Array | string): string
* @summary Creates a keccak hex string from the input.
* @description
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `0x` prefixed hex string.
-1
View File
@@ -6,7 +6,6 @@ import { keccak256 } from 'js-sha3';
/**
* @name keccakAsU8a
* @signature keccakAsU8a (value: Buffer | Uint8Array | string): Uint8Array
* @summary Creates a keccak Uint8Array from the input.
* @description
* From either a `string` or a `Buffer` input, create the keccak and return the result as a `Uint8Array`.
@@ -6,7 +6,6 @@ import { generateMnemonic } from 'bip39';
/**
* @name mnemonicGenerate
* @signature mnemonicGenerate (): string
* @summary Creates a valid mnemonic string using using [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki).
* @example
* <BR>
@@ -6,7 +6,6 @@ import toSecret from './toSecret';
/**
* @name toSeed
* @signature toSeed (mnemonic: string): Uint8Array
* @summary Creates a valid seed from a mnemonic input
* @example
* <BR>
@@ -6,7 +6,6 @@ import { validateMnemonic } from 'bip39';
/**
* @name mnemonicValidate
* @signature mnemonicValidate (mnemonic: string): boolean
* @summary Validates a mnemonic input using [BIP39](https://github.com/bitcoin/bips/blob/master/bip-0039.mediawiki).
* @example
* <BR>
-1
View File
@@ -6,7 +6,6 @@ import nacl from 'tweetnacl';
/**
* @name naclDecrypt
* @signature naclDecrypt (message: Uint8Array, nonce: Uint8Array, secret: Uint8Array): Uint8Array
* @summary Decrypts a message using the supplied secretKey and nonce
* @description
* Returns an decrypted message, using the `secret` and `nonce`.
-1
View File
@@ -13,7 +13,6 @@ type Encrypted = {
/**
* @name naclEncrypt
* @signature naclEncrypt (message: Uint8Array, secret: Uint8Array, nonce?: Uint8Array): { encrypted: Uint8Array, nonce: Uint8Array }
* @summary Encrypts a message using the supplied secretKey and nonce
* @description
* Returns an encrypted message, using the `secretKey` and `nonce`. If the `nonce` was not supplied, a random value is generated.
@@ -8,7 +8,6 @@ import nacl from 'tweetnacl';
/**
* @name naclKeypairFromRandom
* @signature naclKeypairFromRandom (): { secretKey: Uint8Array, publicKey: Uint8Array }
* @summary Creates a new public/secret keypair.
* @description
* Returns a new generate object containing a `publicKey` & `secretKey`.
@@ -8,7 +8,6 @@ import nacl from 'tweetnacl';
/**
* @name naclKeypairFromSecret
* @signature naclKeypairFromSecret (secret: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array }
* @summary Creates a new public/secret keypair from a secret.
* @description
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied secret.
@@ -8,7 +8,6 @@ import nacl from 'tweetnacl';
/**
* @name naclKeypairFromSeed
* @signature naclKeypairFromSeed (seed: Uint8Array): { secretKey: Uint8Array, publicKey: Uint8Array }
* @summary Creates a new public/secret keypair from a seed.
* @description
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied seed.
@@ -11,7 +11,6 @@ import fromSeed from './fromSeed';
/**
* @name naclKeypairFromString
* @signature naclKeypairFromString (value: string): { secretKey: Uint8Array, publicKey: Uint8Array }
* @summary Creates a new public/secret keypair from a string.
* @description
* Returns a object containing a `publicKey` & `secretKey` generated from the supplied string. The string is hashed and the value used as the input seed.
-1
View File
@@ -9,7 +9,6 @@ import { assert } from '@polkadot/util/index';
/**
* @name naclSign
* @signature naclSign (message: Uint8Array, secretKey: Uint8Array): Uint8Array
* @summary Signs a message using the supplied secretKey
* @description
* Returns message signature of `message`, using the `secretKey`.
-1
View File
@@ -6,7 +6,6 @@ import nacl from 'tweetnacl';
/**
* @name naclSign
* @signature naclVerify (message: Uint8Array, signature: Uint8Array, publicKey: Uint8Array): boolean
* @summary Verifies the signature on the supplied message.
* @description
* Verifies the `signature` on `message` with the supplied `plublicKey`. Returns `true` on sucess, `false` otherwise.
-1
View File
@@ -8,7 +8,6 @@ import randomAsU8a from './asU8a';
/**
* @name randomAsHex
* @signature randomAsHex (length?: number = 32): string
* @summary Creates a hex string filled with random bytes.
* @description
* Returns a hex string with the specified (optional) length filled with random bytes.
@@ -11,7 +11,6 @@ const BN_53 = new BN(0b11111111111111111111111111111111111111111111111111111);
/**
* @name randomAsNumber
* @signature randomAsNumber (): number
* @summary Creates a random number from random bytes.
* @description
* Returns a random number generated from the secure bytes.
-1
View File
@@ -6,7 +6,6 @@ import nacl from 'tweetnacl';
/**
* @name randomAsU8a
* @signature randomAsU8a (length?: number = 32): Uint8Array
* @summary Creates a Uint8Array filled with random bytes.
* @description
* Returns a `Uint8Array` with the specified (optional) length filled with random bytes.
-1
View File
@@ -6,7 +6,6 @@ import nacl from 'tweetnacl';
/**
* @name sha512AsU8a
* @signature sha512AsU8a (data: Uint8Array): Uint8Array
* @summary Creates sha-512 hash of the input.
* @description
* Returns a sha-512 `Uint8Array` from the supplied data.
-1
View File
@@ -8,7 +8,6 @@ import xxhashAsU8a from './asU8a';
/**
* @name xxhashAsHex
* @signature xxhashAsHex (data: Buffer | Uint8Array | string, bitLength: number = 64): string
* @summary Creates a xxhash64 hex from the input.
* @description
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a hex string with the specified `bitLength`.
-1
View File
@@ -6,7 +6,6 @@ import xxhash64AsBn from './xxhash64/asBn';
/**
* @name xxhashAsU8a
* @signature xxhashAsU8a (data: Buffer | Uint8Array | string, bitLength: number = 64): Uint8Array
* @summary Creates a xxhash64 u8a from the input.
* @description
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash64 and return the result as a `Uint8Array` with the specified `bitLength`.
@@ -8,7 +8,6 @@ import xxhash64AsRaw from './asRaw';
/**
* @name xxhash64AsBn
* @signature xxhash64AsBn (data: Buffer | Uint8Array | string, seed: number): BN
* @summary Creates a xxhash BN from the input.
* @description
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a BN.
@@ -8,7 +8,6 @@ import xxhash64AsRaw from './asRaw';
/**
* @name xxhash64AsHex
* @signature xxhash64AsHex (data: Buffer | Uint8Array | string, seed: number): string
* @summary Creates a xxhash hex from the input.
* @description
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex string.
@@ -6,7 +6,6 @@ import xxhash64AsValue from './asValue';
/**
* @name xxhash64AsRaw
* @signature xxhash64AsRaw (data: Buffer | Uint8Array | string, seed: number): string
* @summary Creates a xxhash non-prefixed hex from the input.
* @description
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a non-prefixed hex string.
@@ -7,7 +7,6 @@ import { isBuffer, isString, u8aToBuffer } from '@polkadot/util/index';
/**
* @name xxhash64AsValue
* @signature xxhash64AsValue (data: Buffer | Uint8Array | string, seed: number): number
* @summary Creates a hex number from the input.
* @description
* From either a `string`, `Uint8Array` or a `Buffer` input, create the xxhash and return the result as a hex number