| export declare class Queue<T> { | ||
| private q; | ||
| private awaiters; | ||
| push: (item: T) => void; | ||
| get: () => Promise<T>; | ||
| getOptional: () => NonNullable<T> | null; | ||
| get isEmpty(): boolean; | ||
| } |
| "use strict"; | ||
| var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
| function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
| return new (P || (P = Promise))(function (resolve, reject) { | ||
| function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } | ||
| function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } | ||
| function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } | ||
| step((generator = generator.apply(thisArg, _arguments || [])).next()); | ||
| }); | ||
| }; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.Queue = void 0; | ||
| class Queue { | ||
| constructor() { | ||
| this.q = []; | ||
| this.awaiters = []; | ||
| this.push = (item) => { | ||
| // If queue is not empty | ||
| if (this.q.length > 0) { | ||
| this.q.push(item); | ||
| return; | ||
| } | ||
| // If queue is empty and there are awaiters | ||
| if (this.awaiters.length > 0) { | ||
| this.awaiters[0](item); | ||
| return; | ||
| } | ||
| // No awaiters and not empty queue | ||
| this.q.push(item); | ||
| }; | ||
| this.get = () => __awaiter(this, void 0, void 0, function* () { | ||
| if (this.q.length > 0) { | ||
| return this.q.shift(); | ||
| } | ||
| return yield new Promise((resolver) => this.awaiters.push(resolver)); | ||
| }); | ||
| this.getOptional = () => { | ||
| if (this.q.length > 0) { | ||
| return this.q.shift(); | ||
| } | ||
| else { | ||
| return null; | ||
| } | ||
| }; | ||
| } | ||
| get isEmpty() { | ||
| return this.q.length === 0; | ||
| } | ||
| } | ||
| exports.Queue = Queue; | ||
| //# sourceMappingURL=Queue.js.map |
| {"version":3,"file":"Queue.js","sourceRoot":"","sources":["../../src/sync/Queue.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,MAAa,KAAK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ncValue } from './sync/SyncValue'; | ||
| export { Queue } from './sync/Queue'; | ||
| export { ConcurrencyPool, UnboundedConcurrencyPool, BoundedConcurrencyPool } from './sync/ConcurrencyPool'; | ||
| export { createBackoff, BackoffFunc, exponentialBackoffDelay } from './timer/backoff'; | ||
| export { delay } from './timer/delay'; | ||
| export { ConcurrencyPool, UnboundedConcurrencyPool, BoundedConcurrencyPool } from './sync/ConcurrencyPool'; |
+6
-4
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.BoundedConcurrencyPool = exports.UnboundedConcurrencyPool = exports.delay = exports.exponentialBackoffDelay = exports.createBackoff = exports.SyncValue = exports.InvalidateSync = exports.AsyncLock = exports.createAsyncIterator = void 0; | ||
| exports.delay = exports.exponentialBackoffDelay = exports.createBackoff = exports.BoundedConcurrencyPool = exports.UnboundedConcurrencyPool = exports.Queue = exports.SyncValue = exports.InvalidateSync = exports.AsyncLock = exports.createAsyncIterator = void 0; | ||
| var createAsyncIterator_1 = require("./iterator/createAsyncIterator"); | ||
@@ -12,2 +12,7 @@ Object.defineProperty(exports, "createAsyncIterator", { enumerable: true, get: function () { return createAsyncIterator_1.createAsyncIterator; } }); | ||
| Object.defineProperty(exports, "SyncValue", { enumerable: true, get: function () { return SyncValue_1.SyncValue; } }); | ||
| var Queue_1 = require("./sync/Queue"); | ||
| Object.defineProperty(exports, "Queue", { enumerable: true, get: function () { return Queue_1.Queue; } }); | ||
| var ConcurrencyPool_1 = require("./sync/ConcurrencyPool"); | ||
| Object.defineProperty(exports, "UnboundedConcurrencyPool", { enumerable: true, get: function () { return ConcurrencyPool_1.UnboundedConcurrencyPool; } }); | ||
| Object.defineProperty(exports, "BoundedConcurrencyPool", { enumerable: true, get: function () { return ConcurrencyPool_1.BoundedConcurrencyPool; } }); | ||
| var backoff_1 = require("./timer/backoff"); | ||
@@ -18,5 +23,2 @@ Object.defineProperty(exports, "createBackoff", { enumerable: true, get: function () { return backoff_1.createBackoff; } }); | ||
| Object.defineProperty(exports, "delay", { enumerable: true, get: function () { return delay_1.delay; } }); | ||
| var ConcurrencyPool_1 = require("./sync/ConcurrencyPool"); | ||
| Object.defineProperty(exports, "UnboundedConcurrencyPool", { enumerable: true, get: function () { return ConcurrencyPool_1.UnboundedConcurrencyPool; } }); | ||
| Object.defineProperty(exports, "BoundedConcurrencyPool", { enumerable: true, get: function () { return ConcurrencyPool_1.BoundedConcurrencyPool; } }); | ||
| //# sourceMappingURL=index.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sEAAqE;AAA5D,0HAAA,mBAAmB,OAAA;AAC5B,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,2CAAsF;AAA7E,wGAAA,aAAa,OAAA;AAAe,kHAAA,uBAAuB,OAAA;AAC5D,uCAAsC;AAA7B,8FAAA,KAAK,OAAA;AACd,0DAA2G;AAAjF,2HAAA,wBAAwB,OAAA;AAAE,yHAAA,sBAAsB,OAAA"} | ||
| {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,sEAAqE;AAA5D,0HAAA,mBAAmB,OAAA;AAC5B,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,wDAAuD;AAA9C,gHAAA,cAAc,OAAA;AACvB,8CAA6C;AAApC,sGAAA,SAAS,OAAA;AAClB,sCAAqC;AAA5B,8FAAA,KAAK,OAAA;AACd,0DAA2G;AAAjF,2HAAA,wBAAwB,OAAA;AAAE,yHAAA,sBAAsB,OAAA;AAC1E,2CAAsF;AAA7E,wGAAA,aAAa,OAAA;AAAe,kHAAA,uBAAuB,OAAA;AAC5D,uCAAsC;AAA7B,8FAAA,KAAK,OAAA"} |
+1
-1
| { | ||
| "name": "teslabot", | ||
| "version": "1.1.0", | ||
| "version": "1.2.0", | ||
| "repository": "https://github.com/ex3ndr/teslabot.git", | ||
@@ -5,0 +5,0 @@ "author": "Steve Korshakov <steve@korshakov.com>", |
30072
12.91%30
11.11%467
15.02%