diff --git a/types/array.from/.editorconfig b/types/array.from/.editorconfig new file mode 100644 index 0000000000..a0207fa43b --- /dev/null +++ b/types/array.from/.editorconfig @@ -0,0 +1,3 @@ +# This package uses tabs +[*] +indent_style = tab diff --git a/types/array.from/array.from-tests.ts b/types/array.from/array.from-tests.ts new file mode 100644 index 0000000000..8747dfd8fd --- /dev/null +++ b/types/array.from/array.from-tests.ts @@ -0,0 +1,12 @@ +import ArrayFrom = require('array.from'); + +/** + * The `expectType` function from https://www.npmjs.com/package/tsd, + * except instead of returning `void`, it returns `T`. + */ +declare function expectType(t: T): T; + +expectType(ArrayFrom); +expectType(ArrayFrom.implementation); +expectType<() => typeof Array.from>(ArrayFrom.getPolyfill); +expectType<() => typeof Array.from>(ArrayFrom.shim); diff --git a/types/array.from/implementation.d.ts b/types/array.from/implementation.d.ts new file mode 100644 index 0000000000..05ffe88288 --- /dev/null +++ b/types/array.from/implementation.d.ts @@ -0,0 +1,8 @@ +/** + * Creates an array from an array-like or iterable object. + * @param iterable An array-like or iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of `this` used to invoke the mapfn. + */ +declare const ArrayFrom: typeof Array.from; +export = ArrayFrom; diff --git a/types/array.from/index.d.ts b/types/array.from/index.d.ts new file mode 100644 index 0000000000..59ac8993ec --- /dev/null +++ b/types/array.from/index.d.ts @@ -0,0 +1,31 @@ +// Type definitions for array.from 1.0 +// Project: https://mths.be/array-from +// Definitions by: ExE Boss +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped + +import implementation = require('./implementation'); +import getPolyfill = require('./polyfill'); +import shim = require('./shim'); + +/** + * Creates an array from an array-like or iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of `this` used to invoke the mapfn. + */ +declare const ArrayFrom: typeof implementation & { + /** + * Gets the optimal `Array.from` implementation to use. + */ + readonly getPolyfill: typeof getPolyfill; + + /** + * Creates an array from an array-like or iterable object. + * @param iterable An iterable object to convert to an array. + * @param mapfn A mapping function to call on every element of the array. + * @param thisArg Value of `this` used to invoke the mapfn. + */ + readonly implementation: typeof implementation; + readonly shim: typeof shim; +}; +export = ArrayFrom; diff --git a/types/array.from/polyfill.d.ts b/types/array.from/polyfill.d.ts new file mode 100644 index 0000000000..75aafbab7d --- /dev/null +++ b/types/array.from/polyfill.d.ts @@ -0,0 +1,7 @@ +import ArrayFrom = require('./implementation'); + +/** + * Gets the optimal `Array.from` implementation to use. + */ +declare function getPolyfill(): typeof ArrayFrom; +export = getPolyfill; diff --git a/types/array.from/shim.d.ts b/types/array.from/shim.d.ts new file mode 100644 index 0000000000..ed158ba747 --- /dev/null +++ b/types/array.from/shim.d.ts @@ -0,0 +1,4 @@ +import ArrayFrom = require('./implementation'); + +declare function shimArrayFrom(): typeof ArrayFrom; +export = shimArrayFrom; diff --git a/types/array.from/tsconfig.json b/types/array.from/tsconfig.json new file mode 100644 index 0000000000..f46eb63a97 --- /dev/null +++ b/types/array.from/tsconfig.json @@ -0,0 +1,22 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": ["es2015"], + "noImplicitAny": true, + "noImplicitThis": true, + "strictFunctionTypes": true, + "strictNullChecks": true, + "baseUrl": "../", + "typeRoots": ["../"], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "implementation.d.ts", + "index.d.ts", + "polyfill.d.ts", + "shim.d.ts", + "array.from-tests.ts" + ] +} diff --git a/types/array.from/tslint.json b/types/array.from/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/array.from/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }