Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

mdn-polyfills

Package Overview
Dependencies
Maintainers
1
Versions
42
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mdn-polyfills - npm Package Compare versions

Comparing version 2.2.0 to 3.0.0

.eslintrc

2

Array.of.js

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

!function(r){function e(o){if(t[o])return t[o].exports;var u=t[o]={exports:{},id:o,loaded:!1};return r[o].call(u.exports,u,u.exports,e),u.loaded=!0,u.exports}var t={};return e.m=r,e.c=t,e.p="",e(0)}([function(r,e,t){"use strict";function o(r){return r&&r.__esModule?r:{default:r}}var u=t(1),n=o(u);Array.of||(Array.of=n.default)},function(r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(){return Array.prototype.slice.call(arguments)}}]);
!function(){"use strict";var r=function(){return Array.prototype.slice.call(arguments)};Array.of||(Array.of=r)}();

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

!function(r){function t(o){if(e[o])return e[o].exports;var n=e[o]={exports:{},id:o,loaded:!1};return r[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var e={};return t.m=r,t.c=e,t.p="",t(0)}([function(r,t,e){"use strict";function o(r){return r&&r.__esModule?r:{default:r}}var n=e(2),i=o(n);Array.prototype.filter||(Array.prototype.filter=i.default)},,function(r,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r){if(void 0===this||null===this)throw new TypeError;var t=Object(this),e=t.length>>>0;if("function"!=typeof r)throw new TypeError;for(var o=[],n=arguments.length>=2?arguments[1]:void 0,i=0;i<e;i++)if(i in t){var u=t[i];r.call(n,u,i,t)&&o.push(u)}return o}}]);
!function(){"use strict";var r=function(r){if(void 0===this||null===this)throw new TypeError;var t=Object(this),i=t.length>>>0;if("function"!=typeof r)throw new TypeError;for(var o=[],e=arguments.length>=2?arguments[1]:void 0,n=0;n<i;n++)if(n in t){var f=t[n];r.call(e,f,n,t)&&o.push(f)}return o};Array.prototype.filter||(Array.prototype.filter=r)}();

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

!function(r){function e(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return r[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var t={};return e.m=r,e.c=t,e.p="",e(0)}([function(r,e,t){"use strict";function n(r){return r&&r.__esModule?r:{default:r}}var o=t(3),u=n(o);Array.prototype.find||(Array.prototype.find=u.default)},,,function(r,e){"use strict";function t(r){if(null==this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof r)throw new TypeError("predicate must be a function");for(var e=Object(this),t=e.length>>>0,n=arguments[1],o=void 0,u=0;u<t;u++)if(o=e[u],r.call(n,o,u,e))return o}Object.defineProperty(e,"__esModule",{value:!0}),e.default=t}]);
!function(){"use strict";function r(r){if(null==this)throw new TypeError("Array.prototype.find called on null or undefined");if("function"!=typeof r)throw new TypeError("predicate must be a function");for(var t=Object(this),n=t.length>>>0,o=arguments[1],e=void 0,i=0;i<n;i++)if(e=t[i],r.call(o,e,i,t))return e}Array.prototype.find||(Array.prototype.find=r)}();

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

!function(r){function t(o){if(e[o])return e[o].exports;var n=e[o]={exports:{},id:o,loaded:!1};return r[o].call(n.exports,n,n.exports,t),n.loaded=!0,n.exports}var e={};return t.m=r,t.c=e,t.p="",t(0)}([function(r,t,e){"use strict";function o(r){return r&&r.__esModule?r:{default:r}}var n=e(4),i=o(n);Array.prototype.forEach||(Array.prototype.forEach=i.default)},,,,function(r,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(r,t){var e,o;if(null===this)throw new TypeError(" this is null or not defined");var n=Object(this),i=n.length>>>0;if("function"!=typeof r)throw new TypeError(r+" is not a function");for(arguments.length>1&&(e=t),o=0;o<i;){var u;o in n&&(u=n[o],r.call(e,u,o,n)),o++}}}]);
!function(){"use strict";var r=function(r,t){var o,n;if(null===this)throw new TypeError(" this is null or not defined");var i=Object(this),e=i.length>>>0;if("function"!=typeof r)throw new TypeError(r+" is not a function");for(arguments.length>1&&(o=t),n=0;n<e;){var f;n in i&&(f=i[n],r.call(o,f,n,i)),n++}};Array.prototype.forEach||(Array.prototype.forEach=r)}();

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

!function(r){function t(e){if(n[e])return n[e].exports;var o=n[e]={exports:{},id:e,loaded:!1};return r[e].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var n={};return t.m=r,t.c=n,t.p="",t(0)}([function(r,t){"use strict";Array.from||(Array.from=function(){var r=Object.prototype.toString,t=function(t){return"function"==typeof t||"[object Function]"===r.call(t)},n=function(r){var t=Number(r);return isNaN(t)?0:0!==t&&isFinite(t)?(t>0?1:-1)*Math.floor(Math.abs(t)):t},e=Math.pow(2,53)-1,o=function(r){var t=n(r);return Math.min(Math.max(t,0),e)};return function(r){var n=this,e=Object(r);if(null==r)throw new TypeError("Array.from requires an array-like object - not null or undefined");var a,i=arguments.length>1?arguments[1]:void 0;if("undefined"!=typeof i){if(!t(i))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(a=arguments[2])}for(var u,f=o(e.length),c=t(n)?Object(new n(f)):new Array(f),l=0;l<f;)u=e[l],i?c[l]="undefined"==typeof a?i(u,l):i.call(a,u,l):c[l]=u,l+=1;return c.length=f,c}}())}]);
!function(){"use strict";Array.from||(Array.from=function(){var r=Object.prototype.toString,n=function(n){return"function"==typeof n||"[object Function]"===r.call(n)},t=function(r){var n=Number(r);return isNaN(n)?0:0!==n&&isFinite(n)?(n>0?1:-1)*Math.floor(Math.abs(n)):n},e=Math.pow(2,53)-1,o=function(r){var n=t(r);return Math.min(Math.max(n,0),e)};return function(r){var t=this,e=Object(r);if(null==r)throw new TypeError("Array.from requires an array-like object - not null or undefined");var i,a=arguments.length>1?arguments[1]:void 0;if(void 0!==a){if(!n(a))throw new TypeError("Array.from: when provided, the second argument must be a function");arguments.length>2&&(i=arguments[2])}for(var u,f=o(e.length),c=n(t)?Object(new t(f)):new Array(f),h=0;h<f;)u=e[h],c[h]=a?void 0===i?a(u,h):a.call(i,u,h):u,h+=1;return c.length=f,c}}())}();

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

!function(r){function e(n){if(t[n])return t[n].exports;var o=t[n]={exports:{},id:n,loaded:!1};return r[n].call(o.exports,o,o.exports,e),o.loaded=!0,o.exports}var t={};return e.m=r,e.c=t,e.p="",e(0)}({0:function(r,e,t){"use strict";function n(r){return r&&r.__esModule?r:{default:r}}var o=t(5),u=n(o);Array.prototype.includes||(Array.prototype.includes=u.default)},5:function(r,e){"use strict";Object.defineProperty(e,"__esModule",{value:!0}),e.default=function(r){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var e=Object(this),t=parseInt(e.length,10)||0;if(0===t)return!1;var n,o=parseInt(arguments[1],10)||0;o>=0?n=o:(n=t+o,n<0&&(n=0));for(var u;n<t;){if(u=e[n],r===u||r!==r&&u!==u)return!0;n++}return!1}}});
!function(){"use strict";var r=function(r){if(null==this)throw new TypeError("Array.prototype.includes called on null or undefined");var t=Object(this),e=parseInt(t.length,10)||0;if(0===e)return!1;var n,o=parseInt(arguments[1],10)||0;o>=0?n=o:(n=e+o)<0&&(n=0);for(var i;n<e;){if(i=t[n],r===i||r!==r&&i!==i)return!0;n++}return!1};Array.prototype.includes||(Array.prototype.includes=r)}();

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

!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(6),u=n(o);"function"!=typeof Object.assign&&(Object.assign=u.default)},6:function(e,t){"use strict";function r(e){if(void 0===e||null===e)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(e),r=1;r<arguments.length;r++){var n=arguments[r];if(void 0!==n&&null!==n)for(var o in n)n.hasOwnProperty(o)&&(t[o]=n[o])}return t}Object.defineProperty(t,"__esModule",{value:!0}),t.default=r}});
!function(){"use strict";function n(n){if(void 0===n||null===n)throw new TypeError("Cannot convert undefined or null to object");for(var t=Object(n),o=1;o<arguments.length;o++){var r=arguments[o];if(void 0!==r&&null!==r)for(var e in r)r.hasOwnProperty(e)&&(t[e]=r[e])}return t}"function"!=typeof Object.assign&&(Object.assign=n)}();

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

