-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
/
es.typed-array.to-sorted.js
19 lines (17 loc) · 929 Bytes
/
es.typed-array.to-sorted.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
'use strict';
var ArrayBufferViewCore = require('../internals/array-buffer-view-core');
var uncurryThis = require('../internals/function-uncurry-this');
var aCallable = require('../internals/a-callable');
var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
var aTypedArray = ArrayBufferViewCore.aTypedArray;
var getTypedArrayConstructor = ArrayBufferViewCore.getTypedArrayConstructor;
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod;
var sort = uncurryThis(ArrayBufferViewCore.TypedArrayPrototype.sort);
// `%TypedArray%.prototype.toSorted` method
// https://tc39.es/ecma262/#sec-%typedarray%.prototype.tosorted
exportTypedArrayMethod('toSorted', function toSorted(compareFn) {
if (compareFn !== undefined) aCallable(compareFn);
var O = aTypedArray(this);
var A = arrayFromConstructorAndList(getTypedArrayConstructor(O), O);
return sort(A, compareFn);
});