SkillAgentSearch skills...

Array.from

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

Install / Use

/learn @mathiasbynens/Array.from
About this skill

Quality Score

0/100

Supported Platforms

Zed

README

Array.from <sup>Version Badge</sup>

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

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.

View on GitHub
GitHub Stars67
CategoryDevelopment
Updated2y ago
Forks13

Languages

JavaScript

Security Score

80/100

Audited on Mar 2, 2024

No findings