Merge pull request #34265 from ltetzlaff/cuint

Add typings for cuint
This commit is contained in:
Daniel Rosenwasser
2019-04-07 19:06:40 -07:00
committed by GitHub
4 changed files with 68 additions and 0 deletions

View File

@@ -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);

39
types/cuint/index.d.ts vendored Normal file
View File

@@ -0,0 +1,39 @@
// Type definitions for cuint 0.2
// Project: https://github.com/pierrec/js-cuint
// Definitions by: Lukas Tetzlaff <https://github.com/ltetzlaff>
// 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<T extends Uint> {
// 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<Uint>;
export const UINT32: UintConstructor<Uint>;

23
types/cuint/tsconfig.json Normal file
View File

@@ -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"
]
}

1
types/cuint/tslint.json Normal file
View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }