Merge pull request #17900 from wanganjun/master

add arrify 1.0.1
This commit is contained in:
Ryan Cavanaugh
2017-07-13 14:44:35 -07:00
committed by GitHub
3 changed files with 54 additions and 0 deletions

View File

@@ -0,0 +1,14 @@
import arrify = require("arrify");
arrify(null);
arrify<number>(null);
arrify(undefined);
arrify<number>(undefined);
arrify(1);
arrify([2, 3]);
function test(val?: string | string[]) {
arrify(val);
}

18
types/arrify/index.d.ts vendored Normal file
View File

@@ -0,0 +1,18 @@
// Type definitions for arrify 1.0.1
// Project: https://github.com/sindresorhus/arrify
// Definitions by: AnJun Wang <https://github.com/wanganjun>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/**
* @example
* arrify(undefined) // returns []
* @example
* arrify(null) // returns []
* @example
* arrify(1) // returns [1]
* @example
* arrify([2, 3]) // returns [2, 3]
* @param val
*/
declare function arrify<T>(val: undefined | null | T | T[]): T[];
export = arrify;

View File

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