Add type definitions for "scrambo" (#42776)

* Add types for scrambo

* Satisfy linter

* Enable esModuleInterop

* Get rid of esModuleInterop
This commit is contained in:
Christopher Mühl 2020-03-02 23:44:37 +01:00 committed by GitHub
parent 328119f5f6
commit f53fd2ba9c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 86 additions and 0 deletions

51
types/scrambo/index.d.ts vendored Normal file
View File

@ -0,0 +1,51 @@
// Type definitions for scrambo 0.3
// Project: https://github.com/nickcolley/scrambo
// Definitions by: Christopher Mühl <https://github.com/padarom>
// 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;

View File

@ -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);
})();

View File

@ -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"
]
}

View File

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