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

core-js

Package Overview
Dependencies
Maintainers
2
Versions
276
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

core-js - npm Package Compare versions

Comparing version 3.13.1 to 3.14.0

internals/array-sort.js

5

internals/object-prototype-accessors-forced.js

@@ -5,3 +5,3 @@ 'use strict';

var fails = require('../internals/fails');
var userAgent = require('../internals/engine-user-agent');
var WEBKIT = require('../internals/engine-webkit-version');

@@ -12,4 +12,3 @@ // Forced replacement object prototype accessors methods

// https://github.com/zloirock/core-js/issues/232
var webkit = userAgent.match(/AppleWebKit\/(\d+)\./);
if (webkit && +webkit[1] < 535) return;
if (WEBKIT && WEBKIT < 535) return;
var key = Math.random();

@@ -16,0 +15,0 @@ // In FF throws only define methods

2

internals/shared.js

@@ -7,5 +7,5 @@ var IS_PURE = require('../internals/is-pure');

})('versions', []).push({
version: '3.13.1',
version: '3.14.0',
mode: IS_PURE ? 'pure' : 'global',
copyright: '© 2021 Denis Pushkarev (zloirock.ru)'
});

@@ -5,4 +5,10 @@ 'use strict';

var toObject = require('../internals/to-object');
var toLength = require('../internals/to-length');
var fails = require('../internals/fails');
var internalSort = require('../internals/array-sort');
var arrayMethodIsStrict = require('../internals/array-method-is-strict');
var FF = require('../internals/engine-ff-version');
var IE_OR_EDGE = require('../internals/engine-is-ie-or-edge');
var V8 = require('../internals/engine-v8-version');
var WEBKIT = require('../internals/engine-webkit-version');

@@ -23,4 +29,48 @@ var test = [];

var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD;
var STABLE_SORT = !fails(function () {
// feature detection can be too slow, so check engines versions
if (V8) return V8 < 70;
if (FF && FF > 3) return;
if (IE_OR_EDGE) return true;
if (WEBKIT) return WEBKIT < 603;
var result = '';
var code, chr, value, index;
// generate an array with more 512 elements (Chakra and old V8 fails only in this case)
for (code = 65; code < 76; code++) {
chr = String.fromCharCode(code);
switch (code) {
case 66: case 69: case 70: case 72: value = 3; break;
case 68: case 71: value = 4; break;
default: value = 2;
}
for (index = 0; index < 47; index++) {
test.push({ k: chr + index, v: value });
}
}
test.sort(function (a, b) { return b.v - a.v; });
for (index = 0; index < test.length; index++) {
chr = test[index].k.charAt(0);
if (result.charAt(result.length - 1) !== chr) result += chr;
}
return result !== 'DGBEFHACIJK';
});
var FORCED = FAILS_ON_UNDEFINED || !FAILS_ON_NULL || !STRICT_METHOD || !STABLE_SORT;
var getSortCompare = function (comparefn) {
return function (x, y) {
if (y === undefined) return -1;
if (x === undefined) return 1;
if (comparefn !== undefined) return +comparefn(x, y) || 0;
return String(x) > String(y) ? 1 : -1;
};
};
// `Array.prototype.sort` method

@@ -30,6 +80,25 @@ // https://tc39.es/ecma262/#sec-array.prototype.sort

sort: function sort(comparefn) {
return comparefn === undefined
? nativeSort.call(toObject(this))
: nativeSort.call(toObject(this), aFunction(comparefn));
if (comparefn !== undefined) aFunction(comparefn);
var array = toObject(this);
if (STABLE_SORT) return comparefn === undefined ? nativeSort.call(array) : nativeSort.call(array, comparefn);
var items = [];
var arrayLength = toLength(array.length);
var itemsLength, index;
for (index = 0; index < arrayLength; index++) {
if (index in array) items.push(array[index]);
}
items = internalSort(items, getSortCompare(comparefn));
itemsLength = items.length;
index = 0;
while (index < itemsLength) array[index] = items[index++];
while (index < arrayLength) delete array[index++];
return array;
}
});
'use strict';
var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
var global = require('../internals/global');
var fails = require('../internals/fails');
var aFunction = require('../internals/a-function');
var toLength = require('../internals/to-length');
var internalSort = require('../internals/array-sort');
var FF = require('../internals/engine-ff-version');
var IE_OR_EDGE = require('../internals/engine-is-ie-or-edge');
var V8 = require('../internals/engine-v8-version');
var WEBKIT = require('../internals/engine-webkit-version');
var aTypedArray = ArrayBufferViewCore.aTypedArray;
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
var $sort = [].sort;
var Uint16Array = global.Uint16Array;
var nativeSort = Uint16Array && Uint16Array.prototype.sort;
// WebKit
var ACCEPT_INCORRECT_ARGUMENTS = !!nativeSort && !fails(function () {
var array = new Uint16Array(2);
array.sort(null);
array.sort({});
});
var STABLE_SORT = !!nativeSort && !fails(function () {
// feature detection can be too slow, so check engines versions
if (V8) return V8 < 74;
if (FF) return FF < 67;
if (IE_OR_EDGE) return true;
if (WEBKIT) return WEBKIT < 602;
var array = new Uint16Array(516);
var expected = Array(516);
var index, mod;
for (index = 0; index < 516; index++) {
mod = index % 4;
array[index] = 515 - index;
expected[index] = index - 2 * mod + 3;
}
array.sort(function (a, b) {
return (a / 4 | 0) - (b / 4 | 0);
});
for (index = 0; index < 516; index++) {
if (array[index] !== expected[index]) return true;
}
});
var getSortCompare = function (comparefn) {
return function (x, y) {
if (comparefn !== undefined) return +comparefn(x, y) || 0;
// eslint-disable-next-line no-self-compare -- NaN check
if (y !== y) return -1;
// eslint-disable-next-line no-self-compare -- NaN check
if (x !== x) return 1;
if (x === 0 && y === 0) return 1 / x > 0 && 1 / y < 0 ? 1 : -1;
return x > y;
};
};
// `%TypedArray%.prototype.sort` method
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort
exportTypedArrayMethod('sort', function sort(comparefn) {
return $sort.call(aTypedArray(this), comparefn);
});
var array = this;
if (comparefn !== undefined) aFunction(comparefn);
if (STABLE_SORT) return nativeSort.call(array, comparefn);
aTypedArray(array);
var arrayLength = toLength(array.length);
var items = Array(arrayLength);
var index;
for (index = 0; index < arrayLength; index++) {
items[index] = array[index];
}
items = internalSort(array, getSortCompare(comparefn));
for (index = 0; index < arrayLength; index++) {
array[index] = items[index];
}
return array;
}, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS);
{
"name": "core-js",
"description": "Standard library",
"version": "3.13.1",
"version": "3.14.0",
"repository": {

@@ -58,3 +58,3 @@ "type": "git",

},
"gitHead": "a05c21cbf99ccb39b75746f3f65cbb91ef80d697"
"gitHead": "e386f3de7760ee2910d07efb9d35029aa5dda93b"
}
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