!function(e){function t(n){if(r[n])return r[n].exports;var o=r[n]={exports:{},id:n,loaded:!1};return e[n].call(o.exports,o,o.exports,t),o.loaded=!0,o.exports}var r={};return t.m=e,t.c=r,t.p="",t(0)}({0:function(e,t,r){"use strict";function n(e){return e&&e.__esModule?e:{default:e}}var o=r(7),u=n(o);"function"!=typeof Object.create&&(Object.create=(0,u.default)())},7:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default=function(e){var t=function(){};return function(r,n){if(r!==Object(r))throw TypeError("Argument must be an object, or null");t.prototype=r||{};var o=new t;return t.prototype=null,n!==e&&Object.defineProperties(o,n),null===r&&(o.__proto__=null),o}}}});
!function(){"use strict";"function"!=typeof Object.create&&(Object.create=function(t){var e=function(){};return function(n,r){if(n!==Object(n))throw TypeError("Argument must be an object, or null");e.prototype=n||{};var o=new e;return e.prototype=null,r!==t&&Object.defineProperties(o,r),null===n&&(o.__proto__=null),o}}())}();
{
"name": "mdn-polyfills",
"version": "2.2.0",
"version": "3.0.0",
"description": "MDN polyfills",
"scripts": {
"prepublish": "webpack",
"lint": "eslint src/",
"prepublish": "npm run lint && node rollup.build.js",
"test": "ava --tap | tap-nyan"

@@ -19,3 +20,5 @@ },

"includes",
"of",
"assign",
"create",
"array.from",

@@ -37,8 +40,13 @@ "array.find",

"devDependencies": {
"ava": "^0.16.0",
"babel-cli": "^6.10.1",
"babel-loader": "^6.2.4",
"babel-preset-es2015": "^6.9.0",
"tap-nyan": "0.0.2",
"webpack": "^1.13.1"
"ava": "^0.19.1",
"babel-cli": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-plugin-external-helpers": "^6.22.0",
"babel-preset-es2015": "^6.24.1",
"babelrc-rollup": "^3.0.0",
"eslint": "^3.19.0",
"rollup": "^0.41.6",
"rollup-plugin-babel": "^2.7.1",
"rollup-plugin-uglify": "^1.0.2",
"tap-nyan": "^1.1.0"
},

@@ -45,0 +53,0 @@ "ava": {

# Polyfills copied from MDN [![Build Status](https://travis-ci.org/msn0/mdn-polyfills.svg?branch=master)](http://travis-ci.org/msn0/mdn-polyfills)
> [MDN](https://developer.mozilla.org) polyfills. Ready to be used as ES6 modules.
> [MDN](https://developer.mozilla.org) polyfills. A collection of side-effect ECMAScript modules. Minimized, mangled and extremally small thanks to [Rollup](http://rollupjs.org) - next-generation ES6 module bundler.
# Installation

@@ -16,3 +15,3 @@

```js
import 'mdn-polyfills/Object.assign';
import 'mdn-polyfills/Object.assign'; // 333 bytes
```

@@ -23,3 +22,3 @@

```js
import 'mdn-polyfills/Object.create';
import 'mdn-polyfills/Object.create'; // 328 bytes
```

@@ -30,3 +29,3 @@

```js
import 'mdn-polyfills/Array.prototype.find';
import 'mdn-polyfills/Array.prototype.find'; // 361 bytes
```

@@ -37,3 +36,3 @@

```js
import 'mdn-polyfills/Array.prototype.from';
import 'mdn-polyfills/Array.prototype.from'; // 840 bytes
```

@@ -44,3 +43,3 @@

```js
import 'mdn-polyfills/Array.prototype.forEach';
import 'mdn-polyfills/Array.prototype.forEach'; // 364 bytes
```

@@ -51,3 +50,3 @@

```js
import 'mdn-polyfills/Array.prototype.filter';
import 'mdn-polyfills/Array.prototype.filter'; // 352 bytes
```

@@ -58,3 +57,3 @@

```js
import 'mdn-polyfills/Array.prototype.includes';
import 'mdn-polyfills/Array.prototype.includes'; // 388 bytes
```

@@ -65,3 +64,3 @@

```js
import 'mdn-polyfills/Array.of';
import 'mdn-polyfills/Array.of'; // 115 bytes
```

@@ -68,0 +67,0 @@

import of from './of';
if (!Array.of) {
Array.of = of;
Array.of = of;
}
export default function () {
return Array.prototype.slice.call(arguments);
return Array.prototype.slice.call(arguments);
};

@@ -5,5 +5,5 @@ import test from 'ava';

test('should create array from arguments', t => {
const actual = of('foo', 2, null, {});
const actual = of('foo', 2, null, {});
t.deepEqual(actual, ['foo', 2, null, {}]);
t.deepEqual(actual, ['foo', 2, null, {}]);
});
export default function (fun/*, thisArg*/) {
'use strict';
if (this === void 0 || this === null) {
throw new TypeError();
}
if (this === void 0 || this === null) {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== 'function') {
throw new TypeError();
}
var t = Object(this);
var len = t.length >>> 0;
if (typeof fun !== 'function') {
throw new TypeError();
}
var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++) {
if (i in t) {
var val = t[i];
var res = [];
var thisArg = arguments.length >= 2 ? arguments[1] : void 0;
for (var i = 0; i < len; i++) {
if (i in t) {
var val = t[i];
// NOTE: Technically this should Object.defineProperty at

@@ -25,9 +23,9 @@ // the next index, as push can be affected by

// rare, so use the more-compatible alternative.
if (fun.call(thisArg, val, i, t)) {
res.push(val);
}
if (fun.call(thisArg, val, i, t)) {
res.push(val);
}
}
}
}
return res;
return res;
};
import filter from './filter';
if (!Array.prototype.filter) {
Array.prototype.filter = filter;
Array.prototype.filter = filter;
}

@@ -5,9 +5,9 @@ import test from 'ava';

test('should filter out values', t => {
const filtered = filter.call([12, 5, 8, 130, 44], isBigEnough);
const filtered = filter.call([12, 5, 8, 130, 44], isBigEnough);
t.deepEqual(filtered, [12, 130, 44]);
t.deepEqual(filtered, [12, 130, 44]);
});
function isBigEnough(value) {
return value >= 10;
return value >= 10;
}
export default function find(predicate) {
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
let list = Object(this);
let length = list.length >>> 0;
let thisArg = arguments[1];
let value;
if (this == null) {
throw new TypeError('Array.prototype.find called on null or undefined');
}
if (typeof predicate !== 'function') {
throw new TypeError('predicate must be a function');
}
let list = Object(this);
let length = list.length >>> 0;
let thisArg = arguments[1];
let value;
for (let i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
for (let i = 0; i < length; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) {
return value;
}
}
}
return undefined;
return undefined;
};
import find from './find';
if (!Array.prototype.find) {
Array.prototype.find = find;
Array.prototype.find = find;
}

@@ -5,36 +5,36 @@ import test from 'ava';

test('should find cherries', t => {
const inventory = [
const inventory = [
{ name: 'apples', quantity: 2 },
{ name: 'bananas', quantity: 0 },
{ name: 'cherries', quantity: 5 }
];
];
t.deepEqual(find.call(inventory, findCherries), { name: 'cherries', quantity: 5 });
t.deepEqual(find.call(inventory, findCherries), { name: 'cherries', quantity: 5 });
});
test('should find primes', t => {
t.deepEqual(find.call([4, 5, 8, 12], isPrime), 5);
t.deepEqual(find.call([4, 5, 8, 12], isPrime), 5);
});
test('should return undefined if not found', t => {
t.deepEqual(find.call([4, 6, 8, 12], isPrime), undefined);
t.deepEqual(find.call([4, 6, 8, 12], isPrime), undefined);
});
test('only the first one should be found', t => {
t.deepEqual(find.call([4, 5, 8, 12, 17], isPrime), 5);
t.deepEqual(find.call([4, 5, 8, 12, 17], isPrime), 5);
});
function findCherries(fruit) {
return fruit.name === 'cherries';
return fruit.name === 'cherries';
}
function isPrime(element) {
let start = 2;
while (start <= Math.sqrt(element)) {
if (element % start++ < 1) {
return false;
let start = 2;
while (start <= Math.sqrt(element)) {
if (element % start++ < 1) {
return false;
}
}
}
return element > 1;
return element > 1;
}
export default function (callback, thisArg) {
var T, k;
var T, k;
if (this === null) {
throw new TypeError(' this is null or not defined');
}
if (this === null) {
throw new TypeError(' this is null or not defined');
}
// 1. Let O be the result of calling toObject() passing the
// |this| value as the argument.
var O = Object(this);
var O = Object(this);

@@ -16,23 +16,23 @@ // 2. Let lenValue be the result of calling the Get() internal

// 3. Let len be toUint32(lenValue).
var len = O.length >>> 0;
var len = O.length >>> 0;
// 4. If isCallable(callback) is false, throw a TypeError exception.
// See: http://es5.github.com/#x9.11
if (typeof callback !== "function") {
throw new TypeError(callback + ' is not a function');
}
if (typeof callback !== 'function') {
throw new TypeError(callback + ' is not a function');
}
// 5. If thisArg was supplied, let T be thisArg; else let
// T be undefined.
if (arguments.length > 1) {
T = thisArg;
}
if (arguments.length > 1) {
T = thisArg;
}
// 6. Let k be 0
k = 0;
k = 0;
// 7. Repeat, while k < len
while (k < len) {
while (k < len) {
var kValue;
var kValue;

@@ -45,16 +45,16 @@ // a. Let Pk be ToString(k).

// c. If kPresent is true, then
if (k in O) {
if (k in O) {
// i. Let kValue be the result of calling the Get internal
// method of O with argument Pk.
kValue = O[k];
kValue = O[k];
// ii. Call the Call internal method of callback with T as
// the this value and argument list containing kValue, k, and O.
callback.call(T, kValue, k, O);
callback.call(T, kValue, k, O);
}
// d. Increase k by 1.
k++;
}
// d. Increase k by 1.
k++;
}
// 8. return undefined
};
import forEach from './forEach';
if (!Array.prototype.forEach) {
Array.prototype.forEach = forEach;
Array.prototype.forEach = forEach;
}

@@ -5,10 +5,10 @@ import test from 'ava';

test('should iterate through elements', t => {
const array = ['b', 'a', 'r'];
const result = [];
const array = ['b', 'a', 'r'];
const result = [];
forEach.call(array, element => {
result.push(element);
});
forEach.call(array, element => {
result.push(element);
});
t.deepEqual(array, result);
t.deepEqual(array, result);
});
// Production steps of ECMA-262, Edition 6, 22.1.2.1
// Reference: https://people.mozilla.org/~jorendorff/es6-draft.html#sec-array.from
if (!Array.from) {
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
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);
};
Array.from = (function () {
var toStr = Object.prototype.toString;
var isCallable = function (fn) {
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);
};
// The length property of the from method is 1.
return function from(arrayLike/*, mapFn, thisArg */) {
return function from(arrayLike/*, mapFn, thisArg */) {
// 1. Let C be the this value.
var C = this;
var C = this;
// 2. Let items be ToObject(arrayLike).
var items = Object(arrayLike);
var items = Object(arrayLike);
// 3. ReturnIfAbrupt(items).
if (arrayLike == null) {
throw new TypeError("Array.from requires an array-like object - not null or undefined");
}
if (arrayLike == null) {
throw new TypeError('Array.from requires an array-like object - not null or undefined');
}
// 4. If mapfn is undefined, then let mapping be false.
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
if (typeof mapFn !== 'undefined') {
var mapFn = arguments.length > 1 ? arguments[1] : void undefined;
var T;
if (typeof mapFn !== 'undefined') {
// 5. else
// 5. a If IsCallable(mapfn) is false, throw a TypeError exception.
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
if (!isCallable(mapFn)) {
throw new TypeError('Array.from: when provided, the second argument must be a function');
}
// 5. b. If thisArg was supplied, let T be thisArg; else let T be undefined.
if (arguments.length > 2) {
T = arguments[2];
}
}
if (arguments.length > 2) {
T = arguments[2];
}
}
// 10. Let lenValue be Get(items, "length").
// 11. Let len be ToLength(lenValue).
var len = toLength(items.length);
var len = toLength(items.length);
// 13. If IsConstructor(C) is true, then
// 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list containing the single item len.
// 13. a. Let A be the result of calling the [[Construct]] internal method of C with an argument list
// containing the single item len.
// 14. a. Else, Let A be ArrayCreate(len).
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
var A = isCallable(C) ? Object(new C(len)) : new Array(len);
// 16. Let k be 0.
var k = 0;
var k = 0;
// 17. Repeat, while k < len… (also steps a - h)
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k += 1;
}
var kValue;
while (k < len) {
kValue = items[k];
if (mapFn) {
A[k] = typeof T === 'undefined' ? mapFn(kValue, k) : mapFn.call(T, kValue, k);
} else {
A[k] = kValue;
}
k += 1;
}
// 18. Let putStatus be Put(A, "length", len, true).
A.length = len;
A.length = len;
// 20. Return A.
return A;
};
}());
return A;
};
}());
}
export default function (searchElement /*, fromIndex*/) {
'use strict';
if (this == null) {
throw new TypeError('Array.prototype.includes called on null or undefined');
}
if (this == null) {
throw new TypeError('Array.prototype.includes called on null or undefined');
}
var O = Object(this);
var len = parseInt(O.length, 10) || 0;
if (len === 0) {
return false;
}
var n = parseInt(arguments[1], 10) || 0;
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
var O = Object(this);
var len = parseInt(O.length, 10) || 0;
if (len === 0) {
return false;
}
}
var currentElement;
while (k < len) {
currentElement = O[k];
if (searchElement === currentElement ||
var n = parseInt(arguments[1], 10) || 0;
var k;
if (n >= 0) {
k = n;
} else {
k = len + n;
if (k < 0) {
k = 0;
}
}
var currentElement;
while (k < len) {
currentElement = O[k];
if (searchElement === currentElement ||
(searchElement !== searchElement && currentElement !== currentElement)) { // NaN !== NaN
return true;
return true;
}
k++;
}
k++;
}
return false;
return false;
};
import includes from './includes';
if (!Array.prototype.includes) {
Array.prototype.includes = includes;
Array.prototype.includes = includes;
}

