minimal-bit-array: Initial commit (#27501)

This commit is contained in:
Olegs Jeremejevs
2018-07-23 20:02:13 +03:00
committed by Andy
parent 664a91a98f
commit 4461b3198a
4 changed files with 59 additions and 0 deletions

26
types/minimal-bit-array/index.d.ts vendored Normal file
View File

@@ -0,0 +1,26 @@
// Type definitions for minimal-bit-array 1.0
// Project: https://github.com/mikolalysenko/minimal-bit-array
// Definitions by: Olegs Jeremejevs <https://github.com/jeremejevs>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace BitArray {
interface BitArrayJSON {
bits: number[];
length: number;
}
}
declare class BitArray {
static fromJSON(bitArrayJSON: BitArray.BitArrayJSON): BitArray;
length: number;
bits: Uint32Array;
constructor(length: number);
get(index: number): boolean;
set(index: number, value: any): boolean;
toJSON(): BitArray.BitArrayJSON;
}
export = BitArray;

View File

@@ -0,0 +1,9 @@
import * as BitArray from "minimal-bit-array";
new BitArray('abc'); // $ExpectError
const bitArray: BitArray = new BitArray(123);
bitArray.get(12); // $ExpectType boolean
bitArray.set(34, true); // $ExpectType boolean
bitArray.set(34, 'someTruthyValue');
const json: BitArray.BitArrayJSON = bitArray.toJSON();
const bitArrayClone: BitArray = BitArray.fromJSON(json);

View File

@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true,
"strictFunctionTypes": true
},
"files": [
"index.d.ts",
"minimal-bit-array-tests.ts"
]
}

View File

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