diff --git a/types/cuint/cuint-tests.ts b/types/cuint/cuint-tests.ts new file mode 100644 index 0000000000..6a5abe305e --- /dev/null +++ b/types/cuint/cuint-tests.ts @@ -0,0 +1,5 @@ +import { UINT32 } from "cuint"; + +const u = UINT32(1, 2); +const d = u.fromBits(4, 5, 6); +d.add(u.multiply(d)).rotl(17).subtract(u).shiftRight(123); diff --git a/types/cuint/index.d.ts b/types/cuint/index.d.ts new file mode 100644 index 0000000000..4b20b33973 --- /dev/null +++ b/types/cuint/index.d.ts @@ -0,0 +1,39 @@ +// Type definitions for cuint 0.2 +// Project: https://github.com/pierrec/js-cuint +// Definitions by: Lukas Tetzlaff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export interface Uint { + clone(): this; + add(x: this): this; + subtract(x: this): this; + multiply(x: this): this; + xor(x: this): this; + rotl(n: number): this; + shiftRight(n: number): this; + + fromNumber(n: number): this; + fromBits(...bits: number[]): this; + + _low: number; + _high: number; + + toString(base?: number): string; +} + +export interface UintConstructor { + // called as a function: + (low: number, high?: number): T; + // tslint:disable-next-line:unified-signatures + (text: string, radix?: number): T; + + // called as a constructor: + new (low: number, high?: number): T; + // tslint:disable-next-line:unified-signatures + new (text: string, radix?: number): T; + + prototype: T; + } + +export const UINT64: UintConstructor; +export const UINT32: UintConstructor; diff --git a/types/cuint/tsconfig.json b/types/cuint/tsconfig.json new file mode 100644 index 0000000000..44d73f84be --- /dev/null +++ b/types/cuint/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": true, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "cuint-tests.ts" + ] +} diff --git a/types/cuint/tslint.json b/types/cuint/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/cuint/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }