@yume-chan/async-operation-manager
Advanced tools
Comparing version 1.0.1 to 1.0.3
export declare type PromiseResolverState = 'running' | 'resolved' | 'rejected'; | ||
export declare class PromiseResolver<T> { | ||
private _promise; | ||
readonly promise: Promise<T>; | ||
get promise(): Promise<T>; | ||
private _resolve; | ||
private _reject; | ||
private _state; | ||
readonly state: PromiseResolverState; | ||
get state(): PromiseResolverState; | ||
constructor(); | ||
@@ -20,2 +20,3 @@ resolve(value?: T | PromiseLike<T>): void; | ||
private operations; | ||
constructor(initialId?: number); | ||
add<T>(): AsyncOperationInfo<T>; | ||
@@ -22,0 +23,0 @@ private getResolver; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.PromiseResolver = void 0; | ||
var PromiseResolver = /** @class */ (function () { | ||
@@ -14,3 +15,3 @@ function PromiseResolver() { | ||
get: function () { return this._promise; }, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -20,3 +21,3 @@ }); | ||
get: function () { return this._state; }, | ||
enumerable: true, | ||
enumerable: false, | ||
configurable: true | ||
@@ -36,5 +37,6 @@ }); | ||
var AsyncOperationManager = /** @class */ (function () { | ||
function AsyncOperationManager() { | ||
this.operationId = 0; | ||
function AsyncOperationManager(initialId) { | ||
if (initialId === void 0) { initialId = 0; } | ||
this.operations = new Map(); | ||
this.operationId = initialId; | ||
} | ||
@@ -41,0 +43,0 @@ AsyncOperationManager.prototype.add = function () { |
{ | ||
"name": "@yume-chan/async-operation-manager", | ||
"version": "1.0.1", | ||
"version": "1.0.3", | ||
"description": "Utilities to manage RPC operations.", | ||
@@ -30,7 +30,7 @@ "main": "lib/index.js", | ||
"devDependencies": { | ||
"@types/jest": "^24.0.15", | ||
"jest": "^24.8.0", | ||
"ts-jest": "^24.0.2", | ||
"typescript": "^3.5.2" | ||
"@types/jest": "25.2.3", | ||
"jest": "26.0.1", | ||
"ts-jest": "26.0.0", | ||
"typescript": "3.9.3" | ||
} | ||
} |
@@ -38,6 +38,10 @@ export type PromiseResolverState = 'running' | 'resolved' | 'rejected'; | ||
export default class AsyncOperationManager { | ||
private operationId: number = 0; | ||
private operationId: number; | ||
private operations: Map<number, PromiseResolver<any>> = new Map(); | ||
public constructor(initialId: number = 0) { | ||
this.operationId = initialId; | ||
} | ||
public add<T>(): AsyncOperationInfo<T> { | ||
@@ -44,0 +48,0 @@ const id = this.operationId++; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
17920
10
217