@@ -5,9 +5,9 @@ import test from 'ava';

test('should determine whether an array includes a certain element', t => {
const array = [1, 2, 3];
const array = [1, 2, 3];
t.true(includes.call(array, 2));
t.false(includes.call(array, 4));
t.false(includes.call(array, 3, 3));
t.true(includes.call(array, 3, -1));
t.true(includes.call([1, 2, NaN], NaN));
t.true(includes.call(array, 2));
t.false(includes.call(array, 4));
t.false(includes.call(array, 3, 3));
t.true(includes.call(array, 3, -1));
t.true(includes.call([1, 2, NaN], NaN));
});
export default function assign(target) {
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}
if (target === undefined || target === null) {
throw new TypeError('Cannot convert undefined or null to object');
}
let output = Object(target);
for (let index = 1; index < arguments.length; index++) {
let source = arguments[index];
if (source !== undefined && source !== null) {
for (let nextKey in source) {
if (source.hasOwnProperty(nextKey)) {
output[nextKey] = source[nextKey];
let output = Object(target);
for (let index = 1; index < arguments.length; index++) {
let source = arguments[index];
if (source !== undefined && source !== null) {
for (let nextKey in source) {
if (source.hasOwnProperty(nextKey)) {
output[nextKey] = source[nextKey];
}
}
}
}
}
}
return output;
return output;
}
import assign from './assign';
if (typeof Object.assign != 'function') {
Object.assign = assign;
if (typeof Object.assign !== 'function') {
Object.assign = assign;
}

@@ -5,16 +5,15 @@ import test from 'ava';

test('should merge objects', t => {
const foo = { foo: 'foo' };
const bar = { bar: 'bar' };
const foo = { foo: 'foo' };
const bar = { bar: 'bar' };
t.deepEqual(assign(foo, bar), { foo: 'foo', bar: 'bar' });
t.deepEqual(assign(foo, bar), { foo: 'foo', bar: 'bar' });
});
test('should clone object', t => {
const foo = { foo: 'foo' };
const foo = { foo: 'foo' };
const bar = assign({}, foo);
const bar = assign({}, foo);
t.not(foo, bar);
t.deepEqual(foo, bar);
t.not(foo, bar);
t.deepEqual(foo, bar);
});
export default function(undefined) {
var Temp = function() {};
return function (prototype, propertiesObject) {
if(prototype !== Object(prototype)) {
throw TypeError(
var Temp = function() {};
return function (prototype, propertiesObject) {
if(prototype !== Object(prototype)) {
throw TypeError(
'Argument must be an object, or null'
);
}
Temp.prototype = prototype || {};
var result = new Temp();
Temp.prototype = null;
if (propertiesObject !== undefined) {
Object.defineProperties(result, propertiesObject);
}
}
Temp.prototype = prototype || {};
var result = new Temp();
Temp.prototype = null;
if (propertiesObject !== undefined) {
Object.defineProperties(result, propertiesObject);
}
// to imitate the case of Object.create(null)
if(prototype === null) {
result.__proto__ = null;
}
return result;
};
if(prototype === null) {
result.__proto__ = null;
}
return result;
};
};
import create from './create';
if (typeof Object.create !== 'function') {
Object.create = create();
Object.create = create();
}

@@ -5,7 +5,7 @@ import test from 'ava';

test('should create object with given prototype', t => {
const foo = { foo: 'foo' };
const foo = { foo: 'foo' };
const object = create()(foo);
const object = create()(foo);
t.deepEqual(object.__proto__, { foo: 'foo' });
t.deepEqual(object.__proto__, { foo: 'foo' });
});

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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