add types for seededshuffle

This commit is contained in:
Uri Shaked
2018-03-23 03:37:32 +03:00
parent f2982c1754
commit 47337073e1
4 changed files with 44 additions and 0 deletions

13
types/seededshuffle/index.d.ts vendored Normal file
View File

@@ -0,0 +1,13 @@
// Type definitions for seededshuffle 0.2
// Project: https://github.com/LouisT/SeededShuffle
// Definitions by: Uri Shaked <https://github.com/urish>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export const seed: number;
export const strSeed: string;
export function shuffle<T>(arr: T[], seed: string|number): T[];
export function shuffle<T>(arr: ReadonlyArray<T>, seed: string|number, copy: true): T[];
export function unshuffle<T>(arr: T[], seed: string|number): T[];
export function unshuffle<T>(arr: ReadonlyArray<T>, seed: string|number, copy: true): T[];

View File

@@ -0,0 +1,7 @@
import { shuffle, unshuffle } from 'seededshuffle';
const a: number[] = shuffle([1, 2, 3] as ReadonlyArray<number>, 'Example seed', true);
const b: number[] = unshuffle(a as ReadonlyArray<number>, 'Example seed', true);
const c: string[] = shuffle(['a', 'b', 'c'], 'another seed');
const d: string[] = unshuffle(c, 'another seed');

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",
"seededshuffle-tests.ts"
]
}

View File

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