X-Git-Url: https://git.josue.xyz/?a=blobdiff_plain;ds=sidebyside;f=.config%2Fcoc%2Fextensions%2Fnode_modules%2Fcoc-prettier%2Fnode_modules%2Fcore-js%2Fmodules%2Fes.typed-array.sort.js;h=05ae6d9edf9ee1b18ca83b9fe8741d14ee4eaf3d;hb=3be0a9efc698a9570a44456009afc6014812625a;hp=f23c8e22ce92c8df8c13d735687c099423c106fa;hpb=3aba54c891969552833dbc350b3139e944e17a97;p=dotfiles%2F.git diff --git a/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/modules/es.typed-array.sort.js b/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/modules/es.typed-array.sort.js index f23c8e22..05ae6d9e 100644 --- a/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/modules/es.typed-array.sort.js +++ b/.config/coc/extensions/node_modules/coc-prettier/node_modules/core-js/modules/es.typed-array.sort.js @@ -1,12 +1,71 @@ 'use strict'; +var global = require('../internals/global'); +var uncurryThis = require('../internals/function-uncurry-this'); +var fails = require('../internals/fails'); +var aCallable = require('../internals/a-callable'); +var internalSort = require('../internals/array-sort'); var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); +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 Array = global.Array; var aTypedArray = ArrayBufferViewCore.aTypedArray; var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; -var $sort = [].sort; +var Uint16Array = global.Uint16Array; +var un$Sort = Uint16Array && uncurryThis(Uint16Array.prototype.sort); + +// WebKit +var ACCEPT_INCORRECT_ARGUMENTS = !!un$Sort && !(fails(function () { + un$Sort(new Uint16Array(2), null); +}) && fails(function () { + un$Sort(new Uint16Array(2), {}); +})); + +var STABLE_SORT = !!un$Sort && !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; + } + + un$Sort(array, 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.github.io/ecma262/#sec-%typedarray%.prototype.sort +// https://tc39.es/ecma262/#sec-%typedarray%.prototype.sort exportTypedArrayMethod('sort', function sort(comparefn) { - return $sort.call(aTypedArray(this), comparefn); -}); + if (comparefn !== undefined) aCallable(comparefn); + if (STABLE_SORT) return un$Sort(this, comparefn); + + return internalSort(aTypedArray(this), getSortCompare(comparefn)); +}, !STABLE_SORT || ACCEPT_INCORRECT_ARGUMENTS);