main
Last change
on this file was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago |
Initial commit
|
-
Property mode
set to
100644
|
File size:
958 bytes
|
Line | |
---|
1 | 'use strict';
|
---|
2 | var $ = require('../internals/export');
|
---|
3 | var uncurryThis = require('../internals/function-uncurry-this');
|
---|
4 | var aCallable = require('../internals/a-callable');
|
---|
5 | var toIndexedObject = require('../internals/to-indexed-object');
|
---|
6 | var arrayFromConstructorAndList = require('../internals/array-from-constructor-and-list');
|
---|
7 | var getBuiltInPrototypeMethod = require('../internals/get-built-in-prototype-method');
|
---|
8 | var addToUnscopables = require('../internals/add-to-unscopables');
|
---|
9 |
|
---|
10 | var $Array = Array;
|
---|
11 | var sort = uncurryThis(getBuiltInPrototypeMethod('Array', 'sort'));
|
---|
12 |
|
---|
13 | // `Array.prototype.toSorted` method
|
---|
14 | // https://tc39.es/ecma262/#sec-array.prototype.tosorted
|
---|
15 | $({ target: 'Array', proto: true }, {
|
---|
16 | toSorted: function toSorted(compareFn) {
|
---|
17 | if (compareFn !== undefined) aCallable(compareFn);
|
---|
18 | var O = toIndexedObject(this);
|
---|
19 | var A = arrayFromConstructorAndList($Array, O);
|
---|
20 | return sort(A, compareFn);
|
---|
21 | }
|
---|
22 | });
|
---|
23 |
|
---|
24 | addToUnscopables('toSorted');
|
---|
Note:
See
TracBrowser
for help on using the repository browser.