Are you happy with your logging solution? Would you help us out by taking a 30-second survey? Click here

Array.from

A robust & optimized ES3-compatible polyfill for the `Array.from` method in ECMAScript 6.

Subscribe to updates I use Array.from


Statistics on Array.from

Number of watchers on Github 50
Number of open issues 4
Average time to close an issue 4 months
Main language JavaScript
Average time to merge a PR 3 days
Open pull requests 3+
Closed pull requests 3+
Last commit about 3 years ago
Repo Created over 6 years ago
Repo Last Updated about 2 years ago
Size 77 KB
Homepage https://mths.be/a...
Organization / Authormathiasbynens
Contributors6
Page Updated
Do you use Array.from? Leave a review!
View open issues (4)
View Array.from activity
View on github
Fresh, new opensource launches 🚀🚀🚀
Trendy new open source projects in your inbox! View examples

Subscribe to our mailing list

Evaluating Array.from for your project? Score Explanation
Commits Score (?)
Issues & PR Score (?)

Array.from Version Badge

Build Status dependency status dev dependency status License Downloads

npm badge

A spec-compliant Array.from shim/polyfill/replacement that works as far down as ES3.

This package implements the es-shim API interface. It works in an ES3-supported environment and complies with the proposed spec.

The Array.from() method creates a new Array instance from an array-like or iterable object.

Installation

In a browser:

Via npm:

npm install array.from

Example

var from = require('array.from');
var assert = require('assert');

assert.deepEqual(from('abc'), ['a', 'b', 'c']);
var from = require('array.from');
var assert = require('assert');
/* when Array#from is not present */
delete Array.from;
var shimmedFrom = from.shim();
assert.equal(shimmedFrom, from.getPolyfill());
assert.deepEqual(Array.from('foo'), from('foo'));
var from = require('array.from');
var assert = require('assert');
/* when Array#from is present */
var shimmedFrom = from.shim();
assert.equal(shimmedFrom, Array.from);
assert.deepEqual(Array.from('abc'), from('abc'));

Tests

Simply clone the repo, npm install, and run npm test

Author

twitter/mathias
Mathias Bynens

License

This polyfill is available under the MIT license.

Array.from open issues Ask a question     (View All Issues)
  • over 3 years Tests results based on latest master
  • over 3 years Map/Set Iterator tests broken in Firefox
Array.from open pull requests (View All Pulls)
  • Add iterator support
  • Fix tests for collection
  • Always use for-of statements for legacy iterator support
Array.from questions on Stackoverflow (View All Questions)
  • Array.from TypeError: 0 is not a function
  • Babel is not processing Array.from or 'for ... of' loops
  • Weird usage of Array.of() and Array.from()?
  • Strange error in ios -- Array.from(...) crashes
  • what`s the best way to make babel6 support Array.from in webpack?
  • Is Array.from(arguments) an acceptable way to create an array of arguments?
  • TypeError: Array.from is not a function
  • Array.from vs Array.prototype.map
  • Prototype JS source what does this mean? Array.from = $A... Hash.from = $H;
  • Array.from implemented in jQuery
Array.from list of languages used
Other projects in JavaScript