From 562e74741a73091dd2ac78a2382aaaf3085892fb Mon Sep 17 00:00:00 2001 From: Lukas Tetzlaff Date: Wed, 27 Mar 2019 15:15:39 +0100 Subject: [PATCH] Add typings for cuint --- types/cuint/cuint-tests.ts | 5 +++++ types/cuint/index.d.ts | 34 ++++++++++++++++++++++++++++++++++ types/cuint/tsconfig.json | 23 +++++++++++++++++++++++ types/cuint/tslint.json | 1 + 4 files changed, 63 insertions(+) create mode 100644 types/cuint/cuint-tests.ts create mode 100644 types/cuint/index.d.ts create mode 100644 types/cuint/tsconfig.json create mode 100644 types/cuint/tslint.json diff --git a/types/cuint/cuint-tests.ts b/types/cuint/cuint-tests.ts new file mode 100644 index 0000000000..6b2abbeb51 --- /dev/null +++ b/types/cuint/cuint-tests.ts @@ -0,0 +1,5 @@ +import { UINT32 } from "cuint"; + +const u = UINT32(1, 2, 3); +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..9adf41a581 --- /dev/null +++ b/types/cuint/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for cuint 0.2 +// Project: https://github.com/pierrec/js-cuint +// Definitions by: Lukas Tetzlaff +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +export type UIntFactory = ( + ...numbers: Array +) => T; + +export const UINT64: UIntFactory; +export const UINT32: UIntFactory; + +export class UInt { + protected constructor() + + 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 class UInt64 extends UInt {} +export class UInt32 extends UInt {} 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" }