Added declarations for 'random-number

This commit is contained in:
Openbyte 2018-02-16 16:07:53 +01:00
parent 423ace8fe7
commit 263ab90259
4 changed files with 114 additions and 0 deletions

29
types/random-number/index.d.ts vendored Normal file
View File

@ -0,0 +1,29 @@
// Type definitions for random-number 0.0
// Project: https://github.com/ashnur/random-number
// Definitions by: OpenByteDev <https://github.com/OpenByteDev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.2
type Generator = (min?: number|null, max?: number|null, integer?: boolean|null) => number;
interface UnparsedOptions {
min?: number|null;
max?: number|null;
integer?: boolean|null;
}
interface Options {
min: number;
max: number;
integer: boolean;
}
interface RandomNumber {
(options?: UnparsedOptions): number;
generator(options?: UnparsedOptions): Generator;
defaults(options?: UnparsedOptions): Options;
}
declare const randomNumber: RandomNumber;
export = randomNumber;

View File

@ -0,0 +1,58 @@
import rn = require('random-number');
rn();
const options1 = {
min: -1000,
max: 1000,
integer: true
};
rn(options1);
const gen1 = rn.generator({
min: -1000,
max: 1000,
integer: true
});
gen1();
const gen2 = rn.generator({
min: -1000,
max: 1000,
integer: true
});
gen2(500);
gen2(500, null, false);
const options3 = {
min: 9874316514
};
rn(options3);
const options4 = {
max: -9874316514
};
rn(options4);
const options5 = {
integer: true
};
rn(options5);
const options6 = {
min: -10,
max: -1
};
rn(options6);
const options7 = {
min: 1000,
integer: true
};
rn(options7);
const options8 = {
max: 1000,
integer: true
};
rn(options8);

View File

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

View File

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