-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add
Array
find from last stage 1 proposal
- Loading branch information
Showing
34 changed files
with
453 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
1 change: 1 addition & 0 deletions
1
packages/core-js-pure/override/modules/esnext.typed-array.find-last-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// empty |
1 change: 1 addition & 0 deletions
1
packages/core-js-pure/override/modules/esnext.typed-array.find-last.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
// empty |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../modules/esnext.array.find-last-index'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('Array', 'findLastIndex'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../modules/esnext.array.find-last'); | ||
var entryUnbind = require('../../internals/entry-unbind'); | ||
|
||
module.exports = entryUnbind('Array', 'findLast'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../../modules/esnext.array.find-last-index'); | ||
var entryVirtual = require('../../../internals/entry-virtual'); | ||
|
||
module.exports = entryVirtual('Array').findLastIndex; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require('../../../modules/esnext.array.find-last'); | ||
var entryVirtual = require('../../../internals/entry-virtual'); | ||
|
||
module.exports = entryVirtual('Array').findLast; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,8 @@ | ||
var parent = require('../../../es/array/virtual'); | ||
require('../../../modules/esnext.array.at'); | ||
require('../../../modules/esnext.array.filter-out'); | ||
require('../../../modules/esnext.array.find-last'); | ||
require('../../../modules/esnext.array.find-last-index'); | ||
require('../../../modules/esnext.array.unique-by'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var findLastIndex = require('../array/virtual/find-last-index'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.findLastIndex; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.findLastIndex) ? findLastIndex : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
var findLast = require('../array/virtual/find-last'); | ||
|
||
var ArrayPrototype = Array.prototype; | ||
|
||
module.exports = function (it) { | ||
var own = it.findLast; | ||
return it === ArrayPrototype || (it instanceof Array && own === ArrayPrototype.findLast) ? findLast : own; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('../../modules/esnext.typed-array.find-last-index'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
require('../../modules/esnext.typed-array.find-last'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
var parent = require('../../es/typed-array'); | ||
require('../../modules/esnext.typed-array.at'); | ||
require('../../modules/esnext.typed-array.filter-out'); | ||
require('../../modules/esnext.typed-array.find-last'); | ||
require('../../modules/esnext.typed-array.find-last-index'); | ||
|
||
module.exports = parent; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
var bind = require('../internals/function-bind-context'); | ||
var IndexedObject = require('../internals/indexed-object'); | ||
var toObject = require('../internals/to-object'); | ||
var toLength = require('../internals/to-length'); | ||
|
||
// `Array.prototype.{ findLast, findLastIndex }` methods implementation | ||
var createMethod = function (TYPE) { | ||
var IS_FIND_INDEX = TYPE == 6; | ||
return function ($this, callbackfn, that) { | ||
var O = toObject($this); | ||
var self = IndexedObject(O); | ||
var boundFunction = bind(callbackfn, that, 3); | ||
var index = toLength(self.length); | ||
var value, result; | ||
while (index-- > 0) { | ||
value = self[index]; | ||
result = boundFunction(value, index, O); | ||
if (result) switch (TYPE) { | ||
case 5: return value; // find | ||
case 6: return index; // findIndex | ||
} | ||
} | ||
return IS_FIND_INDEX ? -1 : undefined; | ||
}; | ||
}; | ||
|
||
module.exports = { | ||
// `Array.prototype.findLast` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
findLast: createMethod(5), | ||
// `Array.prototype.findLastIndex` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
findLastIndex: createMethod(6) | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var $findLastIndex = require('../internals/array-iteration-from-last').findLastIndex; | ||
var addToUnscopables = require('../internals/add-to-unscopables'); | ||
|
||
// `Array.prototype.findLastIndex` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
$({ target: 'Array', proto: true }, { | ||
findLastIndex: function findLastIndex(callbackfn /* , that = undefined */) { | ||
return $findLastIndex(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); | ||
} | ||
}); | ||
|
||
addToUnscopables('findLastIndex'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var $findLast = require('../internals/array-iteration-from-last').findLast; | ||
var addToUnscopables = require('../internals/add-to-unscopables'); | ||
|
||
// `Array.prototype.findLast` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
$({ target: 'Array', proto: true }, { | ||
findLast: function findLast(callbackfn /* , that = undefined */) { | ||
return $findLast(this, callbackfn, arguments.length > 1 ? arguments[1] : undefined); | ||
} | ||
}); | ||
|
||
addToUnscopables('findLast'); |
12 changes: 12 additions & 0 deletions
12
packages/core-js/modules/esnext.typed-array.find-last-index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); | ||
var $findLastIndex = require('../internals/array-iteration-from-last').findLastIndex; | ||
|
||
var aTypedArray = ArrayBufferViewCore.aTypedArray; | ||
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; | ||
|
||
// `%TypedArray%.prototype.findLastIndex` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
exportTypedArrayMethod('findLastIndex', function findLastIndex(predicate /* , thisArg */) { | ||
return $findLastIndex(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
'use strict'; | ||
var ArrayBufferViewCore = require('../internals/array-buffer-view-core'); | ||
var $findLast = require('../internals/array-iteration-from-last').findLast; | ||
|
||
var aTypedArray = ArrayBufferViewCore.aTypedArray; | ||
var exportTypedArrayMethod = ArrayBufferViewCore.exportTypedArrayMethod; | ||
|
||
// `%TypedArray%.prototype.findLast` method | ||
// https://github.com/tc39/proposal-array-find-from-last | ||
exportTypedArrayMethod('findLast', function findLast(predicate /* , thisArg */) { | ||
return $findLast(aTypedArray(this), predicate, arguments.length > 1 ? arguments[1] : undefined); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
// https://github.com/tc39/proposal-array-find-from-last/ | ||
require('../modules/esnext.array.find-last'); | ||
require('../modules/esnext.array.find-last-index'); | ||
require('../modules/esnext.typed-array.find-last'); | ||
require('../modules/esnext.typed-array.find-last-index'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.