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.
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'));
Simply clone the repo, npm install
, and run npm test
This polyfill is available under the MIT license.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4