@59naga/array.from 中文文档教程
array-from
用于 ES 2015 [Array.from()
][] 的 ponyfill。
* Ponyfill:一个不支持的 polyfill覆盖本地方法。
* ES 2015:ES6 的新名称 没有人预料到。
模仿最终的 ES 2015 规范。 实现的功劳归功于 MDN 的了不起的人和了不起的人 @barberboy。
Installation
$ npm install array-from
Usage
推荐:
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]
您也可以将其用作经典的 polyfill。 不推荐,但有时实用:
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]
License
< a href="./License.md">麻省理工学院 © Studio B12 GmbH
array-from
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.
Installation
$ npm install array-from
Usage
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]