New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

array.from

Package Overview
Dependencies
Maintainers
2
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

array.from - npm Package Compare versions

Comparing version 0.2.0 to 0.3.0

CHANGELOG.md

157

array-from.js

@@ -1,84 +0,83 @@

/*! http://mths.be/array-from v0.2.0 by @mathias */
if (!Array.from) {
(function() {
'use strict';
var defineProperty = (function() {
// IE 8 only supports `Object.defineProperty` on DOM elements.
try {
var object = {};
var $defineProperty = Object.defineProperty;
var result = $defineProperty(object, object, object) && $defineProperty;
} catch(error) {}
return result || function put(object, key, descriptor) {
object[key] = descriptor.value;
};
}());
var toStr = Object.prototype.toString;
var isCallable = function(fn) {
// In a perfect world, the `typeof` check would be sufficient. However,
// in Chrome 1–12, `typeof /x/ == 'object'`, and in IE 6–8
// `typeof alert == 'object'` and similar for other host objects.
return typeof fn == 'function' || toStr.call(fn) == '[object Function]';
/*! https://mths.be/array-from v0.2.0 by @mathias */
(function() {
'use strict';
var defineProperty = (function() {
// IE 8 only supports `Object.defineProperty` on DOM elements.
try {
var object = {};
var $defineProperty = Object.defineProperty;
var result = $defineProperty(object, object, object) && $defineProperty;
} catch(error) {}
return result || function put(object, key, descriptor) {
object[key] = descriptor.value;
};
var toInteger = function(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}());
var toStr = Object.prototype.toString;
var isCallable = function(fn) {
// In a perfect world, the `typeof` check would be sufficient. However,
// in Chrome 1–12, `typeof /x/ == 'object'`, and in IE 6–8
// `typeof alert == 'object'` and similar for other host objects.
return typeof fn == 'function' || toStr.call(fn) == '[object Function]';
};
var toInteger = function(value) {
var number = Number(value);
if (isNaN(number)) {
return 0;
}
if (number == 0 || !isFinite(number)) {
return number;
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var from = function from(arrayLike) {
var C = this;
if (arrayLike == null) {
throw new TypeError('`Array.from` requires an array-like object, not `null` or `undefined`');
}
var items = Object(arrayLike);
var mapping = arguments.length > 1;
var mapFn, T;
if (arguments.length > 1) {
mapFn = arguments[1];
if (!isCallable(mapFn)) {
throw new TypeError('When provided, the second argument to `Array.from` must be a function');
}
if (number == 0 || !isFinite(number)) {
return number;
if (arguments.length > 2) {
T = arguments[2];
}
return (number > 0 ? 1 : -1) * Math.floor(Math.abs(number));
};
var maxSafeInteger = Math.pow(2, 53) - 1;
var toLength = function(value) {
var len = toInteger(value);
return Math.min(Math.max(len, 0), maxSafeInteger);
};
var from = function(arrayLike) {
var C = this;
if (arrayLike == null) {
throw new TypeError('`Array.from` requires an array-like object, not `null` or `undefined`');
}
var items = Object(arrayLike);
var mapping = arguments.length > 1;
}
var mapFn, T;
if (arguments.length > 1) {
mapFn = arguments[1];
if (!isCallable(mapFn)) {
throw new TypeError('When provided, the second argument to `Array.from` must be a function');
}
if (arguments.length > 2) {
T = arguments[2];
}
var len = toLength(items.length);
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
var k = 0;
var kValue, mappedValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
mappedValue = typeof T == 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
mappedValue = kValue;
}
var len = toLength(items.length);
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
var k = 0;
var kValue, mappedValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
mappedValue = typeof T == 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
mappedValue = kValue;
}
defineProperty(A, k, {
'value': mappedValue,
'configurable': true,
'enumerable': true
});
++k;
}
A.length = len;
return A;
};
defineProperty(Array, 'from', {
'value': from,
'configurable': true,
'writable': true
});
}());
}
defineProperty(A, k, {
'value': mappedValue,
'configurable': true,
'enumerable': true,
'writable': true
});
++k;
}
A.length = len;
return A;
};
defineProperty(Array, 'from', {
'value': from,
'configurable': true,
'writable': true
});
}());

@@ -1,2 +0,2 @@

Copyright Mathias Bynens <http://mathiasbynens.be/>
Copyright Mathias Bynens <https://mathiasbynens.be/>

@@ -3,0 +3,0 @@ Permission is hereby granted, free of charge, to any person obtaining

{
"name": "array.from",
"version": "0.2.0",
"version": "0.3.0",
"description": "A robust & optimized `Array.from` polyfill, based on the ECMAScript 6 specification.",
"homepage": "http://mths.be/array-from",
"main": "array-from.js",
"homepage": "https://mths.be/array-from",
"main": "detect.js",
"keywords": [

@@ -13,12 +13,18 @@ "array",

],
"licenses": [
{
"type": "MIT",
"url": "http://mths.be/mit"
}
],
"license": "MIT",
"author": {
"name": "Mathias Bynens",
"url": "http://mathiasbynens.be/"
"url": "https://mathiasbynens.be/"
},
"contributors": [
{
"name": "Mathias Bynens",
"url": "https://mathiasbynens.be/"
},
{
"name": "Jordan Harband",
"email": "ljharb@gmail.com",
"url": "http://ljharb.codes"
}
],
"repository": {

@@ -28,8 +34,7 @@ "type": "git",

},
"bugs": {
"url": "https://github.com/mathiasbynens/Array.from/issues"
},
"bugs": "https://github.com/mathiasbynens/Array.from/issues",
"files": [
"LICENSE-MIT.txt",
"array-from.js"
"array-from.js",
"detect.js"
],

@@ -44,5 +49,5 @@ "directories": {

"devDependencies": {
"covert": "~1.0.0",
"tape": "~2.14.0"
"covert": "^1.1.0",
"tape": "^4.2.2"
}
}
# ES6 `Array.from` polyfill [![Build status](https://travis-ci.org/mathiasbynens/Array.from.svg?branch=master)](https://travis-ci.org/mathiasbynens/Array.from)
A robust & optimized ES3-compatible polyfill for [the `Array.from` method in ECMAScript 6](http://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from).
A robust & optimized ES3-compatible polyfill for [the `Array.from` method in ECMAScript 6](http://ecma-international.org/ecma-262/6.0/#sec-array.from).

@@ -13,3 +13,3 @@ ## Installation

Via [npm](http://npmjs.org/):
Via [npm](https://www.npmjs.com/):

@@ -20,3 +20,3 @@ ```bash

Then, in [Node.js](http://nodejs.org/):
Then, in [Node.js](https://nodejs.org/):

@@ -35,6 +35,6 @@ ```js

|---|
| [Mathias Bynens](http://mathiasbynens.be/) |
| [Mathias Bynens](https://mathiasbynens.be/) |
## License
This polyfill is available under the [MIT](http://mths.be/mit) license.
This polyfill is available under the [MIT](https://mths.be/mit) license.
SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc