Tumortisch-Dist/resources/app/node_modules/es5-ext/promise/#/as-callback.js

20 lines
542 B
JavaScript
Raw Permalink Normal View History

2021-06-15 16:00:08 +02:00
"use strict";
var ensurePlainFunction = require("../../object/ensure-plain-function")
, ensureThenable = require("../../object/ensure-thenable")
, microtaskDelay = require("../../function/#/microtask-delay");
module.exports = function (callback) {
ensureThenable(this);
ensurePlainFunction(callback);
// Rely on microtaskDelay to escape eventual error swallowing
this.then(
microtaskDelay.call(function (value) {
callback(null, value);
}),
microtaskDelay.call(function (reason) {
callback(reason);
})
);
};