吕君喜 406d880ac6 first | 3 年 前 | |
---|---|---|
.. | ||
License.md | 3 年 前 | |
Readme.md | 3 年 前 | |
index.js | 3 年 前 | |
package.json | 3 年 前 | |
polyfill.js | 3 年 前 | |
test.js | 3 年 前 |
A ponyfill for the ES 2015 Array.from()
.
* Ponyfill: A polyfill that doesn't overwrite the native method.
* ES 2015: The new name for ES6 that nobody expected.
Modeled after the final ES 2015 spec. Credits for the implementation go to the amazing folks of the MDN and the amazing guy @barberboy.
$ npm install array-from
Recommended:
var arrayFrom = require('array-from');
// You’ll get the native `Array.from` if it’s available.
function () {console.log(
arrayFrom(arguments).map(require('1-liners/increment'))
);}(1, 2, 3);
//» [2, 3, 4]
You can also use it as a classical polyfill. It’s not recommended, but sometimes practical:
if (!Array.from) Array.from = require('array-from');
// This will affect all loaded modules.
function () {console.log(
Array.from(arguments).map(require('1-liners/increment'))
);}(1, 2, 3);
//» [2, 3, 4]
We support the current and active LTS release of Node.js. More info in nodejs/LTS.