-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (35 loc) · 1.05 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
'use strict';
class PromisedDeferred {
constructor() {
this.State = require('deferred')();
}
/**
* Create a promise to receive an object of any kind later (including nothing).
* @returns a promise to receive an object of any kind later.
* */
Promise() {
var def = this.State;
return new Promise(function (resolve, reject) {
var req = function () {
return def.promise.then(function (value) {
resolve(value);
},
function (value) {
reject(value)
});
}
req();
});
}
/**
* Resolve the item and give a return value of any kind (including nothing).
* @param {any} arg An of any kind (including an empty) that is returned through the promise.
*/
Resolve(arg) {
this.State.resolve(arg);
}
Reject(arg) {
this.State.reject(arg);
}
}
module.exports = PromisedDeferred;