@creately/future
Advanced tools
Comparing version 1.0.2 to 2.0.0
@@ -0,3 +1,7 @@ | ||
## v2.0.0 | ||
- Export `Future` as a type and export a `createFuture` factory function. | ||
## v1.0.2 | ||
- Export `Future` class with `resolve` and `reject` methods. |
/** | ||
* Future | ||
* Future extends Promise and exposes the resolve and reject methods. | ||
*/ | ||
export declare class Future<T> extends Promise<T> { | ||
export declare type Future<T> = Promise<T> & { | ||
resolve: (val: T) => void; | ||
reject: (err: Error) => void; | ||
constructor(); | ||
} | ||
}; | ||
/** | ||
* Creates a new Future instance by extending a new Promise instance. | ||
*/ | ||
export declare function createFuture<T>(): Future<T>; |
"use strict"; | ||
var __extends = (this && this.__extends) || (function () { | ||
var extendStatics = function (d, b) { | ||
extendStatics = Object.setPrototypeOf || | ||
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || | ||
function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; | ||
return extendStatics(d, b); | ||
} | ||
return function (d, b) { | ||
extendStatics(d, b); | ||
function __() { this.constructor = d; } | ||
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); | ||
}; | ||
})(); | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
/** | ||
* Future | ||
* Future extends Promise and exposes the resolve and reject methods. | ||
* Creates a new Future instance by extending a new Promise instance. | ||
*/ | ||
var Future = /** @class */ (function (_super) { | ||
__extends(Future, _super); | ||
function Future() { | ||
var _this = _super.call(this, function (resolve, reject) { | ||
_this.resolve = resolve; | ||
_this.reject = reject; | ||
}) || this; | ||
return _this; | ||
} | ||
return Future; | ||
}(Promise)); | ||
exports.Future = Future; | ||
function createFuture() { | ||
var res; | ||
var rej; | ||
var future = new Promise(function (_res, _rej) { | ||
res = _res; | ||
rej = _rej; | ||
}); | ||
Object.defineProperties(future, { | ||
resolve: { value: res }, | ||
reject: { value: rej }, | ||
}); | ||
return future; | ||
} | ||
exports.createFuture = createFuture; | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@creately/future", | ||
"version": "1.0.2", | ||
"version": "2.0.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4054
30