diff --git a/types/scrambo/index.d.ts b/types/scrambo/index.d.ts new file mode 100644 index 0000000000..ccd4aa3c33 --- /dev/null +++ b/types/scrambo/index.d.ts @@ -0,0 +1,51 @@ +// Type definitions for scrambo 0.3 +// Project: https://github.com/nickcolley/scrambo +// Definitions by: Christopher Mühl +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +type NNN = '222' | '333' | '444' | '555' | '666' | '777'; +type ScrambleType = NNN | 'clock' | 'minx' | 'pyram' | 'sq1' | 'skewb'; + +declare class Scrambo { + /** + * Sets this instance's scrambler type and returns the original instance. + * @param type + */ + type(type: ScrambleType): Scrambo; + + /** + * Returns the currently configured scrambler type. + */ + type(): ScrambleType; + + /** + * Sets this instance's seed and returns the original instance. + * @param seed + */ + seed(seed: number): Scrambo; + + /** + * Returns the current seed type of this scrambler. + */ + seed(): number; + + /** + * Sets this instance's scramble length and returns the original instance. + * @param length + */ + length(length: number): Scrambo; + + /** + * Returns the currently configured scramble length. + */ + length(): number; + + /** + * Returns an array of random scrambles with the given length + * for the configured scrambler type. + * @param number defaults to 1 + */ + get(number?: number): [string]; +} + +export = Scrambo; diff --git a/types/scrambo/scrambo-tests.ts b/types/scrambo/scrambo-tests.ts new file mode 100644 index 0000000000..5ef8d147ad --- /dev/null +++ b/types/scrambo/scrambo-tests.ts @@ -0,0 +1,11 @@ +import Scrambo = require('scrambo'); + +(async () => { + const scrambo = new Scrambo(); + scrambo.seed(15000); + + const originalType = scrambo.type(); + + scrambo.type('minx').length(15).get(); + scrambo.type(originalType).get(5); +})(); diff --git a/types/scrambo/tsconfig.json b/types/scrambo/tsconfig.json new file mode 100644 index 0000000000..261ca1b9fe --- /dev/null +++ b/types/scrambo/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "scrambo-tests.ts" + ] +} diff --git a/types/scrambo/tslint.json b/types/scrambo/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/scrambo/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }