File: Readme.md

package info (click to toggle)
node-array-from 2.1.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 644 kB
  • sloc: makefile: 2
file content (90 lines) | stat: -rw-r--r-- 2,419 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
[![Coveralls – test coverage
](https://img.shields.io/coveralls/studio-b12/array-from.svg?style=flat-square
)](https://coveralls.io/r/studio-b12/array-from
) [![Travis – build status
](https://img.shields.io/travis/studio-b12/array-from/master.svg?style=flat-square
)](https://travis-ci.org/studio-b12/array-from
) [![David – status of dependencies
](https://img.shields.io/david/studio-b12/array-from.svg?style=flat-square
)](https://david-dm.org/studio-b12/array-from
) [![Code style: airbnb
](https://img.shields.io/badge/code%20style-airbnb-777777.svg?style=flat-square
)](https://github.com/airbnb/javascript)




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](https://github.com/barberboy).

 

[`Array.from()`]:         https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/from                  "Array.from()"
[nobody expected]:        http://webreflection.blogspot.de/2015/01/javascript-and-living-ecmascript.html                               "JavaScript and the living ECMAScript Standard"



Installation
------------

```sh
$ npm install array-from
```




Usage
-----

Recommended:

```js
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:

```js
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]
```

[not recommended]:  https://github.com/sindresorhus/object-assign/issues/10#issuecomment-65065859  "Optionally shim native method?"




Support note
------------

We support the _current_ and _active LTS_ release of Node.js. More info in [nodejs/LTS](https://github.com/nodejs/LTS#lts_schedule).




License
-------

[MIT][] © [Studio B12 GmbH][]

[MIT]: ./License.md
[Studio B12 GmbH]: https://github.com/studio-b12