Add shuffle-seed typings (#29798)

* Add shuffle-seed typings

* Add strictFunctionTypes tsconfig param, fix linter errors

* Improve shuffle-seed type definition, use generics
This commit is contained in:
Leonardo Donelli
2018-10-17 11:57:09 -07:00
committed by Sheetal Nandi
parent 6a8e7c47a1
commit 53af59d83f
4 changed files with 41 additions and 0 deletions
+9
View File
@@ -0,0 +1,9 @@
// Type definitions for shuffle-seed 1.1
// Project: https://github.com/webcaetano/shuffle-seed#readme
// Definitions by: Leonardo Donelli <https://github.com/LeartS>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
export as namespace shuffleSeed;
export function shuffle<T>(arr: ReadonlyArray<T>, seed: any): T[];
export function unshuffle<T>(arr: ReadonlyArray<T>, seed: any): T[];
+8
View File
@@ -0,0 +1,8 @@
import { shuffle, unshuffle } from "shuffle-seed";
const originalArray = [1, "hello world", 132.81];
const shuffled1 = shuffle(originalArray, "randomseed");
const shuffled2 = shuffle(originalArray, "randomseed");
const unshuffled = unshuffle(shuffled2, "randomseed");
// shuffled1 === shuffled2
// unshuffled === originalArray
+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",
"shuffle-seed-tests.ts"
]
}
+1
View File
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }