- Notifications
You must be signed in to change notification settings - Fork15
A robust & optimized ES3-compatible polyfill for the `Array.from` method in ECMAScript 6.
License
NotificationsYou must be signed in to change notification settings
mathiasbynens/Array.from
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
A spec-compliantArray.from
shim/polyfill/replacement that works as far down as ES3.
This package implements thees-shim API interface. It works in an ES3-supported environment and complies with the proposedspec.
TheArray.from()
method creates a new Array instance from an array-like or iterable object.
npm install array.from
varfrom=require('array.from');varassert=require('assert');assert.deepEqual(from('abc'),['a','b','c']);
varfrom=require('array.from');varassert=require('assert');/* when Array#from is not present */deleteArray.from;varshimmedFrom=from.shim();assert.equal(shimmedFrom,from.getPolyfill());assert.deepEqual(Array.from('foo'),from('foo'));
varfrom=require('array.from');varassert=require('assert');/* when Array#from is present */varshimmedFrom=from.shim();assert.equal(shimmedFrom,Array.from);assert.deepEqual(Array.from('abc'),from('abc'));
Simply clone the repo,npm install
, and runnpm test
Mathias Bynens |
This polyfill is available under theMIT license.
About
A robust & optimized ES3-compatible polyfill for the `Array.from` method in ECMAScript 6.
Resources
License
Security policy
Stars
Watchers
Forks
Packages0
No packages published