From de1d13bd54cc3a7fb65c04651a68c71bd2968882 Mon Sep 17 00:00:00 2001 From: Mohamed Hegazy Date: Thu, 29 Dec 2016 12:34:20 -0800 Subject: [PATCH] Add new packages (#13578) * Add xstream * Add bigi * Add uuid-js * Add user-home * Add strip-bom * Add strip-ansi * Add slug * Add safe-regex * Add react-recaptcha * Add is-absolute-url * Add is-archive * Add is-compressed * Add is-relative-url * add is-root-path * Add is-root * Add is-text-path * add os-homedir * Add os-tmpdir * Add path-is-absolute * Add pad * Add number-is-nan * Add node-hid * Add is-finite * is-path-incwd * Add indent-string * Add cpy * Add camelcase-keys * Add blacklist * add http-codes * clamp-js * Add checkstyle-formatter * Add currency-formatter * Add multi-typeof * Add intl-messageformat * Add coinstring * Add ecurve * Add bitcoinjs-lib * Add deep-freeze * Add fuxxaldrin * Add react-body-classname * Add react-highlight-words * Update headers * Fix lint errors * remove xstream * Code review comments * Remove clamp-js in favour of https://github.com/DefinitelyTyped/DefinitelyTyped/pull/13527 --- bigi/bigi-tests.ts | 9 + bigi/index.d.ts | 105 +++++ bigi/tsconfig.json | 20 + bigi/tslint.json | 1 + bitcoinjs-lib/bitcoinjs-lib-tests.ts | 63 +++ bitcoinjs-lib/index.d.ts | 403 ++++++++++++++++++ bitcoinjs-lib/tsconfig.json | 20 + bitcoinjs-lib/tslint.json | 1 + blacklist/blacklist-tests.ts | 13 + blacklist/index.d.ts | 8 + blacklist/tsconfig.json | 20 + blacklist/tslint.json | 1 + camelcase-keys/camelcase-keys-tests.ts | 10 + camelcase-keys/index.d.ts | 7 + camelcase-keys/tsconfig.json | 20 + camelcase-keys/tslint.json | 1 + checkstyle-formatter/index.d.ts | 7 + checkstyle-formatter/tsconfig.json | 19 + checkstyle-formatter/tslint.json | 1 + coinstring/coinstring-tests.ts | 69 +++ coinstring/index.d.ts | 13 + coinstring/tsconfig.json | 20 + coinstring/tslint.json | 1 + cpy/cpy-tests.ts | 10 + cpy/index.d.ts | 7 + cpy/tsconfig.json | 20 + cpy/tslint.json | 1 + currency-formatter/currencies.d.ts | 2 + .../currency-formatter-tests.ts | 47 ++ currency-formatter/index.d.ts | 30 ++ currency-formatter/tsconfig.json | 21 + currency-formatter/tslint.json | 1 + deep-freeze-strict/index.d.ts | 7 + deep-freeze-strict/tsconfig.json | 19 + deep-freeze-strict/tslint.json | 1 + ecurve/ecurve-tests.ts | 55 +++ ecurve/index.d.ts | 41 ++ ecurve/tsconfig.json | 20 + ecurve/tslint.json | 1 + fuzzaldrin/index.d.ts | 8 + fuzzaldrin/tsconfig.json | 19 + fuzzaldrin/tslint.json | 1 + http-codes/index.d.ts | 67 +++ http-codes/tsconfig.json | 19 + http-codes/tslint.json | 1 + indent-string/indent-string-tests.ts | 9 + indent-string/index.d.ts | 7 + indent-string/tsconfig.json | 20 + indent-string/tslint.json | 1 + intl-messageformat/index.d.ts | 51 +++ .../intl-messageformat-tests.ts | 45 ++ intl-messageformat/tsconfig.json | 20 + intl-messageformat/tslint.json | 1 + is-absolute-url/index.d.ts | 7 + is-absolute-url/is-absolute-url-tests.ts | 10 + is-absolute-url/tsconfig.json | 20 + is-absolute-url/tslint.json | 1 + is-archive/index.d.ts | 7 + is-archive/is-archive-tests.ts | 7 + is-archive/tsconfig.json | 20 + is-archive/tslint.json | 1 + is-compressed/index.d.ts | 7 + is-compressed/is-compressed-tests.ts | 7 + is-compressed/tsconfig.json | 20 + is-compressed/tslint.json | 1 + is-finite/index.d.ts | 7 + is-finite/tsconfig.json | 19 + is-finite/tslint.json | 1 + is-path-in-cwd/index.d.ts | 7 + is-path-in-cwd/tsconfig.json | 19 + is-path-in-cwd/tslint.json | 1 + is-relative-url/index.d.ts | 7 + is-relative-url/is-relative-url-tests.ts | 10 + is-relative-url/tsconfig.json | 20 + is-relative-url/tslint.json | 1 + is-root-path/index.d.ts | 7 + is-root-path/is-root-path-tests.ts | 7 + is-root-path/tsconfig.json | 20 + is-root-path/tslint.json | 1 + is-root/index.d.ts | 7 + is-root/is-root-tests.ts | 5 + is-root/tsconfig.json | 20 + is-root/tslint.json | 1 + is-text-path/index.d.ts | 7 + is-text-path/is-text-path-tests.ts | 7 + is-text-path/tsconfig.json | 20 + is-text-path/tslint.json | 1 + multi-typeof/index.d.ts | 7 + multi-typeof/tsconfig.json | 19 + multi-typeof/tslint.json | 1 + node-hid/index.d.ts | 31 ++ node-hid/node-hid-tests.ts | 13 + node-hid/tsconfig.json | 20 + node-hid/tslint.json | 1 + number-is-nan/index.d.ts | 7 + number-is-nan/tsconfig.json | 19 + number-is-nan/tslint.json | 1 + os-homedir/index.d.ts | 7 + os-homedir/tsconfig.json | 19 + os-homedir/tslint.json | 1 + os-tmpdir/index.d.ts | 7 + os-tmpdir/tsconfig.json | 19 + os-tmpdir/tslint.json | 1 + pad/index.d.ts | 11 + pad/pad-tests.ts | 6 + pad/tsconfig.json | 20 + pad/tslint.json | 1 + path-is-absolute/index.d.ts | 11 + path-is-absolute/path-is-absolute-tests.ts | 23 + path-is-absolute/tsconfig.json | 20 + path-is-absolute/tslint.json | 1 + react-body-classname/index.d.ts | 15 + .../react-body-classname-tests.tsx | 26 ++ react-body-classname/tsconfig.json | 21 + react-body-classname/tslint.json | 1 + react-highlight-words/index.d.ts | 33 ++ .../react-highlight-words-tests.tsx | 9 + react-highlight-words/tsconfig.json | 21 + react-highlight-words/tslint.json | 1 + react-recaptcha/index.d.ts | 29 ++ react-recaptcha/react-recaptcha-tests.tsx | 10 + react-recaptcha/tsconfig.json | 21 + react-recaptcha/tslint.json | 1 + safe-regex/index.d.ts | 7 + safe-regex/safe-regex-tests.ts | 2 + safe-regex/tsconfig.json | 20 + safe-regex/tslint.json | 1 + slug/index.d.ts | 34 ++ slug/slug-tests.ts | 41 ++ slug/tsconfig.json | 20 + slug/tslint.json | 1 + strip-ansi/index.d.ts | 7 + strip-ansi/strip-ansi-tests.ts | 4 + strip-ansi/tsconfig.json | 20 + strip-ansi/tslint.json | 1 + strip-bom/index.d.ts | 7 + strip-bom/strip-bom-tests.ts | 4 + strip-bom/tsconfig.json | 20 + strip-bom/tslint.json | 1 + user-home/index.d.ts | 7 + user-home/tsconfig.json | 20 + user-home/tslint.json | 1 + user-home/user-home-tests.ts | 4 + uuid-js/index.d.ts | 42 ++ uuid-js/tsconfig.json | 20 + uuid-js/tslint.json | 1 + uuid-js/uuid-js-tests.ts | 28 ++ 147 files changed, 2454 insertions(+) create mode 100644 bigi/bigi-tests.ts create mode 100644 bigi/index.d.ts create mode 100644 bigi/tsconfig.json create mode 100644 bigi/tslint.json create mode 100644 bitcoinjs-lib/bitcoinjs-lib-tests.ts create mode 100644 bitcoinjs-lib/index.d.ts create mode 100644 bitcoinjs-lib/tsconfig.json create mode 100644 bitcoinjs-lib/tslint.json create mode 100644 blacklist/blacklist-tests.ts create mode 100644 blacklist/index.d.ts create mode 100644 blacklist/tsconfig.json create mode 100644 blacklist/tslint.json create mode 100644 camelcase-keys/camelcase-keys-tests.ts create mode 100644 camelcase-keys/index.d.ts create mode 100644 camelcase-keys/tsconfig.json create mode 100644 camelcase-keys/tslint.json create mode 100644 checkstyle-formatter/index.d.ts create mode 100644 checkstyle-formatter/tsconfig.json create mode 100644 checkstyle-formatter/tslint.json create mode 100644 coinstring/coinstring-tests.ts create mode 100644 coinstring/index.d.ts create mode 100644 coinstring/tsconfig.json create mode 100644 coinstring/tslint.json create mode 100644 cpy/cpy-tests.ts create mode 100644 cpy/index.d.ts create mode 100644 cpy/tsconfig.json create mode 100644 cpy/tslint.json create mode 100644 currency-formatter/currencies.d.ts create mode 100644 currency-formatter/currency-formatter-tests.ts create mode 100644 currency-formatter/index.d.ts create mode 100644 currency-formatter/tsconfig.json create mode 100644 currency-formatter/tslint.json create mode 100644 deep-freeze-strict/index.d.ts create mode 100644 deep-freeze-strict/tsconfig.json create mode 100644 deep-freeze-strict/tslint.json create mode 100644 ecurve/ecurve-tests.ts create mode 100644 ecurve/index.d.ts create mode 100644 ecurve/tsconfig.json create mode 100644 ecurve/tslint.json create mode 100644 fuzzaldrin/index.d.ts create mode 100644 fuzzaldrin/tsconfig.json create mode 100644 fuzzaldrin/tslint.json create mode 100644 http-codes/index.d.ts create mode 100644 http-codes/tsconfig.json create mode 100644 http-codes/tslint.json create mode 100644 indent-string/indent-string-tests.ts create mode 100644 indent-string/index.d.ts create mode 100644 indent-string/tsconfig.json create mode 100644 indent-string/tslint.json create mode 100644 intl-messageformat/index.d.ts create mode 100644 intl-messageformat/intl-messageformat-tests.ts create mode 100644 intl-messageformat/tsconfig.json create mode 100644 intl-messageformat/tslint.json create mode 100644 is-absolute-url/index.d.ts create mode 100644 is-absolute-url/is-absolute-url-tests.ts create mode 100644 is-absolute-url/tsconfig.json create mode 100644 is-absolute-url/tslint.json create mode 100644 is-archive/index.d.ts create mode 100644 is-archive/is-archive-tests.ts create mode 100644 is-archive/tsconfig.json create mode 100644 is-archive/tslint.json create mode 100644 is-compressed/index.d.ts create mode 100644 is-compressed/is-compressed-tests.ts create mode 100644 is-compressed/tsconfig.json create mode 100644 is-compressed/tslint.json create mode 100644 is-finite/index.d.ts create mode 100644 is-finite/tsconfig.json create mode 100644 is-finite/tslint.json create mode 100644 is-path-in-cwd/index.d.ts create mode 100644 is-path-in-cwd/tsconfig.json create mode 100644 is-path-in-cwd/tslint.json create mode 100644 is-relative-url/index.d.ts create mode 100644 is-relative-url/is-relative-url-tests.ts create mode 100644 is-relative-url/tsconfig.json create mode 100644 is-relative-url/tslint.json create mode 100644 is-root-path/index.d.ts create mode 100644 is-root-path/is-root-path-tests.ts create mode 100644 is-root-path/tsconfig.json create mode 100644 is-root-path/tslint.json create mode 100644 is-root/index.d.ts create mode 100644 is-root/is-root-tests.ts create mode 100644 is-root/tsconfig.json create mode 100644 is-root/tslint.json create mode 100644 is-text-path/index.d.ts create mode 100644 is-text-path/is-text-path-tests.ts create mode 100644 is-text-path/tsconfig.json create mode 100644 is-text-path/tslint.json create mode 100644 multi-typeof/index.d.ts create mode 100644 multi-typeof/tsconfig.json create mode 100644 multi-typeof/tslint.json create mode 100644 node-hid/index.d.ts create mode 100644 node-hid/node-hid-tests.ts create mode 100644 node-hid/tsconfig.json create mode 100644 node-hid/tslint.json create mode 100644 number-is-nan/index.d.ts create mode 100644 number-is-nan/tsconfig.json create mode 100644 number-is-nan/tslint.json create mode 100644 os-homedir/index.d.ts create mode 100644 os-homedir/tsconfig.json create mode 100644 os-homedir/tslint.json create mode 100644 os-tmpdir/index.d.ts create mode 100644 os-tmpdir/tsconfig.json create mode 100644 os-tmpdir/tslint.json create mode 100644 pad/index.d.ts create mode 100644 pad/pad-tests.ts create mode 100644 pad/tsconfig.json create mode 100644 pad/tslint.json create mode 100644 path-is-absolute/index.d.ts create mode 100644 path-is-absolute/path-is-absolute-tests.ts create mode 100644 path-is-absolute/tsconfig.json create mode 100644 path-is-absolute/tslint.json create mode 100644 react-body-classname/index.d.ts create mode 100644 react-body-classname/react-body-classname-tests.tsx create mode 100644 react-body-classname/tsconfig.json create mode 100644 react-body-classname/tslint.json create mode 100644 react-highlight-words/index.d.ts create mode 100644 react-highlight-words/react-highlight-words-tests.tsx create mode 100644 react-highlight-words/tsconfig.json create mode 100644 react-highlight-words/tslint.json create mode 100644 react-recaptcha/index.d.ts create mode 100644 react-recaptcha/react-recaptcha-tests.tsx create mode 100644 react-recaptcha/tsconfig.json create mode 100644 react-recaptcha/tslint.json create mode 100644 safe-regex/index.d.ts create mode 100644 safe-regex/safe-regex-tests.ts create mode 100644 safe-regex/tsconfig.json create mode 100644 safe-regex/tslint.json create mode 100644 slug/index.d.ts create mode 100644 slug/slug-tests.ts create mode 100644 slug/tsconfig.json create mode 100644 slug/tslint.json create mode 100644 strip-ansi/index.d.ts create mode 100644 strip-ansi/strip-ansi-tests.ts create mode 100644 strip-ansi/tsconfig.json create mode 100644 strip-ansi/tslint.json create mode 100644 strip-bom/index.d.ts create mode 100644 strip-bom/strip-bom-tests.ts create mode 100644 strip-bom/tsconfig.json create mode 100644 strip-bom/tslint.json create mode 100644 user-home/index.d.ts create mode 100644 user-home/tsconfig.json create mode 100644 user-home/tslint.json create mode 100644 user-home/user-home-tests.ts create mode 100644 uuid-js/index.d.ts create mode 100644 uuid-js/tsconfig.json create mode 100644 uuid-js/tslint.json create mode 100644 uuid-js/uuid-js-tests.ts diff --git a/bigi/bigi-tests.ts b/bigi/bigi-tests.ts new file mode 100644 index 0000000000..82ba89fb18 --- /dev/null +++ b/bigi/bigi-tests.ts @@ -0,0 +1,9 @@ +import BigInteger = require('bigi') + +var b1 = BigInteger.fromHex("188DA80EB03090F67CBF20EB43A18800F4FF0AFD82FF1012") +var b2 = BigInteger.fromHex("07192B95FFC8DA78631011ED6B24CDD573F977A11E794811") + +var b3 = b1.multiply(b2) + +console.log(b3.toHex()) +// => ae499bfe762edfb416d0ce71447af67ff33d1760cbebd70874be1d7a5564b0439a59808cb1856a91974f7023f72132 \ No newline at end of file diff --git a/bigi/index.d.ts b/bigi/index.d.ts new file mode 100644 index 0000000000..c991b13fac --- /dev/null +++ b/bigi/index.d.ts @@ -0,0 +1,105 @@ +// Type definitions for bigi 1.4 +// Project: https://github.com/cryptocoinjs/bigi#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = bigi; + +declare class bigi { + constructor(a: any, b: any, c: any); + abs(): any; + add(a: bigi): bigi; + addTo(a: bigi, r: number): void; + am(i: any, x: any, w: any, j: any, c: any, n: any): any; + and(a: bigi): bigi; + andNot(a: any): any; + bitCount(): any; + bitLength(): any; + bitwiseTo(a: any, op: any, r: any): void; + byteLength(): any; + byteValue(): any; + changeBit(n: any, op: any): any; + chunkSize(r: any): any; + clamp(): void; + clearBit(n: number): bigi; + clone(): bigi; + compareTo(a: bigi): bigi; + copyTo(r: any): void; + dAddOffset(n: any, w: any): void; + dMultiply(n: number): void; + divRemTo(m: any, q: any, r: any): void; + divide(a: any): any; + divideAndRemainder(a: bigi): bigi; + dlShiftTo(n: bigi, r: number): void; + drShiftTo(n: bigi, r: number): void; + equals(a: bigi): boolean; + exp(e: any, z: any): any; + flipBit(n: number): bigi; + fromInt(x: any): void; + fromNumber(a: any, b: any, c: any): void; + fromRadix(s: any, b: any): void; + fromString(s: any, b: any): void; + gcd(a: any): any; + getLowestSetBit(): any; + intValue(): number; + invDigit(): any; + isEven(): boolean; + isProbablePrime(t: any): boolean; + lShiftTo(n: any, r: any): void; + max(a: any): any; + millerRabin(t: bigi): bigi; + min(a: bigi): bigi; + mod(a: bigi): bigi; + modInt(n: number): bigi; + modInverse(m: number): bigi; + modPow(e: any, m: any): any; + modPowInt(e: any, m: any): any; + multiply(a: bigi): bigi; + multiplyLowerTo(a: bigi, n: any, r: any): void; + multiplyTo(a: bigi, r: any): void; + multiplyUpperTo(a: bigi, n: any, r: any): void; + negate(): bigi; + not(): bigi; + or(a: bigi): bigi; + pow(e: bigi): bigi; + rShiftTo(n: bigi, r: any): void; + remainder(a: bigi): bigi; + setBit(n: number): bigi; + shiftLeft(n: number): bigi; + shiftRight(n: number): bigi; + shortValue(): bigi; + signum(): bigi; + square(): bigi; + squareTo(r: any): void; + subTo(a: any, r: any): void; + subtract(a: bigi): bigi; + testBit(n: any): any; + toBuffer(size: number): any; + toByteArray(): any; + toByteArrayUnsigned(): any; + toDERInteger(): any; + toHex(size?: number): string; + toRadix(b: number): string; + toString(b?: any): string; + xor(a: any): any; + static fromBuffer(buffer: any): bigi; + static fromByteArrayUnsigned(byteArray?: any): number[]; + static fromDERInteger(byteArray?: any): number; + static fromHex(hex: string): bigi; + static isBigInteger(obj: any, check_ver: any): obj is bigi; + static valueOf(i: any): number; +} +declare namespace bigi { + interface Constants { + readonly DB: number; + readonly DM: number; + readonly DV: number; + readonly F1: number; + readonly F2: number; + readonly FV: number; + readonly s: number; + readonly t: number; + } + const ONE: bigi & Constants; + const ZERO: bigi & Constants; +} diff --git a/bigi/tsconfig.json b/bigi/tsconfig.json new file mode 100644 index 0000000000..261cc6a2a4 --- /dev/null +++ b/bigi/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bigi-tests.ts" + ] +} diff --git a/bigi/tslint.json b/bigi/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/bigi/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/bitcoinjs-lib/bitcoinjs-lib-tests.ts b/bitcoinjs-lib/bitcoinjs-lib-tests.ts new file mode 100644 index 0000000000..9341d60c66 --- /dev/null +++ b/bitcoinjs-lib/bitcoinjs-lib-tests.ts @@ -0,0 +1,63 @@ +/// + +import bigi = require('bigi') +import bitcoin = require('bitcoinjs-lib'); + +declare var it: any; +declare var describe: any; +declare var assert: any; + +describe('bitcoinjs-lib (basic)', function () { + it('can generate a random bitcoin address', function () { + // for testing only + function rng() { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') } + + // generate random keyPair + var keyPair = bitcoin.ECPair.makeRandom({ rng: rng }) + var address = keyPair.getAddress() + + assert.strictEqual(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64') + }) + + it('can generate an address from a SHA256 hash', function () { + var hash = bitcoin.crypto.sha256('correct horse battery staple') + var d = bigi.fromBuffer(hash) + + var keyPair = new bitcoin.ECPair(d) + var address = keyPair.getAddress() + + assert.strictEqual(address, '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8') + }) + + it('can generate a random keypair for alternative networks', function () { + // for testing only + function rng() { return new Buffer('zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz') } + + var litecoin = bitcoin.networks.litecoin + + var keyPair = bitcoin.ECPair.makeRandom({ network: litecoin, rng: rng }) + var wif = keyPair.toWIF() + var address = keyPair.getAddress() + + assert.strictEqual(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn') + assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS') + }) + + it('can import an address via WIF', function () { + var keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct') + var address = keyPair.getAddress() + + assert.strictEqual(address, '19AAjaTUbRjQCMuVczepkoPswiZRhjtg31') + }) + + it('can create a Transaction', function () { + var keyPair = bitcoin.ECPair.fromWIF('L1uyy5qTuGrVXrmrsvHWHgVzW9kKdrp27wBC7Vs6nZDTF2BRUVwy') + var tx = new bitcoin.TransactionBuilder() + + tx.addInput('aa94ab02c182214f090e99a0d57021caffd0f195a81c24602b1028b130b63e31', 0) + tx.addOutput('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000) + tx.sign(0, keyPair) + + assert.strictEqual(tx.build().toHex(), '0100000001313eb630b128102b60241ca895f1d0ffca2170d5a0990e094f2182c102ab94aa000000006b483045022100aefbcf847900b01dd3e3debe054d3b6d03d715d50aea8525f5ea3396f168a1fb022013d181d05b15b90111808b22ef4f9ebe701caf2ab48db269691fdf4e9048f4f60121029f50f51d63b345039a290c94bffd3180c99ed659ff6ea6b1242bca47eb93b59fffffffff01983a0000000000001976a914ad618cf4333b3b248f9744e8e81db2964d0ae39788ac00000000') + }) +}) \ No newline at end of file diff --git a/bitcoinjs-lib/index.d.ts b/bitcoinjs-lib/index.d.ts new file mode 100644 index 0000000000..600edda000 --- /dev/null +++ b/bitcoinjs-lib/index.d.ts @@ -0,0 +1,403 @@ +// Type definitions for bitcoinjs-lib 2.3 +// Project: https://github.com/bitcoinjs/bitcoinjs-lib#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export class Block { + constructor(); + checkMerkleRoot(): any; + checkProofOfWork(): any; + getHash(): any; + getId(): any; + getUTCDate(): any; + toBuffer(headersOnly: any): any; + toHex(headersOnly: any): any; + static calculateMerkleRoot(transactions: any): any; + static calculateTarget(bits: any): any; + static fromBuffer(buffer: any): any; + static fromHex(hex: any): any; +} +export class ECPair { + constructor(d: any, Q?: any, options?: any); + getAddress(): string; + getNetwork(): Network; + getPublicKeyBuffer(): any; + sign(hash: any): any; + toWIF(): string; + verify(hash: any, signature: any): boolean; + static fromPublicKeyBuffer(buffer: any, network: Network): ECPair; + static fromWIF(string: any, network?: Network): ECPair; + static makeRandom(options: any): ECPair; +} +export class ECSignature { + constructor(r: any, s: any, ...args: any[]); + toCompact(i: any, compressed: any): any; + toDER(): any; + toScriptSignature(hashType: any): any; + static fromDER(buffer: any): ECSignature; + static parseCompact(buffer: any): ECSignature; + static parseScriptSignature(buffer: any): ECSignature; +} +export class HDNode { + constructor(keyPair: any, chainCode: any, ...args: any[]); + derive(index: any): any; + deriveHardened(index: any): any; + derivePath(path: any): any; + getAddress(): string; + getFingerprint(): any; + getIdentifier(): any; + getNetwork(): Network; + getPublicKeyBuffer(): any; + isNeutered(): any; + neutered(): any; + sign(hash: any): any; + toBase58(__isPrivate: any): any; + toString(__isPrivate: any): any; + verify(hash: any, signature: any): any; + static HIGHEST_BIT: number; + static LENGTH: number; + static fromBase58(string: any, networks: Network[]): HDNode; + static fromSeedBuffer(seed: any, network: Network, ...args: any[]): HDNode; + static fromSeedHex(hex: any, network: Network): HDNode; +} +export class Transaction { + constructor(); + addInput(hash: any, index: any, sequence: any, scriptSig: any, ...args: any[]): any; + addOutput(scriptPubKey: any, value: any, ...args: any[]): any; + byteLength(): number; + clone(): Transaction; + getHash(): any; + getId(): any; + hashForSignature(inIndex: any, prevOutScript: any, hashType: any, ...args: any[]): any; + isCoinbase(): boolean; + setInputScript(index: any, scriptSig: any, ...args: any[]): void; + toBuffer(buffer?: any, initialOffset?: any): Buffer; + toHex(): string; + static DEFAULT_SEQUENCE: number; + static SIGHASH_ALL: number; + static SIGHASH_ANYONECANPAY: number; + static SIGHASH_NONE: number; + static SIGHASH_SINGLE: number; + static fromBuffer(buffer: any, __noStrict: any): Transaction; + static fromHex(hex: any): Transaction; + static isCoinbaseHash(buffer: any): Transaction; +} +export class TransactionBuilder { + constructor(network?: Network); + addInput(txHash: any, vout: any, sequence?: any, prevOutScript?: any): any; + addOutput(scriptPubKey: any, value: any): any; + build(): Transaction; + buildIncomplete(): Transaction; + setLockTime(locktime: number): any; + setVersion(version: number): void; + sign(index: any, keyPair: any, redeemScript?: any, hashType?: any): any; + static fromTransaction(transaction: Transaction, network: Network): TransactionBuilder; +} + +export interface Network { + bitcoin: { + private: number; + public: number; + }; + dustThreshold: number; + messagePrefix: string; + pubKeyHash: number; + scriptHash: number; + wif: number; +} + +export const networks: { + bitcoin: Network; + dogecoin: Network; + litecoin: Network; + testnet: Network; +}; + +export const opcodes: { + OP_0: number; + OP_0NOTEQUAL: number; + OP_1: number; + OP_10: number; + OP_11: number; + OP_12: number; + OP_13: number; + OP_14: number; + OP_15: number; + OP_16: number; + OP_1ADD: number; + OP_1NEGATE: number; + OP_1SUB: number; + OP_2: number; + OP_2DIV: number; + OP_2DROP: number; + OP_2DUP: number; + OP_2MUL: number; + OP_2OVER: number; + OP_2ROT: number; + OP_2SWAP: number; + OP_3: number; + OP_3DUP: number; + OP_4: number; + OP_5: number; + OP_6: number; + OP_7: number; + OP_8: number; + OP_9: number; + OP_ABS: number; + OP_ADD: number; + OP_AND: number; + OP_BOOLAND: number; + OP_BOOLOR: number; + OP_CAT: number; + OP_CHECKLOCKTIMEVERIFY: number; + OP_CHECKMULTISIG: number; + OP_CHECKMULTISIGVERIFY: number; + OP_CHECKSIG: number; + OP_CHECKSIGVERIFY: number; + OP_CODESEPARATOR: number; + OP_DEPTH: number; + OP_DIV: number; + OP_DROP: number; + OP_DUP: number; + OP_ELSE: number; + OP_ENDIF: number; + OP_EQUAL: number; + OP_EQUALVERIFY: number; + OP_FALSE: number; + OP_FROMALTSTACK: number; + OP_GREATERTHAN: number; + OP_GREATERTHANOREQUAL: number; + OP_HASH160: number; + OP_HASH256: number; + OP_IF: number; + OP_IFDUP: number; + OP_INVALIDOPCODE: number; + OP_INVERT: number; + OP_LEFT: number; + OP_LESSTHAN: number; + OP_LESSTHANOREQUAL: number; + OP_LSHIFT: number; + OP_MAX: number; + OP_MIN: number; + OP_MOD: number; + OP_MUL: number; + OP_NEGATE: number; + OP_NIP: number; + OP_NOP: number; + OP_NOP1: number; + OP_NOP10: number; + OP_NOP2: number; + OP_NOP3: number; + OP_NOP4: number; + OP_NOP5: number; + OP_NOP6: number; + OP_NOP7: number; + OP_NOP8: number; + OP_NOP9: number; + OP_NOT: number; + OP_NOTIF: number; + OP_NUMEQUAL: number; + OP_NUMEQUALVERIFY: number; + OP_NUMNOTEQUAL: number; + OP_OR: number; + OP_OVER: number; + OP_PICK: number; + OP_PUBKEY: number; + OP_PUBKEYHASH: number; + OP_PUSHDATA1: number; + OP_PUSHDATA2: number; + OP_PUSHDATA4: number; + OP_RESERVED: number; + OP_RESERVED1: number; + OP_RESERVED2: number; + OP_RETURN: number; + OP_RIGHT: number; + OP_RIPEMD160: number; + OP_ROLL: number; + OP_ROT: number; + OP_RSHIFT: number; + OP_SHA1: number; + OP_SHA256: number; + OP_SIZE: number; + OP_SUB: number; + OP_SUBSTR: number; + OP_SWAP: number; + OP_TOALTSTACK: number; + OP_TRUE: number; + OP_TUCK: number; + OP_VER: number; + OP_VERIF: number; + OP_VERIFY: number; + OP_VERNOTIF: number; + OP_WITHIN: number; + OP_XOR: number; +}; +export namespace HDNode { + namespace MASTER_SECRET { + const BYTES_PER_ELEMENT: number; + const byteLength: number; + const byteOffset: number; + const length: number; + const offset: number; + function asciiSlice(): any; + function asciiWrite(): any; + function base64Slice(): any; + function base64Write(): any; + function compare(target: any, start: any, end: any, thisStart: any, thisEnd: any): any; + function copy(): any; + function copyWithin(p0: any, p1: any): any; + function entries(): any; + function equals(b: any): any; + function every(p0: any): any; + function fill(val: any, start: any, end: any, encoding: any): any; + function filter(p0: any): any; + function find(p0: any): any; + function findIndex(p0: any): any; + function forEach(p0: any): any; + function hexSlice(): any; + function hexWrite(): any; + function includes(val: any, byteOffset: any, encoding: any): any; + function indexOf(val: any, byteOffset: any, encoding: any): any; + function inspect(): any; + function join(p0: any): any; + function keys(): any; + function lastIndexOf(val: any, byteOffset: any, encoding: any): any; + function latin1Slice(): any; + function latin1Write(): any; + function map(p0: any): any; + function readDoubleBE(offset: any, noAssert: any): any; + function readDoubleLE(offset: any, noAssert: any): any; + function readFloatBE(offset: any, noAssert: any): any; + function readFloatLE(offset: any, noAssert: any): any; + function readInt16BE(offset: any, noAssert: any): any; + function readInt16LE(offset: any, noAssert: any): any; + function readInt32BE(offset: any, noAssert: any): any; + function readInt32LE(offset: any, noAssert: any): any; + function readInt8(offset: any, noAssert: any): any; + function readIntBE(offset: any, byteLength: any, noAssert: any): any; + function readIntLE(offset: any, byteLength: any, noAssert: any): any; + function readUInt16BE(offset: any, noAssert: any): any; + function readUInt16LE(offset: any, noAssert: any): any; + function readUInt32BE(offset: any, noAssert: any): any; + function readUInt32LE(offset: any, noAssert: any): any; + function readUInt8(offset: any, noAssert: any): any; + function readUIntBE(offset: any, byteLength: any, noAssert: any): any; + function readUIntLE(offset: any, byteLength: any, noAssert: any): any; + function reduce(p0: any): any; + function reduceRight(p0: any): any; + function reverse(): any; + function set(p0: any): any; + function slice(start: any, end: any): any; + function some(p0: any): any; + function sort(p0: any): any; + function subarray(p0: any, p1: any): any; + function swap16(): any; + function swap32(): any; + function swap64(): any; + function toJSON(): any; + function toLocaleString(): any; + function toString(...args: any[]): any; + function ucs2Slice(): any; + function ucs2Write(): any; + function undefined(): any; + function utf8Slice(): any; + function utf8Write(): any; + function values(): any; + function write(string: any, offset: any, length: any, encoding: any): any; + function writeDoubleBE(val: any, offset: any, noAssert: any): any; + function writeDoubleLE(val: any, offset: any, noAssert: any): any; + function writeFloatBE(val: any, offset: any, noAssert: any): any; + function writeFloatLE(val: any, offset: any, noAssert: any): any; + function writeInt16BE(value: any, offset: any, noAssert: any): any; + function writeInt16LE(value: any, offset: any, noAssert: any): any; + function writeInt32BE(value: any, offset: any, noAssert: any): any; + function writeInt32LE(value: any, offset: any, noAssert: any): any; + function writeInt8(value: any, offset: any, noAssert: any): any; + function writeIntBE(value: any, offset: any, byteLength: any, noAssert: any): any; + function writeIntLE(value: any, offset: any, byteLength: any, noAssert: any): any; + function writeUInt16BE(value: any, offset: any, noAssert: any): any; + function writeUInt16LE(value: any, offset: any, noAssert: any): any; + function writeUInt32BE(value: any, offset: any, noAssert: any): any; + function writeUInt32LE(value: any, offset: any, noAssert: any): any; + function writeUInt8(value: any, offset: any, noAssert: any): any; + function writeUIntBE(value: any, offset: any, byteLength: any, noAssert: any): any; + function writeUIntLE(value: any, offset: any, byteLength: any, noAssert: any): any; + namespace buffer { + const byteLength: number; + function slice(p0: any, p1: any): any; + } + namespace parent { + const byteLength: number; + function slice(p0: any, p1: any): any; + } + } +} +export namespace address { + function fromBase58Check(address: any): any; + function fromOutputScript(scriptPubKey: any, network?: Network): any; + function toBase58Check(hash: any, version: any, ...args: any[]): any; + function toOutputScript(address: any, network?: Network): any; +} +export namespace bufferutils { + function equal(a: any, b: any): any; + function pushDataSize(i: any): any; + function readPushDataInt(buffer: any, offset: any): any; + function readUInt64LE(buffer: any, offset: any): any; + function readVarInt(buffer: any, offset: any): any; + function reverse(src: any): any; + function varIntBuffer(i: any): any; + function varIntSize(i: any): any; + function writePushDataInt(buffer: any, number: any, offset: any): any; + function writeUInt64LE(buffer: any, value: any, offset: any): void; + function writeVarInt(buffer: any, number: any, offset: any): any; +} +export namespace crypto { + function hash160(buffer: any): any; + function hash256(buffer: any): any; + function ripemd160(buffer: any): any; + function sha1(buffer: any): any; + function sha256(buffer: any): any; +} +export namespace message { + function magicHash(message: any, network: any): any; + function sign(keyPair: any, message: any, network: any): any; + function verify(address: any, signature: any, message: any, network: any): any; +} +export namespace script { + function classifyInput(script: any, allowIncomplete: any): any; + function classifyOutput(script: any): any; + function compile(chunks: any): any; + function decompile(buffer: any): any; + function fromASM(asm: any): any; + function isCanonicalPubKey(buffer: any): any; + function isCanonicalSignature(buffer: any): any; + function isDefinedHashType(hashType: any): any; + function isMultisigInput(script: any, allowIncomplete: any): any; + function isMultisigOutput(script: any): any; + function isNullDataOutput(script: any): any; + function isPubKeyHashInput(script: any): any; + function isPubKeyHashOutput(script: any): any; + function isPubKeyInput(script: any): any; + function isPubKeyOutput(script: any): any; + function isScriptHashInput(script: any, allowIncomplete: any): any; + function isScriptHashOutput(script: any): any; + function isWitnessPubKeyHashOutput(script: any): any; + function isWitnessScriptHashOutput(script: any): any; + function multisigInput(signatures: any, scriptPubKey: any): any; + function multisigOutput(m: any, pubKeys: any, ...args: any[]): any; + function nullDataOutput(data: any): any; + function pubKeyHashInput(signature: any, pubKey: any, ...args: any[]): any; + function pubKeyHashOutput(pubKeyHash: any): any; + function pubKeyInput(signature: any): any; + function pubKeyOutput(pubKey: any): any; + function scriptHashInput(scriptSig: any, scriptPubKey: any): any; + function scriptHashOutput(scriptHash: any): any; + function toASM(chunks: any): any; + function witnessPubKeyHashOutput(pubKeyHash: any): any; + function witnessScriptHashInput(scriptSig: any, scriptPubKey: any): any; + function witnessScriptHashOutput(scriptHash: any): any; + namespace number { + function decode(buffer: any, maxLength: any, minimal: any): any; + function encode(number: any): any; + } +} diff --git a/bitcoinjs-lib/tsconfig.json b/bitcoinjs-lib/tsconfig.json new file mode 100644 index 0000000000..280b41d50e --- /dev/null +++ b/bitcoinjs-lib/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "bitcoinjs-lib-tests.ts" + ] +} diff --git a/bitcoinjs-lib/tslint.json b/bitcoinjs-lib/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/bitcoinjs-lib/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/blacklist/blacklist-tests.ts b/blacklist/blacklist-tests.ts new file mode 100644 index 0000000000..daff924403 --- /dev/null +++ b/blacklist/blacklist-tests.ts @@ -0,0 +1,13 @@ +var someInput = { a: 1, b: 2, c: 3 } + +import blacklist = require('blacklist') + +blacklist(someInput, 'b', 'c') +// => { a: 1 } + +blacklist(someInput, { + a: true, // a will not be in the result + b: false, // b will be in the result + c: 1 > 2 // false, therefore c will be in the result +}) +// => { b: 2, c: 3 } \ No newline at end of file diff --git a/blacklist/index.d.ts b/blacklist/index.d.ts new file mode 100644 index 0000000000..b3c9d14270 --- /dev/null +++ b/blacklist/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for blacklist 1.1 +// Project: https://github.com/dcousens/blacklist +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = blacklist; +declare function blacklist(src: any, ...args: string[]): any; +declare function blacklist(src: any, spec: { [x: string]: boolean }): any; diff --git a/blacklist/tsconfig.json b/blacklist/tsconfig.json new file mode 100644 index 0000000000..5132449aaf --- /dev/null +++ b/blacklist/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "blacklist-tests.ts" + ] +} diff --git a/blacklist/tslint.json b/blacklist/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/blacklist/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/camelcase-keys/camelcase-keys-tests.ts b/camelcase-keys/camelcase-keys-tests.ts new file mode 100644 index 0000000000..2e8d7ab2d7 --- /dev/null +++ b/camelcase-keys/camelcase-keys-tests.ts @@ -0,0 +1,10 @@ +import camelcaseKeys = require('camelcase-keys'); + +camelcaseKeys({'foo-bar': true}); +//=> {fooBar: true} + +camelcaseKeys({'foo-bar': true, nested: {unicorn_rainbow: true}}, {deep: true}); +//=> {fooBar: true, nested: {unicornRainbow: true}} + +camelcaseKeys({_: [], 'foo-bar': true}); +//=> {_: [], fooBar: true} \ No newline at end of file diff --git a/camelcase-keys/index.d.ts b/camelcase-keys/index.d.ts new file mode 100644 index 0000000000..f6be6b7f03 --- /dev/null +++ b/camelcase-keys/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for camelcase-keys 4.0 +// Project: https://github.com/sindresorhus/camelcase-keys#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = camelcaseKeys; +declare function camelcaseKeys(input: any, options?: { exclude?: string[] | RegExp[], deep?: boolean }): any; diff --git a/camelcase-keys/tsconfig.json b/camelcase-keys/tsconfig.json new file mode 100644 index 0000000000..e7b25d69e5 --- /dev/null +++ b/camelcase-keys/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "camelcase-keys-tests.ts" + ] +} diff --git a/camelcase-keys/tslint.json b/camelcase-keys/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/camelcase-keys/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/checkstyle-formatter/index.d.ts b/checkstyle-formatter/index.d.ts new file mode 100644 index 0000000000..63a5296a69 --- /dev/null +++ b/checkstyle-formatter/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for checkstyle-formatter 1.0 +// Project: https://github.com/jimf/checkstyle-formatter +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = checkstyle_formatter; +declare function checkstyle_formatter(results: any): string; diff --git a/checkstyle-formatter/tsconfig.json b/checkstyle-formatter/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/checkstyle-formatter/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/checkstyle-formatter/tslint.json b/checkstyle-formatter/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/checkstyle-formatter/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/coinstring/coinstring-tests.ts b/coinstring/coinstring-tests.ts new file mode 100644 index 0000000000..ad1312d652 --- /dev/null +++ b/coinstring/coinstring-tests.ts @@ -0,0 +1,69 @@ +/// + +import cs = require('coinstring') + + +var privateKeyHex = "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd" +var privateKeyHexBuf = new Buffer(privateKeyHex, 'hex') +var version = 0x80; //Bitcoin private key + +console.log(cs.encode(privateKeyHexBuf, version)) +// => 5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD + +var hash160 = "3c176e659bea0f29a3e9bf7880c112b1b31b4dc8" //hash representing uncompressed +var hash160Buf = new Buffer(hash160, 'hex') +var version = 0x00; //Bitcoin public address + +console.log(cs.encode(hash160Buf, version)); +// => 16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS + +var privateKeyHex = "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd" + +//for compressed, append "01" +privateKeyHex += '01' + +var privateKeyHexBuf = new Buffer(privateKeyHex, 'hex') +var version = 0x80 //Bitcoin private key + +console.log(cs.encode(privateKeyHexBuf, version)) +// => KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5auC2qc3 + +var hash160 = "3c176e659bea0f29a3e9bf7880c112b1b31b4dc8" //hash representing uncompressed +var hash160Buf = new Buffer(hash160, 'hex') +var version = 0x1E //Dogecoin public address + +console.log(cs.encode(hash160Buf, version)) +// => DAcq9oJpZZAjr56RmF7Y5zmWboZWQ4HAsW + + +var data = "000000000000000000873dff81c02f525623fd1fe5167eac3a55a049de3d314bb42ee227ffed37d50800e8f32e723decf4051aefac8e2c93c9c5b214313817cdb01a1494b917c8436b35" +var buffer = new Buffer(data, 'hex') +var versionBuffer = new Buffer('0488ade4', 'hex') //0488ade4 is a consant listed in the aforementioned bip32 wiki. + +console.log(cs.encode(buffer, versionBuffer)) +// => xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi + + +var privateKeyHex = "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd"; +var privateKeyHexBuf = new Buffer(privateKeyHex, 'hex') +var version = 0x80 //Bitcoin private key + +var toBtcWif = cs.createEncoder(version) + +//later in your program +console.log(toBtcWif(privateKeyHexBuf)) +// => 5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD + + +var wif = "5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD" +var version = 0x80 //Bitcoin private key + +var fromBtcWif = cs.createDecoder(version) + + +var hash160 = "3c176e659bea0f29a3e9bf7880c112b1b31b4dc8" //hash representing uncompressed +var hash160Buf = new Buffer(hash160, 'hex') +var version = 0x6F //Bitcoin Testnet Address + +var testnetAddressValidator = cs.createValidator(version) +console.log(testnetAddressValidator("mkzgubTA5Ahi6BPSkE6MN9pEafRutznkMe")) // => true \ No newline at end of file diff --git a/coinstring/index.d.ts b/coinstring/index.d.ts new file mode 100644 index 0000000000..f7a061fd73 --- /dev/null +++ b/coinstring/index.d.ts @@ -0,0 +1,13 @@ +// Type definitions for coinstring 2.3 +// Project: https://github.com/cryptocoinjs/coinstring +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +export function createDecoder(version: number): (base58str: string, version?: number | Buffer) => Buffer; +export function createEncoder(version: number): (payload: Buffer | number[] | Uint8Array, version?: number | Buffer) => string; +export function createValidator(version: number): (base58str: string, version?: number | Buffer) => boolean; +export function decode(base58str: string, version?: number | Buffer): Buffer; +export function encode(payload: Buffer | number[] | Uint8Array, version?: number| Buffer): string; +export function isValid(base58str: string, version?: number | Buffer): boolean; diff --git a/coinstring/tsconfig.json b/coinstring/tsconfig.json new file mode 100644 index 0000000000..bf0c095e30 --- /dev/null +++ b/coinstring/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "coinstring-tests.ts" + ] +} diff --git a/coinstring/tslint.json b/coinstring/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/coinstring/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/cpy/cpy-tests.ts b/cpy/cpy-tests.ts new file mode 100644 index 0000000000..047c9943bf --- /dev/null +++ b/cpy/cpy-tests.ts @@ -0,0 +1,10 @@ +import cpy = require('cpy'); + +cpy(['src/*.png', '!src/goat.png'], 'dist').then(() => { + console.log('files copied'); +}); + + +cpy('foo.js', 'destination', { + rename: basename => `prefix-${basename}` +}); \ No newline at end of file diff --git a/cpy/index.d.ts b/cpy/index.d.ts new file mode 100644 index 0000000000..039d0b84fb --- /dev/null +++ b/cpy/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for cpy 5.0 +// Project: https://github.com/sindresorhus/cpy#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = cpy; +declare function cpy(src: string | string[], dest: string, opts?: { cwd?: string, parents?: boolean, rename?: (s: string) => string }): Promise; diff --git a/cpy/tsconfig.json b/cpy/tsconfig.json new file mode 100644 index 0000000000..10d0fca79e --- /dev/null +++ b/cpy/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cpy-tests.ts" + ] +} diff --git a/cpy/tslint.json b/cpy/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/cpy/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/currency-formatter/currencies.d.ts b/currency-formatter/currencies.d.ts new file mode 100644 index 0000000000..163bd578de --- /dev/null +++ b/currency-formatter/currencies.d.ts @@ -0,0 +1,2 @@ +import { currencies } from "./index"; +export = currencies; \ No newline at end of file diff --git a/currency-formatter/currency-formatter-tests.ts b/currency-formatter/currency-formatter-tests.ts new file mode 100644 index 0000000000..a64b9bc48f --- /dev/null +++ b/currency-formatter/currency-formatter-tests.ts @@ -0,0 +1,47 @@ +import currencyFormatter = require('currency-formatter'); + +currencyFormatter.format(1000000, { code: 'USD' }); +// => '$1,000,000.00' + +currencyFormatter.format(1000000, { code: 'GBP' }); +// => '£1,000,000.00' + +currencyFormatter.format(1000000, { code: 'EUR' }); +// => '1 000 000,00 €' + +currencyFormatter.findCurrency('USD'); +// returns: +// { +// code: 'USD', +// symbol: '$', +// thousandsSeparator: ',', +// decimalSeparator: '.', +// symbolOnLeft: true, +// spaceBetweenAmountAndSymbol: false, +// decimalDigits: 2 +// } + +currencyFormatter.format(1000000, { + symbol: '@', + decimal: '*', + thousand: '^', + precision: 1, + format: '%v %s' // %s is the symbol and %v is the value +}); + +// => '1^000^000*0 @' + +// Different formatting for positive and negative values +currencyFormatter.format(-10, { + format: { + pos: '%s%v', // %s is the symbol and %v is the value + neg: '(%s%v)', + zero: '%s%v' + } +}); + +// => ($10) + + +import currencies = require('currency-formatter/currencies'); +currencies === currencyFormatter.currencies; diff --git a/currency-formatter/index.d.ts b/currency-formatter/index.d.ts new file mode 100644 index 0000000000..67591738ab --- /dev/null +++ b/currency-formatter/index.d.ts @@ -0,0 +1,30 @@ +// Type definitions for currency-formatter 1.0 +// Project: https://github.com/smirzaei/currency-formatter#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Currency { + code: string; + decimalDigits: number; + decimalSeparator: string; + spaceBetweenAmountAndSymbol: boolean; + symbol: string; + symbolOnLeft: boolean; + thousandsSeparator: string; +} + +export const currencies: Currency[]; +export const defaultCurrency: Currency; +export function findCurrency(currencyCode: string): Currency; +export function format(value: number, options: { + code?: string, + symbol?: string, + decimal?: string, + thousand?: string, + precision?: number, + format?: string | { + pos: string, + neg: string, + zero: string + } +}): string; diff --git a/currency-formatter/tsconfig.json b/currency-formatter/tsconfig.json new file mode 100644 index 0000000000..ef7acd7ccf --- /dev/null +++ b/currency-formatter/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "currencies.d.ts", + "currency-formatter-tests.ts" + ] +} diff --git a/currency-formatter/tslint.json b/currency-formatter/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/currency-formatter/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/deep-freeze-strict/index.d.ts b/deep-freeze-strict/index.d.ts new file mode 100644 index 0000000000..ecb7958e8c --- /dev/null +++ b/deep-freeze-strict/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for deep-freeze-strict 1.1 +// Project: https://github.com/jsdf/deep-freeze +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = deepFreezeStrict; +declare function deepFreezeStrict(o: T): T; diff --git a/deep-freeze-strict/tsconfig.json b/deep-freeze-strict/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/deep-freeze-strict/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/deep-freeze-strict/tslint.json b/deep-freeze-strict/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/deep-freeze-strict/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/ecurve/ecurve-tests.ts b/ecurve/ecurve-tests.ts new file mode 100644 index 0000000000..1c73a7e648 --- /dev/null +++ b/ecurve/ecurve-tests.ts @@ -0,0 +1,55 @@ +/// + +import ecurve = require('ecurve'); +import crypto = require('crypto'); + +import BigInteger = require('bigi'); +import cs = require('coinstring'); + + +var ecparams = ecurve.getCurveByName('secp256k1') +console.log(ecparams.n.toString(16)) +// => fffffffffffffffffffffffffffffffebaaedce6af48a03bbfd25e8cd0364141 +console.log(ecparams.G.getEncoded().toString('hex')) //getEncoded() returns type 'Buffer' instead of 'BigInteger' +// => 0279be667ef9dcbbac55a06295ce870b07029bfcdb2dce28d959f2815b16f81798 +console.log(ecparams.h.toString(16)) +// => 1 + + +var privateKey = new Buffer("1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd", 'hex') + +var ecparams = ecurve.getCurveByName('secp256k1') +var curvePt = ecparams.G.multiply(BigInteger.fromBuffer(privateKey)) +var x = curvePt.affineX.toBuffer(32) +var y = curvePt.affineY.toBuffer(32) + +var publicKey = Buffer.concat([new Buffer([0x04]), x, y]) +console.log(publicKey.toString('hex')) +// => 04d0988bfa799f7d7ef9ab3de97ef481cd0f75d2367ad456607647edde665d6f6fbdd594388756a7beaf73b4822bc22d36e9bda7db82df2b8b623673eefc0b7495 + +//alternatively +publicKey = curvePt.getEncoded(false) //false forces uncompressed public key +console.log(publicKey.toString('hex')) +// => 04d0988bfa799f7d7ef9ab3de97ef481cd0f75d2367ad456607647edde665d6f6fbdd594388756a7beaf73b4822bc22d36e9bda7db82df2b8b623673eefc0b7495 + +//want compressed? +publicKey = curvePt.getEncoded(true) //true forces compressed public key +console.log(publicKey.toString('hex')) +// => 03d0988bfa799f7d7ef9ab3de97ef481cd0f75d2367ad456607647edde665d6f6f + +var sha = crypto.createHash('sha256').update(publicKey).digest() +var pubkeyHash = crypto.createHash('rmd160').update(sha).digest() + +// pubkeyHash of compressed public key +console.log(pubkeyHash.toString('hex')) +// => a1c2f92a9dacbd2991c3897724a93f338e44bdc1 + +// address of compressed public key +console.log(cs.encode(pubkeyHash, 0x0)) //<-- 0x0 is for public addresses +// => 1FkKMsKNJqWSDvTvETqcCeHcUQQ64kSC6s + +console.log(cs.encode(privateKey, 0x80)) //<--- 0x80 is for private addresses +// => 5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD + +console.log(cs.encode(Buffer.concat([privateKey, new Buffer([0])]), 0x80)) // <-- compressed private address +// => KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5aqzCxDY \ No newline at end of file diff --git a/ecurve/index.d.ts b/ecurve/index.d.ts new file mode 100644 index 0000000000..9eaacac688 --- /dev/null +++ b/ecurve/index.d.ts @@ -0,0 +1,41 @@ +// Type definitions for ecurve 1.0 +// Project: https://github.com/cryptocoinjs/ecurve#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +/// + +import BigInteger = require('bigi'); + +export class Curve { + p: BigInteger; + a: BigInteger; + b: BigInteger; + G: Point; + n: BigInteger; + h: BigInteger; + constructor(p: BigInteger, a: BigInteger, b: BigInteger, Gx: BigInteger, Gy: BigInteger, n: BigInteger, h: BigInteger); + isInfinity(Q: any): boolean; + isOnCurve(Q: any): boolean; + pointFromX(isOdd: boolean, x: Point): Point; + validate(Q: any): boolean; +} +export class Point { + x: BigInteger; + y: BigInteger; + z: BigInteger; + affineX: BigInteger; + affineY: BigInteger; + constructor(curve: Curve, x: BigInteger, y: BigInteger, z: BigInteger); + add(b: Point): Point; + equals(other: Point): boolean; + getEncoded(compressed?: boolean): Buffer; + multiply(k: any): Point; + multiplyTwo(j: any, x: any, k: any): Point; + negate(): Point; + toString(): string; + twice(): Point; + static decodeFrom(curve: Curve, buffer: Buffer): any; + static fromAffine(curve: Curve, x: BigInteger, y: BigInteger): Point; +} +export function getCurveByName(name: string): Curve; diff --git a/ecurve/tsconfig.json b/ecurve/tsconfig.json new file mode 100644 index 0000000000..125dfbe787 --- /dev/null +++ b/ecurve/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "ecurve-tests.ts" + ] +} diff --git a/ecurve/tslint.json b/ecurve/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/ecurve/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/fuzzaldrin/index.d.ts b/fuzzaldrin/index.d.ts new file mode 100644 index 0000000000..1e1427c08f --- /dev/null +++ b/fuzzaldrin/index.d.ts @@ -0,0 +1,8 @@ +// Type definitions for fuzzaldrin 2.1 +// Project: https://github.com/atom/fuzzaldrin +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export function filter(candidates: T[], query: string, options?: { key?: string, maxResults?: number }): T[]; +export function match(string: string, query: string): any; +export function score(string: string, query: string): number; diff --git a/fuzzaldrin/tsconfig.json b/fuzzaldrin/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/fuzzaldrin/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/fuzzaldrin/tslint.json b/fuzzaldrin/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/fuzzaldrin/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/http-codes/index.d.ts b/http-codes/index.d.ts new file mode 100644 index 0000000000..e106812f0c --- /dev/null +++ b/http-codes/index.d.ts @@ -0,0 +1,67 @@ +// Type definitions for http-codes 1.0 +// Project: https://github.com/flesler/node-http-codes +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export declare const ACCEPTED: number; +export declare const ALREADY_REPORTED: number; +export declare const BAD_GATEWAY: number; +export declare const BAD_REQUEST: number; +export declare const BANDWIDTH_LIMIT_EXCEEDED: number; +export declare const CONFLICT: number; +export declare const CONTINUE: number; +export declare const CREATED: number; +export declare const EXPECTATION_FAILED: number; +export declare const FAILED_DEPENDENCY: number; +export declare const FORBIDDEN: number; +export declare const FOUND: number; +export declare const GATEWAY_TIMEOUT: number; +export declare const GONE: number; +export declare const HTTP_VERSION_NOT_SUPPORTED: number; +export declare const IM_A_TEAPOT: number; +export declare const IM_USED: number; +export declare const INSUFFICIENT_STORAGE: number; +export declare const INTERNAL_SERVER_ERROR: number; +export declare const LENGTH_REQUIRED: number; +export declare const LOCKED: number; +export declare const LOOP_DETECTED: number; +export declare const METHOD_NOT_ALLOWED: number; +export declare const MISDIRECTED_REQUEST: number; +export declare const MOVED_PERMANENTLY: number; +export declare const MULTIPLE_CHOICES: number; +export declare const MULTI_STATUS: number; +export declare const NETWORK_AUTHENTICATION_REQUIRED: number; +export declare const NON_AUTHORITATIVE_INFORMATION: number; +export declare const NOT_ACCEPTABLE: number; +export declare const NOT_EXTENDED: number; +export declare const NOT_FOUND: number; +export declare const NOT_IMPLEMENTED: number; +export declare const NOT_MODIFIED: number; +export declare const NO_CONTENT: number; +export declare const OK: number; +export declare const PARTIAL_CONTENT: number; +export declare const PAYLOAD_TOO_LARGE: number; +export declare const PAYMENT_REQUIRED: number; +export declare const PERMANENT_REDIRECT: number; +export declare const PRECONDITION_FAILED: number; +export declare const PRECONDITION_REQUIRED: number; +export declare const PROCESSING: number; +export declare const PROXY_AUTHENTICATION_REQUIRED: number; +export declare const RANGE_NOT_SATISFIABLE: number; +export declare const REQUEST_HEADER_FIELDS_TOO_LARGE: number; +export declare const REQUEST_TIMEOUT: number; +export declare const RESET_CONTENT: number; +export declare const SEE_OTHER: number; +export declare const SERVICE_UNAVAILABLE: number; +export declare const SWITCHING_PROTOCOLS: number; +export declare const TEMPORARY_REDIRECT: number; +export declare const TOO_MANY_REQUESTS: number; +export declare const UNAUTHORIZED: number; +export declare const UNAVAILABLE_FOR_LEGAL_REASONS: number; +export declare const UNORDERED_COLLECTION: number; +export declare const UNPROCESSABLE_ENTITY: number; +export declare const UNSUPPORTED_MEDIA_TYPE: number; +export declare const UPGRADE_REQUIRED: number; +export declare const URI_TOO_LONG: number; +export declare const USE_PROXY: number; +export declare const VARIANT_ALSO_NEGOTIATES: number; diff --git a/http-codes/tsconfig.json b/http-codes/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/http-codes/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/http-codes/tslint.json b/http-codes/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/http-codes/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/indent-string/indent-string-tests.ts b/indent-string/indent-string-tests.ts new file mode 100644 index 0000000000..ea473a2814 --- /dev/null +++ b/indent-string/indent-string-tests.ts @@ -0,0 +1,9 @@ +import indentString = require('indent-string'); + +indentString('Unicorns\nRainbows', 4); +//=> ' Unicorns' +//=> ' Rainbows' + +indentString('Unicorns\nRainbows', 4, '♥'); +//=> '♥♥♥♥Unicorns' +//=> '♥♥♥♥Rainbows' \ No newline at end of file diff --git a/indent-string/index.d.ts b/indent-string/index.d.ts new file mode 100644 index 0000000000..5d4a01b7eb --- /dev/null +++ b/indent-string/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for indent-string 3.0 +// Project: https://github.com/sindresorhus/indent-string#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = indent_string; +declare function indent_string(str: string, count: number, indent?: string): string; diff --git a/indent-string/tsconfig.json b/indent-string/tsconfig.json new file mode 100644 index 0000000000..6e2b6f011d --- /dev/null +++ b/indent-string/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "indent-string-tests.ts" + ] +} diff --git a/indent-string/tslint.json b/indent-string/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/indent-string/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/intl-messageformat/index.d.ts b/intl-messageformat/index.d.ts new file mode 100644 index 0000000000..9dccb6056a --- /dev/null +++ b/intl-messageformat/index.d.ts @@ -0,0 +1,51 @@ +// Type definitions for intl-messageformat 1.3 +// Project: https://github.com/yahoo/intl-messageformat +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = IntlMessageFormat; +export as namespace IntlMessageFormat; + +interface DateFormat { + day: string; + month: string; + weekday: string; + year: string; +} + +interface TimeFormat { + hour: string; + minute: string; + second: string; + timeZoneName: string; +} + +declare class IntlMessageFormat { + constructor(message: string, locales: string | string[], formats?: any); + resolvedOptions(): { locale: string }; + format(arg: any): string; + static default: any; + static defaultLocale: string; + static formats: { + date: { + full: DateFormat; + long: DateFormat; + medium: DateFormat; + short: DateFormat; + }; + number: { + currency: { + style: string; + }; + percent: { + style: string; + }; + }; + time: { + full: TimeFormat; + long: TimeFormat; + medium: TimeFormat; + short: TimeFormat; + }; + }; +} diff --git a/intl-messageformat/intl-messageformat-tests.ts b/intl-messageformat/intl-messageformat-tests.ts new file mode 100644 index 0000000000..e758210bbf --- /dev/null +++ b/intl-messageformat/intl-messageformat-tests.ts @@ -0,0 +1,45 @@ +import IntlMessageFormat = require("intl-messageformat"); + + +var msg = new IntlMessageFormat("message", "en-us"); + + +var output = msg.format({name: "Eric"}); +console.log(output); // => "My name is Eric." + +var MESSAGES = { + 'en-US': { + NUM_PHOTOS: 'You have {numPhotos, plural, ' + + '=0 {no photos.}' + + '=1 {one photo.}' + + 'other {# photos.}}' + }, + + 'es-MX': { + NUM_PHOTOS: 'Usted {numPhotos, plural, ' + + '=0 {no tiene fotos.}' + + '=1 {tiene una foto.}' + + 'other {tiene # fotos.}}' + } +}; + +var enNumPhotos = new IntlMessageFormat(MESSAGES['en-US'].NUM_PHOTOS, 'en-US'); +output = enNumPhotos.format({numPhotos: 1000}); +console.log(output); // => "You have 1,000 photos." + +var esNumPhotos = new IntlMessageFormat(MESSAGES['es-MX'].NUM_PHOTOS, 'es-MX'); +output = esNumPhotos.format({numPhotos: 1000}); +console.log(output); // => "Usted tiene 1,000 fotos." + + +var msg = new IntlMessageFormat('The price is: {price, number, USD}', 'en-US', { + number: { + USD: { + style : 'currency', + currency: 'USD' + } + } +}); + +var output = msg.format({price: 100}); +console.log(output); // => "The price is: $100.00" \ No newline at end of file diff --git a/intl-messageformat/tsconfig.json b/intl-messageformat/tsconfig.json new file mode 100644 index 0000000000..066dcd175c --- /dev/null +++ b/intl-messageformat/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "intl-messageformat-tests.ts" + ] +} diff --git a/intl-messageformat/tslint.json b/intl-messageformat/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/intl-messageformat/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-absolute-url/index.d.ts b/is-absolute-url/index.d.ts new file mode 100644 index 0000000000..eecb3998e0 --- /dev/null +++ b/is-absolute-url/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-absolute-url 2.1 +// Project: https://github.com/sindresorhus/is-absolute-url#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_absolute_url; +declare function is_absolute_url(url: string): boolean; diff --git a/is-absolute-url/is-absolute-url-tests.ts b/is-absolute-url/is-absolute-url-tests.ts new file mode 100644 index 0000000000..8ddf3e2514 --- /dev/null +++ b/is-absolute-url/is-absolute-url-tests.ts @@ -0,0 +1,10 @@ +import isAbsoluteUrl = require('is-absolute-url'); + +isAbsoluteUrl('http://sindresorhus.com/foo/bar'); +//=> true + +isAbsoluteUrl('//sindresorhus.com'); +//=> false + +isAbsoluteUrl('foo/bar'); +//=> false \ No newline at end of file diff --git a/is-absolute-url/tsconfig.json b/is-absolute-url/tsconfig.json new file mode 100644 index 0000000000..56363cd768 --- /dev/null +++ b/is-absolute-url/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-absolute-url-tests.ts" + ] +} diff --git a/is-absolute-url/tslint.json b/is-absolute-url/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-absolute-url/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-archive/index.d.ts b/is-archive/index.d.ts new file mode 100644 index 0000000000..58b6ed8324 --- /dev/null +++ b/is-archive/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-archive 1.0 +// Project: https://github.com/sindresorhus/is-archive +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_archive; +declare function is_archive(filepath: string): boolean; diff --git a/is-archive/is-archive-tests.ts b/is-archive/is-archive-tests.ts new file mode 100644 index 0000000000..30be8dc06e --- /dev/null +++ b/is-archive/is-archive-tests.ts @@ -0,0 +1,7 @@ +import isArchive = require('is-archive'); + +isArchive('src/unicorn.zip'); +//=> true + +isArchive('src/unicorn.txt'); +//=> false \ No newline at end of file diff --git a/is-archive/tsconfig.json b/is-archive/tsconfig.json new file mode 100644 index 0000000000..7c4fa0a536 --- /dev/null +++ b/is-archive/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-archive-tests.ts" + ] +} diff --git a/is-archive/tslint.json b/is-archive/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-archive/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-compressed/index.d.ts b/is-compressed/index.d.ts new file mode 100644 index 0000000000..617d40a51b --- /dev/null +++ b/is-compressed/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-compressed 1.0 +// Project: https://github.com/sindresorhus/is-compressed +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_compressed; +declare function is_compressed(filepath: string): boolean; diff --git a/is-compressed/is-compressed-tests.ts b/is-compressed/is-compressed-tests.ts new file mode 100644 index 0000000000..11a2e67294 --- /dev/null +++ b/is-compressed/is-compressed-tests.ts @@ -0,0 +1,7 @@ +import isCompressed = require('is-compressed'); + +isCompressed('src/unicorn.zip'); +//=> true + +isCompressed('src/unicorn.txt'); +//=> false \ No newline at end of file diff --git a/is-compressed/tsconfig.json b/is-compressed/tsconfig.json new file mode 100644 index 0000000000..3cb6f8603c --- /dev/null +++ b/is-compressed/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-compressed-tests.ts" + ] +} diff --git a/is-compressed/tslint.json b/is-compressed/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-compressed/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-finite/index.d.ts b/is-finite/index.d.ts new file mode 100644 index 0000000000..e70bd80168 --- /dev/null +++ b/is-finite/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-finite 1.0 +// Project: https://github.com/sindresorhus/is-finite#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_finite; +declare function is_finite(p0: any): boolean; diff --git a/is-finite/tsconfig.json b/is-finite/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/is-finite/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/is-finite/tslint.json b/is-finite/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-finite/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-path-in-cwd/index.d.ts b/is-path-in-cwd/index.d.ts new file mode 100644 index 0000000000..ebf748a38e --- /dev/null +++ b/is-path-in-cwd/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-path-in-cwd 1.0 +// Project: https://github.com/sindresorhus/is-path-in-cwd +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_path_in_cwd; +declare function is_path_in_cwd(str: string): boolean; diff --git a/is-path-in-cwd/tsconfig.json b/is-path-in-cwd/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/is-path-in-cwd/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/is-path-in-cwd/tslint.json b/is-path-in-cwd/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-path-in-cwd/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-relative-url/index.d.ts b/is-relative-url/index.d.ts new file mode 100644 index 0000000000..ac28dc0d9f --- /dev/null +++ b/is-relative-url/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-relative-url 2.0 +// Project: https://github.com/sindresorhus/is-relative-url +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_relative_url; +declare function is_relative_url(url: string): boolean; diff --git a/is-relative-url/is-relative-url-tests.ts b/is-relative-url/is-relative-url-tests.ts new file mode 100644 index 0000000000..293c621872 --- /dev/null +++ b/is-relative-url/is-relative-url-tests.ts @@ -0,0 +1,10 @@ +import isRelativeUrl = require('is-relative-url'); + +isRelativeUrl('foo/bar'); +//=> true + +isRelativeUrl('http://sindresorhus.com/foo/bar'); +//=> false + +isRelativeUrl('//sindresorhus.com'); +//=> true \ No newline at end of file diff --git a/is-relative-url/tsconfig.json b/is-relative-url/tsconfig.json new file mode 100644 index 0000000000..6d27996149 --- /dev/null +++ b/is-relative-url/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-relative-url-tests.ts" + ] +} diff --git a/is-relative-url/tslint.json b/is-relative-url/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-relative-url/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-root-path/index.d.ts b/is-root-path/index.d.ts new file mode 100644 index 0000000000..00266378ce --- /dev/null +++ b/is-root-path/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-root-path 1.0 +// Project: https://github.com/sindresorhus/is-root-path#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_root_path; +declare function is_root_path(pth: string): boolean; diff --git a/is-root-path/is-root-path-tests.ts b/is-root-path/is-root-path-tests.ts new file mode 100644 index 0000000000..0a577aee5a --- /dev/null +++ b/is-root-path/is-root-path-tests.ts @@ -0,0 +1,7 @@ +import isRootPath = require('is-root-path'); + +isRootPath('/'); +//=> true + +isRootPath('/Users'); +//=> false \ No newline at end of file diff --git a/is-root-path/tsconfig.json b/is-root-path/tsconfig.json new file mode 100644 index 0000000000..d48e0020f4 --- /dev/null +++ b/is-root-path/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-root-path-tests.ts" + ] +} diff --git a/is-root-path/tslint.json b/is-root-path/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-root-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-root/index.d.ts b/is-root/index.d.ts new file mode 100644 index 0000000000..af91c74ff2 --- /dev/null +++ b/is-root/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-root 1.0 +// Project: https://github.com/sindresorhus/is-root +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_root; +declare function is_root(): boolean; diff --git a/is-root/is-root-tests.ts b/is-root/is-root-tests.ts new file mode 100644 index 0000000000..42fc3ee4f3 --- /dev/null +++ b/is-root/is-root-tests.ts @@ -0,0 +1,5 @@ +// index.js +import isRoot = require('is-root'); + +isRoot(); +//=> true \ No newline at end of file diff --git a/is-root/tsconfig.json b/is-root/tsconfig.json new file mode 100644 index 0000000000..65a451e878 --- /dev/null +++ b/is-root/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-root-tests.ts" + ] +} diff --git a/is-root/tslint.json b/is-root/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-root/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/is-text-path/index.d.ts b/is-text-path/index.d.ts new file mode 100644 index 0000000000..997b94ab7d --- /dev/null +++ b/is-text-path/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for is-text-path 1.0 +// Project: https://github.com/sindresorhus/is-text-path +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = is_text_path; +declare function is_text_path(filepath: string): boolean; diff --git a/is-text-path/is-text-path-tests.ts b/is-text-path/is-text-path-tests.ts new file mode 100644 index 0000000000..cd71933ec2 --- /dev/null +++ b/is-text-path/is-text-path-tests.ts @@ -0,0 +1,7 @@ +import isTextPath = require('is-text-path'); + +isTextPath('src/unicorn.txt'); +//=> true + +isTextPath('src/unicorn.png'); +//=> false \ No newline at end of file diff --git a/is-text-path/tsconfig.json b/is-text-path/tsconfig.json new file mode 100644 index 0000000000..f56c2f4a4f --- /dev/null +++ b/is-text-path/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "is-text-path-tests.ts" + ] +} diff --git a/is-text-path/tslint.json b/is-text-path/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/is-text-path/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/multi-typeof/index.d.ts b/multi-typeof/index.d.ts new file mode 100644 index 0000000000..26477f1061 --- /dev/null +++ b/multi-typeof/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for multi-typeof 1.0 +// Project: https://github.com/gillstrom/multi-typeof#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = multi_typeof; +declare function multi_typeof(input: any, types: string[]): boolean; diff --git a/multi-typeof/tsconfig.json b/multi-typeof/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/multi-typeof/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/multi-typeof/tslint.json b/multi-typeof/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/multi-typeof/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/node-hid/index.d.ts b/node-hid/index.d.ts new file mode 100644 index 0000000000..7c04487b37 --- /dev/null +++ b/node-hid/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for node-hid 0.5 +// Project: https://github.com/node-hid/node-hid#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +interface Device { + vendorId: number; + productId: number; + path: string; + serialNumber: string; + manufacturer: string; + product: string; + release: number; + interface: number; +} + +export class HID { + constructor(path: string); + constructor(vid: number, pid: number); + close(): void; + pause(): void; + read(callback: (value: any, err: any) => void): any; + readSync(): number[]; + readTimeout(time_out: number): number[]; + sendFeatureReport(data: number[]): void; + getFeatureReport(report_id: number, report_length: number): number[]; + resume(): void; + on(event: string, handler: (value: any) => void): void; + write(values: number[]): void; +} +export function devices(): Device[]; diff --git a/node-hid/node-hid-tests.ts b/node-hid/node-hid-tests.ts new file mode 100644 index 0000000000..15bc71b7d1 --- /dev/null +++ b/node-hid/node-hid-tests.ts @@ -0,0 +1,13 @@ +import HID = require('node-hid'); + +var devices = HID.devices() + + +var device = new HID.HID("path"); + +var device = new HID.HID(12, 22); + +device.on("data", function (data) { }); +device.on("error", function (err) { }); + +device.write([0x00, 0x01, 0x01, 0x05, 0xff, 0xff]); \ No newline at end of file diff --git a/node-hid/tsconfig.json b/node-hid/tsconfig.json new file mode 100644 index 0000000000..0f9e2fa1ce --- /dev/null +++ b/node-hid/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "node-hid-tests.ts" + ] +} diff --git a/node-hid/tslint.json b/node-hid/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/node-hid/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/number-is-nan/index.d.ts b/number-is-nan/index.d.ts new file mode 100644 index 0000000000..ee163c30a2 --- /dev/null +++ b/number-is-nan/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for number-is-nan 1.0 +// Project: https://github.com/sindresorhus/number-is-nan#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = number_is_nan; +declare function number_is_nan(p0: number): boolean; diff --git a/number-is-nan/tsconfig.json b/number-is-nan/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/number-is-nan/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/number-is-nan/tslint.json b/number-is-nan/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/number-is-nan/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/os-homedir/index.d.ts b/os-homedir/index.d.ts new file mode 100644 index 0000000000..14067d1ab6 --- /dev/null +++ b/os-homedir/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for os-homedir 1.0 +// Project: https://github.com/sindresorhus/os-homedir#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = os_homedir; +declare function os_homedir(): string; diff --git a/os-homedir/tsconfig.json b/os-homedir/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/os-homedir/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/os-homedir/tslint.json b/os-homedir/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/os-homedir/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/os-tmpdir/index.d.ts b/os-tmpdir/index.d.ts new file mode 100644 index 0000000000..9ce3c88fd7 --- /dev/null +++ b/os-tmpdir/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for os-tmpdir 1.0 +// Project: https://github.com/sindresorhus/os-tmpdir#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = os_tmpdir; +declare function os_tmpdir(): string; diff --git a/os-tmpdir/tsconfig.json b/os-tmpdir/tsconfig.json new file mode 100644 index 0000000000..87eb6217d4 --- /dev/null +++ b/os-tmpdir/tsconfig.json @@ -0,0 +1,19 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts" + ] +} diff --git a/os-tmpdir/tslint.json b/os-tmpdir/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/os-tmpdir/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/pad/index.d.ts b/pad/index.d.ts new file mode 100644 index 0000000000..f169c8b564 --- /dev/null +++ b/pad/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for pad 1.0 +// Project: https://github.com/wdavidw/node-pad#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = pad; + +/** left pad */ +declare function pad(length: number, text: string, options?: { char?: string, colors?: boolean, strip?: boolean }): string; +/** Right pad */ +declare function pad(text: string, length: number, options?: { char?: string, colors?: boolean, strip?: boolean }): string; diff --git a/pad/pad-tests.ts b/pad/pad-tests.ts new file mode 100644 index 0000000000..c808d303df --- /dev/null +++ b/pad/pad-tests.ts @@ -0,0 +1,6 @@ +import pad = require('pad'); + +pad('pad', 5) // "pad " +pad(5, 'pad') // " pad" +pad('pad', 5, '+') // "pad++" +pad(5, 'pad', '+') // "++pad" \ No newline at end of file diff --git a/pad/tsconfig.json b/pad/tsconfig.json new file mode 100644 index 0000000000..3fc7c77057 --- /dev/null +++ b/pad/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "pad-tests.ts" + ] +} diff --git a/pad/tslint.json b/pad/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/pad/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/path-is-absolute/index.d.ts b/path-is-absolute/index.d.ts new file mode 100644 index 0000000000..c930c2545b --- /dev/null +++ b/path-is-absolute/index.d.ts @@ -0,0 +1,11 @@ +// Type definitions for path-is-absolute 1.0 +// Project: https://github.com/sindresorhus/path-is-absolute#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = path_is_absolute; +declare function path_is_absolute(path: string): boolean; +declare namespace path_is_absolute { + function win32(path: string): boolean; + function posix(path: string): boolean; +} diff --git a/path-is-absolute/path-is-absolute-tests.ts b/path-is-absolute/path-is-absolute-tests.ts new file mode 100644 index 0000000000..fe7d177cc2 --- /dev/null +++ b/path-is-absolute/path-is-absolute-tests.ts @@ -0,0 +1,23 @@ +import pathIsAbsolute = require('path-is-absolute'); + +// Running on Linux +pathIsAbsolute('/home/foo'); +//=> true +pathIsAbsolute('C:/Users/foo'); +//=> false + +// Running on Windows +pathIsAbsolute('C:/Users/foo'); +//=> true +pathIsAbsolute('/home/foo'); +//=> false + +// Running on any OS +pathIsAbsolute.posix('/home/foo'); +//=> true +pathIsAbsolute.posix('C:/Users/foo'); +//=> false +pathIsAbsolute.win32('C:/Users/foo'); +//=> true +pathIsAbsolute.win32('/home/foo'); +//=> false \ No newline at end of file diff --git a/path-is-absolute/tsconfig.json b/path-is-absolute/tsconfig.json new file mode 100644 index 0000000000..38663b8241 --- /dev/null +++ b/path-is-absolute/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "path-is-absolute-tests.ts" + ] +} diff --git a/path-is-absolute/tslint.json b/path-is-absolute/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/path-is-absolute/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/react-body-classname/index.d.ts b/react-body-classname/index.d.ts new file mode 100644 index 0000000000..91c0ccd668 --- /dev/null +++ b/react-body-classname/index.d.ts @@ -0,0 +1,15 @@ +// Type definitions for react-body-classname 1.1 +// Project: https://github.com/PactCoffee/react-body-classname +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import React = require("react"); + +export = BodyClassName; + +declare class BodyClassName extends React.Component<{ className: string }, any> { + static canUseDOM: boolean; + static displayName: string; + static peek(): any; + static rewind(): any; +} \ No newline at end of file diff --git a/react-body-classname/react-body-classname-tests.tsx b/react-body-classname/react-body-classname-tests.tsx new file mode 100644 index 0000000000..7fb971fe44 --- /dev/null +++ b/react-body-classname/react-body-classname-tests.tsx @@ -0,0 +1,26 @@ +import React = require("react"); +import BodyClassName = require("react-body-classname"); + +class SomeComponent { + render() { + // This will add 'home' to the body + return ( + +

Home, sweet home.

+
+ ); + } +} + +class App { + render() { + // This will add 'app' to the body + return ( + +
+ + ); + // Becuase we nested the component, our body will now have 'app home' + // as the class name + } +} \ No newline at end of file diff --git a/react-body-classname/tsconfig.json b/react-body-classname/tsconfig.json new file mode 100644 index 0000000000..da2bf47eb2 --- /dev/null +++ b/react-body-classname/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "jsx": "react", + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-body-classname-tests.tsx" + ] +} diff --git a/react-body-classname/tslint.json b/react-body-classname/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-body-classname/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/react-highlight-words/index.d.ts b/react-highlight-words/index.d.ts new file mode 100644 index 0000000000..a9ccc36fc6 --- /dev/null +++ b/react-highlight-words/index.d.ts @@ -0,0 +1,33 @@ +// Type definitions for react-highlight-words 0.6 +// Project: https://github.com/bvaughn/react-highlight-words#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import React = require("react"); + +export = Highlighter; + +interface HighlighterProps { + /** Escape characters which are meaningful in regular expressions */ + autoEscape?: boolean; + /** Escape characters which are meaningful in regular expressions */ + activeClassName?: string; + /** Specify the match index that should be actively highlighted. Use along with activeClassName */ + activeIndex?: string; + /** CSS class name applied to highlighted text */ + highlightClassName?: string; + /** Inline styles applied to highlighted text */ + highlightStyle?: any; + /** Type of tag to wrap around highlighted matches; defaults to mark */ + highlightTag?: string; + /** Process each search word and text to highlight before comparing (eg remove accents); signature (text: string): string */ + sanitize?: (text: string) => string; + /** Array of search words */ + searchWords: string[]; + /** Text to highlight matches in */ + textToHighlight: string; +} + +declare class Highlighter extends React.Component { + static propTypes: any; +} diff --git a/react-highlight-words/react-highlight-words-tests.tsx b/react-highlight-words/react-highlight-words-tests.tsx new file mode 100644 index 0000000000..e840edfabd --- /dev/null +++ b/react-highlight-words/react-highlight-words-tests.tsx @@ -0,0 +1,9 @@ +import React = require("react"); +import Highlighter = require("react-highlight-words"); + + + \ No newline at end of file diff --git a/react-highlight-words/tsconfig.json b/react-highlight-words/tsconfig.json new file mode 100644 index 0000000000..baa4c9c691 --- /dev/null +++ b/react-highlight-words/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "jsx": "react", + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-highlight-words-tests.tsx" + ] +} diff --git a/react-highlight-words/tslint.json b/react-highlight-words/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-highlight-words/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/react-recaptcha/index.d.ts b/react-recaptcha/index.d.ts new file mode 100644 index 0000000000..d17ed8ef34 --- /dev/null +++ b/react-recaptcha/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for react-recaptcha 2.2 +// Project: https://github.com/appleboy/react-recaptcha +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import { Component } from "react"; +export = Recaptcha; + +interface RecaptchaProps { + className?: string; + elementID?: string; + expiredCallback?: () => any; + expiredCallbackName?: string; + onloadCallback?: () => any; + onloadCallbackName?: string; + render?: string; + size?: string; + tabindex?: string; + theme?: "dark" | "light"; + type?: string; + verifyCallback?: () => any; + verifyCallbackName?: string; + sitekey?: string; +} + +declare class Recaptcha extends Component { + static propTypes: any; + static defaultProps: RecaptchaProps; +} diff --git a/react-recaptcha/react-recaptcha-tests.tsx b/react-recaptcha/react-recaptcha-tests.tsx new file mode 100644 index 0000000000..624020cc62 --- /dev/null +++ b/react-recaptcha/react-recaptcha-tests.tsx @@ -0,0 +1,10 @@ +import Recaptcha = require('react-recaptcha'); +import ReactDOM = require("react-dom"); +import React = require("react"); + +ReactDOM.render( + , + document.getElementById('example') +); \ No newline at end of file diff --git a/react-recaptcha/tsconfig.json b/react-recaptcha/tsconfig.json new file mode 100644 index 0000000000..cdfdfaf376 --- /dev/null +++ b/react-recaptcha/tsconfig.json @@ -0,0 +1,21 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "jsx": "react", + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "react-recaptcha-tests.tsx" + ] +} diff --git a/react-recaptcha/tslint.json b/react-recaptcha/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/react-recaptcha/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/safe-regex/index.d.ts b/safe-regex/index.d.ts new file mode 100644 index 0000000000..582f8fa443 --- /dev/null +++ b/safe-regex/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for safe-regex 1.1 +// Project: https://github.com/substack/safe-regex +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = safe_regex; +declare function safe_regex(re: string | RegExp, opts?: { limit?: number | undefined }): boolean; diff --git a/safe-regex/safe-regex-tests.ts b/safe-regex/safe-regex-tests.ts new file mode 100644 index 0000000000..a3c0b3a420 --- /dev/null +++ b/safe-regex/safe-regex-tests.ts @@ -0,0 +1,2 @@ +import safe = require('safe-regex'); +console.log(safe("regex")); \ No newline at end of file diff --git a/safe-regex/tsconfig.json b/safe-regex/tsconfig.json new file mode 100644 index 0000000000..ff598703d8 --- /dev/null +++ b/safe-regex/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "safe-regex-tests.ts" + ] +} diff --git a/safe-regex/tslint.json b/safe-regex/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/safe-regex/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/slug/index.d.ts b/slug/index.d.ts new file mode 100644 index 0000000000..1a82532473 --- /dev/null +++ b/slug/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for slug 0.9 +// Project: https://github.com/dodo/node-slug +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = slug; + +interface CharMap { + [x: string]: string; +} + +interface Mode { + charmap?: CharMap| null; + lower?: boolean| null; + multicharmap?: CharMap| null; + remove?: RegExp| null; + replacement?: string | null; + symbols?: boolean| null; +} + +declare function slug(string: string, opts?: Mode | string): string; +declare namespace slug { + const charmap: CharMap; + const defaults: { + charmap: CharMap; + mode: string; + modes: { + pretty: Mode; + rfc3986: Mode; + }; + multicharmap: CharMap; + }; + const multicharmap: CharMap; +} diff --git a/slug/slug-tests.ts b/slug/slug-tests.ts new file mode 100644 index 0000000000..101155e3ce --- /dev/null +++ b/slug/slug-tests.ts @@ -0,0 +1,41 @@ +import slug = require('slug') +var print = console.log.bind(console, '>') + +print(slug('i ♥ unicode')) +// > i-love-unicode + +print(slug('unicode ♥ is ☢')) // yes! +// > unicode-love-is-radioactive + +print(slug('i ♥ unicode', '_')) // If you prefer something else then `-` as seperator +// > i_love_unicode + +slug.charmap['♥'] = 'freaking love' // change default charmap or use option {charmap:{…}} as 2. argument +print(slug('I ♥ UNICODE')) +// > I-freaking-love-UNICODE + +print(slug('☏-Number', {lower: true})) // If you prefer lower case +// > telephone-number + +print(slug('i <3 unicode')) +// > i-love-unicode + +// options is either object or replacement (sets options.replacement) +slug('string', { } || 'replacement'); +slug.defaults.mode ='pretty'; +slug.defaults.modes['rfc3986'] = { + replacement: '-', // replace spaces with replacement + symbols: true, // replace unicode symbols or not + remove: null, // (optional) regex to remove characters + lower: true, // result in lower case + charmap: slug.charmap, // replace special characters + multicharmap: slug.multicharmap // replace multi-characters +}; +slug.defaults.modes['pretty'] = { + replacement: '-', + symbols: true, + remove: /[.]/g, + lower: false, + charmap: slug.charmap, + multicharmap: slug.multicharmap +}; \ No newline at end of file diff --git a/slug/tsconfig.json b/slug/tsconfig.json new file mode 100644 index 0000000000..180e505ec6 --- /dev/null +++ b/slug/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "slug-tests.ts" + ] +} diff --git a/slug/tslint.json b/slug/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/slug/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/strip-ansi/index.d.ts b/strip-ansi/index.d.ts new file mode 100644 index 0000000000..c31ee6aa8c --- /dev/null +++ b/strip-ansi/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for strip-ansi 3.0 +// Project: https://github.com/chalk/strip-ansi +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = strip_ansi; +declare function strip_ansi(str: string): string; diff --git a/strip-ansi/strip-ansi-tests.ts b/strip-ansi/strip-ansi-tests.ts new file mode 100644 index 0000000000..6d38a0ed49 --- /dev/null +++ b/strip-ansi/strip-ansi-tests.ts @@ -0,0 +1,4 @@ +import stripAnsi = require('strip-ansi'); + +stripAnsi('\u001b[4mcake\u001b[0m'); +//=> 'cake' \ No newline at end of file diff --git a/strip-ansi/tsconfig.json b/strip-ansi/tsconfig.json new file mode 100644 index 0000000000..fe78295d77 --- /dev/null +++ b/strip-ansi/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "strip-ansi-tests.ts" + ] +} diff --git a/strip-ansi/tslint.json b/strip-ansi/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/strip-ansi/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/strip-bom/index.d.ts b/strip-bom/index.d.ts new file mode 100644 index 0000000000..d7cf2b892e --- /dev/null +++ b/strip-bom/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for strip-bom 3.0 +// Project: https://github.com/sindresorhus/strip-bom#readme +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = strip_bom; +declare function strip_bom(x: string): string; diff --git a/strip-bom/strip-bom-tests.ts b/strip-bom/strip-bom-tests.ts new file mode 100644 index 0000000000..dc63d80303 --- /dev/null +++ b/strip-bom/strip-bom-tests.ts @@ -0,0 +1,4 @@ +import stripBom = require('strip-bom'); + +stripBom('\uFEFFunicorn'); +//=> 'unicorn' \ No newline at end of file diff --git a/strip-bom/tsconfig.json b/strip-bom/tsconfig.json new file mode 100644 index 0000000000..3d5c97f3bd --- /dev/null +++ b/strip-bom/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "strip-bom-tests.ts" + ] +} diff --git a/strip-bom/tslint.json b/strip-bom/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/strip-bom/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/user-home/index.d.ts b/user-home/index.d.ts new file mode 100644 index 0000000000..e0152ec9a4 --- /dev/null +++ b/user-home/index.d.ts @@ -0,0 +1,7 @@ +// Type definitions for user-home 2.0 +// Project: https://github.com/sindresorhus/user-home +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = user_home; +declare const user_home: string; diff --git a/user-home/tsconfig.json b/user-home/tsconfig.json new file mode 100644 index 0000000000..556b72aca2 --- /dev/null +++ b/user-home/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "user-home-tests.ts" + ] +} diff --git a/user-home/tslint.json b/user-home/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/user-home/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/user-home/user-home-tests.ts b/user-home/user-home-tests.ts new file mode 100644 index 0000000000..41ef1e31a8 --- /dev/null +++ b/user-home/user-home-tests.ts @@ -0,0 +1,4 @@ +import userHome = require('user-home'); + +console.log(userHome); +//=> '/Users/sindresorhus' \ No newline at end of file diff --git a/uuid-js/index.d.ts b/uuid-js/index.d.ts new file mode 100644 index 0000000000..efc9f75786 --- /dev/null +++ b/uuid-js/index.d.ts @@ -0,0 +1,42 @@ +// Type definitions for uuid-js 0.7 +// Project: http://github.com/pnegri/uuid-js +// Definitions by: Mohamed Hegazy +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export = uuid; +declare class uuid { + equals(uuid: uuid): boolean; + fromParts(timeLow: any, timeMid: any, timeHiAndVersion: any, clockSeqHiAndReserved: any, clockSeqLow: any, node: any): uuid; + toBytes(): any[]; + toString(): string; + toURN(): string; + static create(version?: number): uuid; + static firstFromTime(time: number): uuid; + static fromBinary(binary: any): uuid; + static fromBytes(ints: number[]): uuid; + static fromTime(time: number, last?: boolean): uuid; + static fromURN(strId: any): uuid; + static getTimeFieldValues(time: any): any; + static lastFromTime(time: any): uuid; + static limitUI04: number; + static limitUI06: number; + static limitUI08: number; + static limitUI12: number; + static limitUI14: number; + static limitUI16: number; + static limitUI32: number; + static limitUI40: number; + static limitUI48: number; + static maxFromBits(bits: number): uuid; + static newTS(): uuid; + static paddedString(string: any, length: any, z: any): uuid; + static randomUI04(): uuid; + static randomUI06(): uuid; + static randomUI08(): uuid; + static randomUI12(): uuid; + static randomUI14(): uuid; + static randomUI16(): uuid; + static randomUI32(): uuid; + static randomUI40(): uuid; + static randomUI48(): uuid; +} diff --git a/uuid-js/tsconfig.json b/uuid-js/tsconfig.json new file mode 100644 index 0000000000..2a168056db --- /dev/null +++ b/uuid-js/tsconfig.json @@ -0,0 +1,20 @@ +{ + "compilerOptions": { + "module": "commonjs", + "target": "es6", + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "uuid-js-tests.ts" + ] +} diff --git a/uuid-js/tslint.json b/uuid-js/tslint.json new file mode 100644 index 0000000000..377cc837d4 --- /dev/null +++ b/uuid-js/tslint.json @@ -0,0 +1 @@ +{ "extends": "../tslint.json" } diff --git a/uuid-js/uuid-js-tests.ts b/uuid-js/uuid-js-tests.ts new file mode 100644 index 0000000000..67ef73ba68 --- /dev/null +++ b/uuid-js/uuid-js-tests.ts @@ -0,0 +1,28 @@ +import UUID = require('uuid-js'); + + +// Generate a V4 UUID +var uuid4 = UUID.create(); +console.log(uuid4.toString()); +// Prints: 896b677f-fb14-11e0-b14d-d11ca798dbac + + +// Generate a V1 TimeUUID +var uuid1 = UUID.create(1); +console.log(uuid1.toString()); + + +// First and last possible v1 TimeUUID for a given timestamp: +var date = new Date().getTime(); +var uuidFirst = UUID.fromTime(date, false); +var uuidLast = UUID.fromTime(date, true); +console.log(uuidFirst.toString(), uuidLast.toString()); +// Prints: aa0f9af0-0e1f-11e1-0000-000000000000 aa0f9af0-0e1f-11e1-c0ff-ffffffffffff + + +// Use these TimeUUID's to perform range queries in cassandra: +var today = new Date().getTime(); +var last30days = (new Date().setDate(today - 30)); + +var rangeStart = UUID.firstFromTime(last30days); +var rangeEnd = UUID.lastFromTime(today);