2016-05-25 19:40:00 +03:00
|
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
|
|
|
|
"use strict";
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a deferred object, with a resolve and reject property.
|
|
|
|
* https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Promise.jsm/Deferred
|
|
|
|
*/
|
|
|
|
module.exports = function defer() {
|
|
|
|
let resolve, reject;
|
2018-06-01 13:36:09 +03:00
|
|
|
const promise = new Promise(function() {
|
2016-05-25 19:40:00 +03:00
|
|
|
resolve = arguments[0];
|
|
|
|
reject = arguments[1];
|
|
|
|
});
|
|
|
|
return {
|
2017-01-12 01:21:56 +03:00
|
|
|
resolve: resolve,
|
|
|
|
reject: reject,
|
|
|
|
promise: promise
|
2016-05-25 19:40:00 +03:00
|
|
|
};
|
|
|
|
};
|