Add typings for cuint

This commit is contained in:
Lukas Tetzlaff
2019-03-27 15:15:39 +01:00
parent 20573fa26d
commit 562e74741a
4 changed files with 63 additions and 0 deletions
+5
View File
@@ -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);
+34
View File
@@ -0,0 +1,34 @@
// 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 type UIntFactory<T extends UInt> = (
...numbers: Array<number | string>
) => T;
export const UINT64: UIntFactory<UInt64>;
export const UINT32: UIntFactory<UInt32>;
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 {}
+23
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
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }