Socket
Socket
Sign inDemoInstall

array.from

Package Overview
Dependencies
65
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    array.from

A robust & optimized `Array.from` polyfill, based on the ECMAScript 6 specification.


Version published
Weekly downloads
2.8K
decreased by-23.53%
Maintainers
2
Created
Weekly downloads
 

Readme

Source

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

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.

Keywords

FAQs

Last updated on 23 Mar 2024

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc