moodle/lib/amd/build/pending.min.js
Andrew Nicols 116ddb8933 MDL-72609 behat: Rewrite core/pending to observe ES6 style
This commit makes the following changes:
* convert to use ES6 module format
* migrate from a jQuery Deferred to a native ES6 promise
* add a native-Promise-like instantiation

New uses are documented in appropriate jsdoc with examples.
2023-01-23 15:02:55 +08:00

12 lines
1.4 KiB
JavaScript

define("core/pending",["exports"],(function(_exports){Object.defineProperty(_exports,"__esModule",{value:!0}),_exports.default=void 0;return _exports.default=
/**
* A helper used to inform Behat that an operation is in progress and that Behat must wait for it to complete.
*
* @module core/pending
* @copyright 2018 Andrew Nicols <andrew@nicols.co.uk>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
* @since 3.6
*/
class{static request(pendingKey){return window.console.error("The core/pending::request method has been deprecated. "+"Please use one of the alternative calls to core/pending, for example \"new Pending('".concat(pendingKey,"')\". ")+"Called with ".concat(pendingKey)),new this(pendingKey)}constructor(){let resolver,rejector,pendingKey=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"pendingPromise";const pendingPromise=this.constructor.Promise(((resolve,reject)=>{resolver=resolve,rejector=reject}),pendingKey);return pendingPromise.resolve=resolver,pendingPromise.reject=rejector,pendingPromise}static Promise(fn){let pendingKey=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"pendingPromise";const resolver=new Promise(((resolve,reject)=>{M.util.js_pending(pendingKey),fn(resolve,reject)}));return resolver.then((()=>{M.util.js_complete(pendingKey)})).catch(),resolver}},_exports.default}));
//# sourceMappingURL=pending.min.js.map