Security News
tea.xyz Spam Plagues npm and RubyGems Package Registries
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
array-from
Advanced tools
Package description
The npm package 'array-from' provides a utility function for creating arrays from array-like or iterable objects. This is particularly useful for converting objects that resemble arrays but do not have the full functionality of an Array, such as NodeLists or arguments objects, into true JavaScript arrays.
Creating arrays from array-like objects
Converts an array-like object (object with properties indexed from 0 and a length property) into a true array.
const arrayFrom = require('array-from');
const arrayLike = {0: 'hello', 1: 'world', length: 2};
const newArray = arrayFrom(arrayLike);
console.log(newArray); // ['hello', 'world']
Creating arrays from iterable objects
Converts an iterable object (like Set or Map) into a true array, allowing for easier manipulation and access to array methods.
const arrayFrom = require('array-from');
const set = new Set(['foo', 'bar', 'baz']);
const newArray = arrayFrom(set);
console.log(newArray); // ['foo', 'bar', 'baz']
This package polyfills the Array.from method and offers similar functionality to 'array-from'. It allows for creating arrays from array-like or iterable objects. The main difference is that 'array.prototype.from' is intended as a polyfill for the standard Array.from method, aligning closely with the ECMAScript specification.
Similar to 'array-from', 'to-array' converts array-like or iterable objects into true arrays. The difference lies in the implementation details and additional utility functions that 'to-array' might offer, making it suitable for different use cases depending on the specific needs of the developer.
Readme
A ponyfill for the ES 2015 Array.from()
.
* Ponyfill: A polyfill that doesn't overwrite the native method.
* ES 2015: The new name for ES6 that nobody expected.
Modeled after the final ES 2015 spec. Credits for the implementation go to the amazing folks of the MDN and the amazing guy @barberboy.
$ npm install array-from
Recommended:
var arrayFrom = require('array-from');
// You’ll get the native `Array.from` if it’s available.
function () {console.log(
arrayFrom(arguments).map(require('1-liners/increment'))
);}(1, 2, 3);
//» [2, 3, 4]
You can also use it as a classical polyfill. It’s not recommended, but sometimes practical:
if (!Array.from) Array.from = require('array-from');
// This will affect all loaded modules.
function () {console.log(
Array.from(arguments).map(require('1-liners/increment'))
);}(1, 2, 3);
//» [2, 3, 4]
We support the current and active LTS release of Node.js. More info in nodejs/LTS.
FAQs
A ponyfill for the ES 2015 (ES6) `Array.from()`.
The npm package array-from receives a total of 1,113,339 weekly downloads. As such, array-from popularity was classified as popular.
We found that array-from demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
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.
Security News
Tea.xyz, a crypto project aimed at rewarding open source contributions, is once again facing backlash due to an influx of spam packages flooding public package registries.
Security News
As cyber threats become more autonomous, AI-powered defenses are crucial for businesses to stay ahead of attackers who can exploit software vulnerabilities at scale.
Security News
UnitedHealth Group disclosed that the ransomware attack on Change Healthcare compromised protected health information for millions in the U.S., with estimated costs to the company expected to reach $1 billion.