-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
113 additions
and
86 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -267,5 +267,6 @@ export default { | |
'es.iterator.some', | ||
'es.iterator.take', | ||
'es.iterator.to-array', | ||
'es.promise.try', | ||
], | ||
}; |
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 |
---|---|---|
@@ -1,14 +1,6 @@ | ||
'use strict'; | ||
require('../../modules/es.promise'); | ||
var parent = require('../../stable/promise/try'); | ||
// TODO: Remove from `core-js@4` | ||
require('../../modules/esnext.promise.try'); | ||
var apply = require('../../internals/function-apply'); | ||
var isCallable = require('../../internals/is-callable'); | ||
var path = require('../../internals/path'); | ||
|
||
var Promise = path.Promise; | ||
var promiseTry = Promise['try']; | ||
|
||
// eslint-disable-next-line no-unused-vars -- required for arity | ||
module.exports = ({ 'try': function (callbackfn /* , ...args */) { | ||
return apply(promiseTry, isCallable(this) ? this : Promise, arguments); | ||
} })['try']; | ||
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
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,15 @@ | ||
'use strict'; | ||
require('../../modules/es.object.to-string'); | ||
require('../../modules/es.promise'); | ||
require('../../modules/es.promise.try'); | ||
var apply = require('../../internals/function-apply'); | ||
var isCallable = require('../../internals/is-callable'); | ||
var path = require('../../internals/path'); | ||
|
||
var Promise = path.Promise; | ||
var $try = Promise['try']; | ||
|
||
// eslint-disable-next-line no-unused-vars -- required for arity | ||
module.exports = ({ 'try': function (callbackfn /* , ...args */) { | ||
return apply($try, isCallable(this) ? this : Promise, arguments); | ||
} })['try']; |
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,33 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var globalThis = require('../internals/global-this'); | ||
var apply = require('../internals/function-apply'); | ||
var slice = require('../internals/array-slice'); | ||
var newPromiseCapabilityModule = require('../internals/new-promise-capability'); | ||
var aCallable = require('../internals/a-callable'); | ||
var perform = require('../internals/perform'); | ||
|
||
var Promise = globalThis.Promise; | ||
|
||
var ACCEPT_ARGUMENTS = false; | ||
// Avoiding the use of polyfills of the previous iteration of this proposal | ||
// that does not accept arguments of the callback | ||
var FORCED = !Promise || !Promise['try'] || perform(function () { | ||
Promise['try'](function (argument) { | ||
ACCEPT_ARGUMENTS = argument === 8; | ||
}, 8); | ||
}).error || !ACCEPT_ARGUMENTS; | ||
|
||
// `Promise.try` method | ||
// https://github.com/tc39/proposal-promise-try | ||
$({ target: 'Promise', stat: true, forced: FORCED }, { | ||
'try': function (callbackfn /* , ...args */) { | ||
var args = arguments.length > 1 ? slice(arguments, 1) : []; | ||
var promiseCapability = newPromiseCapabilityModule.f(this); | ||
var result = perform(function () { | ||
return apply(aCallable(callbackfn), undefined, args); | ||
}); | ||
(result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value); | ||
return promiseCapability.promise; | ||
} | ||
}); |
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,33 +1,3 @@ | ||
'use strict'; | ||
var $ = require('../internals/export'); | ||
var globalThis = require('../internals/global-this'); | ||
var apply = require('../internals/function-apply'); | ||
var slice = require('../internals/array-slice'); | ||
var newPromiseCapabilityModule = require('../internals/new-promise-capability'); | ||
var aCallable = require('../internals/a-callable'); | ||
var perform = require('../internals/perform'); | ||
|
||
var Promise = globalThis.Promise; | ||
|
||
var ACCEPT_ARGUMENTS = false; | ||
// Avoiding the use of polyfills of the previous iteration of this proposal | ||
// that does not accept arguments of the callback | ||
var FORCED = !Promise || !Promise['try'] || perform(function () { | ||
Promise['try'](function (argument) { | ||
ACCEPT_ARGUMENTS = argument === 8; | ||
}, 8); | ||
}).error || !ACCEPT_ARGUMENTS; | ||
|
||
// `Promise.try` method | ||
// https://github.com/tc39/proposal-promise-try | ||
$({ target: 'Promise', stat: true, forced: FORCED }, { | ||
'try': function (callbackfn /* , ...args */) { | ||
var args = arguments.length > 1 ? slice(arguments, 1) : []; | ||
var promiseCapability = newPromiseCapabilityModule.f(this); | ||
var result = perform(function () { | ||
return apply(aCallable(callbackfn), undefined, args); | ||
}); | ||
(result.error ? promiseCapability.reject : promiseCapability.resolve)(result.value); | ||
return promiseCapability.promise; | ||
} | ||
}); | ||
// TODO: Remove from `core-js@4` | ||
require('../modules/es.promise.try.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,4 @@ | ||
'use strict'; | ||
var parent = require('../../es/promise/try'); | ||
|
||
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
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
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
tests/unit-pure/esnext.promise.try.js → tests/unit-pure/es.promise.try.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