New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

asva-executors

Package Overview
Dependencies
Maintainers
1
Versions
50
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asva-executors - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

dist/src/index.esm.js

20

dist/src/index.js

@@ -84,14 +84,2 @@ (function webpackUniversalModuleDefinition(root, factory) {

/***/ "./node_modules/tslib/tslib.es6.js":
/*!*****************************************!*\
!*** ./node_modules/tslib/tslib.es6.js ***!
\*****************************************/
/*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
/***/ (function(module, __webpack_exports__, __webpack_require__) {
"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__extends\", function() { return __extends; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__assign\", function() { return __assign; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__rest\", function() { return __rest; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__decorate\", function() { return __decorate; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__param\", function() { return __param; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__metadata\", function() { return __metadata; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__awaiter\", function() { return __awaiter; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__generator\", function() { return __generator; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__exportStar\", function() { return __exportStar; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__values\", function() { return __values; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__read\", function() { return __read; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__spread\", function() { return __spread; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__await\", function() { return __await; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__asyncGenerator\", function() { return __asyncGenerator; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__asyncDelegator\", function() { return __asyncDelegator; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__asyncValues\", function() { return __asyncValues; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__makeTemplateObject\", function() { return __makeTemplateObject; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__importStar\", function() { return __importStar; });\n/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, \"__importDefault\", function() { return __importDefault; });\n/*! *****************************************************************************\r\nCopyright (c) Microsoft Corporation. All rights reserved.\r\nLicensed under the Apache License, Version 2.0 (the \"License\"); you may not use\r\nthis file except in compliance with the License. You may obtain a copy of the\r\nLicense at http://www.apache.org/licenses/LICENSE-2.0\r\n\r\nTHIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY\r\nKIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED\r\nWARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,\r\nMERCHANTABLITY OR NON-INFRINGEMENT.\r\n\r\nSee the Apache Version 2.0 License for specific language governing permissions\r\nand limitations under the License.\r\n***************************************************************************** */\r\n/* global Reflect, Promise */\r\n\r\nvar extendStatics = function(d, b) {\r\n extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return extendStatics(d, b);\r\n};\r\n\r\nfunction __extends(d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n}\r\n\r\nvar __assign = function() {\r\n __assign = Object.assign || function __assign(t) {\r\n for (var s, i = 1, n = arguments.length; i < n; i++) {\r\n s = arguments[i];\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];\r\n }\r\n return t;\r\n }\r\n return __assign.apply(this, arguments);\r\n}\r\n\r\nfunction __rest(s, e) {\r\n var t = {};\r\n for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)\r\n t[p] = s[p];\r\n if (s != null && typeof Object.getOwnPropertySymbols === \"function\")\r\n for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)\r\n t[p[i]] = s[p[i]];\r\n return t;\r\n}\r\n\r\nfunction __decorate(decorators, target, key, desc) {\r\n var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;\r\n if (typeof Reflect === \"object\" && typeof Reflect.decorate === \"function\") r = Reflect.decorate(decorators, target, key, desc);\r\n else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;\r\n return c > 3 && r && Object.defineProperty(target, key, r), r;\r\n}\r\n\r\nfunction __param(paramIndex, decorator) {\r\n return function (target, key) { decorator(target, key, paramIndex); }\r\n}\r\n\r\nfunction __metadata(metadataKey, metadataValue) {\r\n if (typeof Reflect === \"object\" && typeof Reflect.metadata === \"function\") return Reflect.metadata(metadataKey, metadataValue);\r\n}\r\n\r\nfunction __awaiter(thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n}\r\n\r\nfunction __generator(thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = op[0] & 2 ? y[\"return\"] : op[0] ? y[\"throw\"] || ((t = y[\"return\"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [op[0] & 2, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n}\r\n\r\nfunction __exportStar(m, exports) {\r\n for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];\r\n}\r\n\r\nfunction __values(o) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator], i = 0;\r\n if (m) return m.call(o);\r\n return {\r\n next: function () {\r\n if (o && i >= o.length) o = void 0;\r\n return { value: o && o[i++], done: !o };\r\n }\r\n };\r\n}\r\n\r\nfunction __read(o, n) {\r\n var m = typeof Symbol === \"function\" && o[Symbol.iterator];\r\n if (!m) return o;\r\n var i = m.call(o), r, ar = [], e;\r\n try {\r\n while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);\r\n }\r\n catch (error) { e = { error: error }; }\r\n finally {\r\n try {\r\n if (r && !r.done && (m = i[\"return\"])) m.call(i);\r\n }\r\n finally { if (e) throw e.error; }\r\n }\r\n return ar;\r\n}\r\n\r\nfunction __spread() {\r\n for (var ar = [], i = 0; i < arguments.length; i++)\r\n ar = ar.concat(__read(arguments[i]));\r\n return ar;\r\n}\r\n\r\nfunction __await(v) {\r\n return this instanceof __await ? (this.v = v, this) : new __await(v);\r\n}\r\n\r\nfunction __asyncGenerator(thisArg, _arguments, generator) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var g = generator.apply(thisArg, _arguments || []), i, q = [];\r\n return i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i;\r\n function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }\r\n function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }\r\n function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }\r\n function fulfill(value) { resume(\"next\", value); }\r\n function reject(value) { resume(\"throw\", value); }\r\n function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }\r\n}\r\n\r\nfunction __asyncDelegator(o) {\r\n var i, p;\r\n return i = {}, verb(\"next\"), verb(\"throw\", function (e) { throw e; }), verb(\"return\"), i[Symbol.iterator] = function () { return this; }, i;\r\n function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === \"return\" } : f ? f(v) : v; } : f; }\r\n}\r\n\r\nfunction __asyncValues(o) {\r\n if (!Symbol.asyncIterator) throw new TypeError(\"Symbol.asyncIterator is not defined.\");\r\n var m = o[Symbol.asyncIterator], i;\r\n return m ? m.call(o) : (o = typeof __values === \"function\" ? __values(o) : o[Symbol.iterator](), i = {}, verb(\"next\"), verb(\"throw\"), verb(\"return\"), i[Symbol.asyncIterator] = function () { return this; }, i);\r\n function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }\r\n function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }\r\n}\r\n\r\nfunction __makeTemplateObject(cooked, raw) {\r\n if (Object.defineProperty) { Object.defineProperty(cooked, \"raw\", { value: raw }); } else { cooked.raw = raw; }\r\n return cooked;\r\n};\r\n\r\nfunction __importStar(mod) {\r\n if (mod && mod.__esModule) return mod;\r\n var result = {};\r\n if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];\r\n result.default = mod;\r\n return result;\r\n}\r\n\r\nfunction __importDefault(mod) {\r\n return (mod && mod.__esModule) ? mod : { default: mod };\r\n}\r\n\n\n//# sourceURL=webpack:///./node_modules/tslib/tslib.es6.js?");
/***/ }),
/***/ "./src/index.ts":

@@ -117,3 +105,3 @@ /*!**********************!*\

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.js\");\n/* harmony import */ var _Executor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Executor */ \"./src/modules/Executors/Executor.ts\");\n\r\n\r\n/**\r\n * This executor caches first run result and provides it for all subsequent calls.\r\n */\r\nvar CacheExecutor = /** @class */ (function (_super) {\r\n tslib__WEBPACK_IMPORTED_MODULE_0__[\"__extends\"](CacheExecutor, _super);\r\n function CacheExecutor() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.cachedPromise = null;\r\n return _this;\r\n }\r\n /**\r\n * Run command and cache promise.\r\n */\r\n CacheExecutor.prototype.run = function () {\r\n var parameters = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n parameters[_i] = arguments[_i];\r\n }\r\n if (!this.cachedPromise) {\r\n this.cachedPromise = _super.prototype.run.apply(this, parameters);\r\n }\r\n return this.cachedPromise;\r\n };\r\n /**\r\n * Run executor without cache. Promise will be put to cache though.\r\n */\r\n CacheExecutor.prototype.runFresh = function () {\r\n var parameters = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n parameters[_i] = arguments[_i];\r\n }\r\n this.cachedPromise = _super.prototype.run.apply(this, parameters);\r\n return this.cachedPromise;\r\n };\r\n /**\r\n * Just clean cache.\r\n */\r\n CacheExecutor.prototype.cleanCache = function () {\r\n this.cachedPromise = null;\r\n };\r\n return CacheExecutor;\r\n}(_Executor__WEBPACK_IMPORTED_MODULE_1__[\"default\"]));\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (CacheExecutor);\r\n\n\n//# sourceURL=webpack:///./src/modules/Executors/CacheExecutor.ts?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Executor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Executor */ \"./src/modules/Executors/Executor.ts\");\nvar __extends = (undefined && undefined.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\n\r\n/**\r\n * This executor caches first run result and provides it for all subsequent calls.\r\n */\r\nvar CacheExecutor = /** @class */ (function (_super) {\r\n __extends(CacheExecutor, _super);\r\n function CacheExecutor() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.cachedPromise = null;\r\n return _this;\r\n }\r\n /**\r\n * Run command and cache promise.\r\n */\r\n CacheExecutor.prototype.run = function () {\r\n var parameters = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n parameters[_i] = arguments[_i];\r\n }\r\n if (!this.cachedPromise) {\r\n this.cachedPromise = _super.prototype.run.apply(this, parameters);\r\n }\r\n return this.cachedPromise;\r\n };\r\n /**\r\n * Run executor without cache. Promise will be put to cache though.\r\n */\r\n CacheExecutor.prototype.runFresh = function () {\r\n var parameters = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n parameters[_i] = arguments[_i];\r\n }\r\n this.cachedPromise = _super.prototype.run.apply(this, parameters);\r\n return this.cachedPromise;\r\n };\r\n /**\r\n * Just clean cache.\r\n */\r\n CacheExecutor.prototype.cleanCache = function () {\r\n this.cachedPromise = null;\r\n };\r\n return CacheExecutor;\r\n}(_Executor__WEBPACK_IMPORTED_MODULE_0__[\"default\"]));\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (CacheExecutor);\r\n\n\n//# sourceURL=webpack:///./src/modules/Executors/CacheExecutor.ts?");

@@ -142,3 +130,3 @@ /***/ }),

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.js\");\n/* harmony import */ var _Executor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Executor */ \"./src/modules/Executors/Executor.ts\");\n\r\n\r\n/**\r\n * This executor will chain requests ladder-like.\r\n * Last one will always be executed.\r\n * For skipped requests the promise will never be resolved.\r\n */\r\nvar LadderExecutor = /** @class */ (function (_super) {\r\n tslib__WEBPACK_IMPORTED_MODULE_0__[\"__extends\"](LadderExecutor, _super);\r\n function LadderExecutor() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.trigger = null;\r\n return _this;\r\n }\r\n LadderExecutor.prototype.run = function () {\r\n var _this = this;\r\n var parameters = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n parameters[_i] = arguments[_i];\r\n }\r\n if (!this.isRunning) {\r\n var promise = _super.prototype.run.apply(this, parameters);\r\n promise.then(function () {\r\n _this.trigger && _this.trigger();\r\n _this.trigger = null;\r\n });\r\n return promise;\r\n }\r\n return new Promise(function (resolve) {\r\n _this.trigger = function () { return _this.run.apply(_this, parameters).then(resolve); };\r\n });\r\n };\r\n return LadderExecutor;\r\n}(_Executor__WEBPACK_IMPORTED_MODULE_1__[\"default\"]));\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (LadderExecutor);\r\n\n\n//# sourceURL=webpack:///./src/modules/Executors/LadderExecutor.ts?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Executor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Executor */ \"./src/modules/Executors/Executor.ts\");\nvar __extends = (undefined && undefined.__extends) || (function () {\r\n var extendStatics = Object.setPrototypeOf ||\r\n ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||\r\n function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };\r\n return function (d, b) {\r\n extendStatics(d, b);\r\n function __() { this.constructor = d; }\r\n d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());\r\n };\r\n})();\r\n\r\n/**\r\n * This executor will chain requests ladder-like.\r\n * Last one will always be executed.\r\n * For skipped requests the promise will never be resolved.\r\n */\r\nvar LadderExecutor = /** @class */ (function (_super) {\r\n __extends(LadderExecutor, _super);\r\n function LadderExecutor() {\r\n var _this = _super !== null && _super.apply(this, arguments) || this;\r\n _this.trigger = null;\r\n return _this;\r\n }\r\n LadderExecutor.prototype.run = function () {\r\n var _this = this;\r\n var parameters = [];\r\n for (var _i = 0; _i < arguments.length; _i++) {\r\n parameters[_i] = arguments[_i];\r\n }\r\n if (!this.isRunning) {\r\n var promise = _super.prototype.run.apply(this, parameters);\r\n promise.then(function () {\r\n _this.trigger && _this.trigger();\r\n _this.trigger = null;\r\n });\r\n return promise;\r\n }\r\n return new Promise(function (resolve) {\r\n _this.trigger = function () { return _this.run.apply(_this, parameters).then(resolve); };\r\n });\r\n };\r\n return LadderExecutor;\r\n}(_Executor__WEBPACK_IMPORTED_MODULE_0__[\"default\"]));\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (LadderExecutor);\r\n\n\n//# sourceURL=webpack:///./src/modules/Executors/LadderExecutor.ts?");

@@ -179,3 +167,3 @@ /***/ }),

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.js\");\n/* harmony import */ var _Executors_LadderExecutor__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Executors/LadderExecutor */ \"./src/modules/Executors/LadderExecutor.ts\");\n\r\n\r\nvar InfiniteLoader = /** @class */ (function () {\r\n function InfiniteLoader(run, perStep) {\r\n if (perStep === void 0) { perStep = 20; }\r\n var _this = this;\r\n this.items = [];\r\n this.isFinished = false;\r\n this.perStep = 20; // number of items to load\r\n this.pointer = 0;\r\n this.isFresh = true;\r\n this.executor = new _Executors_LadderExecutor__WEBPACK_IMPORTED_MODULE_1__[\"default\"](function () { return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"](_this, void 0, void 0, function () { return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"](this, function (_a) {\r\n switch (_a.label) {\r\n case 0: return [4 /*yield*/, this.runRequest(run)];\r\n case 1: return [2 /*return*/, _a.sent()];\r\n }\r\n }); }); });\r\n this.perStep = perStep;\r\n }\r\n Object.defineProperty(InfiniteLoader.prototype, \"isRunning\", {\r\n /**\r\n * Command from this executor is currently running.\r\n */\r\n get: function () {\r\n return this.executor.isRunning;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(InfiniteLoader.prototype, \"isEmpty\", {\r\n /**\r\n * We tried to load, but list is empty\r\n */\r\n get: function () {\r\n if (this.executor.isRunning) {\r\n return false;\r\n }\r\n return this.isFinished && (this.items.length === 0);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(InfiniteLoader.prototype, \"isFull\", {\r\n /**\r\n * We tried to load, and list is not empty\r\n */\r\n get: function () {\r\n return !!this.items.length;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(InfiniteLoader.prototype, \"isRefreshing\", {\r\n /**\r\n * Is loading anew. This could happen in two cases.\r\n * 1) Executor is running for the first time. Meaning the list is empty.\r\n * 2) Executor is refreshing. Meaning the list is not empty.\r\n */\r\n get: function () {\r\n return this.pointer === 0 && this.isRunning;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Loads a bunch of items\r\n */\r\n InfiniteLoader.prototype.next = function () {\r\n if (this.isRunning || this.isFinished) {\r\n return;\r\n }\r\n this.isFresh = false;\r\n this.executor.run();\r\n };\r\n InfiniteLoader.prototype.runRequest = function (pointerRequest) {\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"](this, void 0, void 0, function () {\r\n var expectedPointer, result, exception_1;\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"](this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 2, , 3]);\r\n expectedPointer = this.pointer + this.perStep;\r\n return [4 /*yield*/, pointerRequest(this.pointer, this.perStep)];\r\n case 1:\r\n result = _a.sent();\r\n if (!Array.isArray(result)) {\r\n console.warn('InfiniteLoader function must return array');\r\n return [2 /*return*/];\r\n }\r\n if (result.length < this.perStep) {\r\n this.isFinished = true;\r\n }\r\n this.pointer = expectedPointer;\r\n this.applyNew(result);\r\n return [3 /*break*/, 3];\r\n case 2:\r\n exception_1 = _a.sent();\r\n this.isFinished = true;\r\n throw exception_1;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Refresh the list.\r\n * This will replace current items with new ones after loading. Not clear the list immediately.\r\n */\r\n InfiniteLoader.prototype.refresh = function () {\r\n this.pointer = 0;\r\n this.isFresh = true;\r\n this.isFinished = false;\r\n this.executor.run();\r\n };\r\n InfiniteLoader.prototype.applyNew = function (items) {\r\n if (this.isFresh) {\r\n this.items = items;\r\n return;\r\n }\r\n this.items = this.items.concat(items);\r\n };\r\n return InfiniteLoader;\r\n}());\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (InfiniteLoader);\r\n\n\n//# sourceURL=webpack:///./src/modules/Loaders/InfiniteLoader.ts?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Executors_LadderExecutor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Executors/LadderExecutor */ \"./src/modules/Executors/LadderExecutor.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [0, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\n\r\nvar InfiniteLoader = /** @class */ (function () {\r\n function InfiniteLoader(run, perStep) {\r\n if (perStep === void 0) { perStep = 20; }\r\n this.items = [];\r\n this.isFinished = false;\r\n this.perStep = 20; // number of items to load\r\n this.pointer = 0;\r\n this.isFresh = true;\r\n this.executor = new _Executors_LadderExecutor__WEBPACK_IMPORTED_MODULE_0__[\"default\"](run);\r\n this.perStep = perStep;\r\n }\r\n Object.defineProperty(InfiniteLoader.prototype, \"isRunning\", {\r\n /**\r\n * Command from this executor is currently running.\r\n */\r\n get: function () {\r\n return this.executor.isRunning;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(InfiniteLoader.prototype, \"isEmpty\", {\r\n /**\r\n * We tried to load, but list is empty\r\n */\r\n get: function () {\r\n if (this.executor.isRunning) {\r\n return false;\r\n }\r\n return this.isFinished && (this.items.length === 0);\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(InfiniteLoader.prototype, \"isFull\", {\r\n /**\r\n * We tried to load, and list is not empty\r\n */\r\n get: function () {\r\n return !!this.items.length;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n Object.defineProperty(InfiniteLoader.prototype, \"isRefreshing\", {\r\n /**\r\n * Is loading anew. This could happen in two cases.\r\n * 1) Executor is running for the first time. Meaning the list is empty.\r\n * 2) Executor is refreshing. Meaning the list is not empty.\r\n */\r\n get: function () {\r\n return this.pointer === 0 && this.isRunning;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n /**\r\n * Loads a bunch of items\r\n */\r\n InfiniteLoader.prototype.next = function () {\r\n if (this.isRunning || this.isFinished) {\r\n return;\r\n }\r\n this.isFresh = false;\r\n this.runExecutor();\r\n };\r\n InfiniteLoader.prototype.runExecutor = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var result, exception_1;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n _a.trys.push([0, 2, , 3]);\r\n return [4 /*yield*/, this.executor.run(this.pointer, this.perStep)];\r\n case 1:\r\n result = _a.sent();\r\n if (!Array.isArray(result)) {\r\n console.warn('InfiniteLoader function must return array');\r\n return [2 /*return*/];\r\n }\r\n if (result.length < this.perStep) {\r\n this.isFinished = true;\r\n }\r\n this.pointer = this.pointer + this.perStep;\r\n this.applyNew(result);\r\n return [3 /*break*/, 3];\r\n case 2:\r\n exception_1 = _a.sent();\r\n this.isFinished = true;\r\n throw exception_1;\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n /**\r\n * Refresh the list.\r\n * This will replace current items with new ones after loading. Not clear the list immediately.\r\n */\r\n InfiniteLoader.prototype.refresh = function () {\r\n this.pointer = 0;\r\n this.isFresh = true;\r\n this.isFinished = false;\r\n this.runExecutor();\r\n };\r\n InfiniteLoader.prototype.applyNew = function (items) {\r\n if (this.isFresh) {\r\n this.items = items;\r\n return;\r\n }\r\n this.items = this.items.concat(items);\r\n };\r\n return InfiniteLoader;\r\n}());\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (InfiniteLoader);\r\n\n\n//# sourceURL=webpack:///./src/modules/Loaders/InfiniteLoader.ts?");

@@ -228,3 +216,3 @@ /***/ }),

"use strict";
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ \"./node_modules/tslib/tslib.es6.js\");\n/* harmony import */ var _Helpers_AsyncHelpers__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Helpers/AsyncHelpers */ \"./src/modules/Helpers/AsyncHelpers.ts\");\n\r\n\r\nvar RetrierExecutor = /** @class */ (function () {\r\n function RetrierExecutor(command, timeout, maxTime) {\r\n if (timeout === void 0) { timeout = 100; }\r\n if (maxTime === void 0) { maxTime = 1000; }\r\n this.iterationCount = 0;\r\n this.command = command;\r\n this.timeout = timeout;\r\n this.maxTime = maxTime;\r\n }\r\n /**\r\n * Shortcut to use executor functionally.\r\n */\r\n RetrierExecutor.waitUntil = function (command, timeout, maxTime) {\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"](this, void 0, void 0, function () {\r\n var executor;\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"](this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n executor = new RetrierExecutor(command, timeout, maxTime);\r\n return [4 /*yield*/, executor.run()];\r\n case 1:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n Object.defineProperty(RetrierExecutor.prototype, \"timeElapsed\", {\r\n get: function () {\r\n return this.timeout * this.iterationCount;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n RetrierExecutor.prototype.takesTooLong = function () {\r\n return this.timeElapsed > this.maxTime;\r\n };\r\n RetrierExecutor.prototype.run = function () {\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"](this, void 0, void 0, function () {\r\n var result;\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__generator\"](this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.iterationCount = 0;\r\n result = this.command();\r\n _a.label = 1;\r\n case 1:\r\n if (!!result) return [3 /*break*/, 3];\r\n return [4 /*yield*/, _Helpers_AsyncHelpers__WEBPACK_IMPORTED_MODULE_1__[\"default\"].sleep(this.timeout)];\r\n case 2:\r\n _a.sent();\r\n this.iterationCount++;\r\n if (this.takesTooLong()) {\r\n throw new Error(\"Max time (\" + this.maxTime + \") elapsed.\");\r\n }\r\n result = this.command();\r\n return [3 /*break*/, 1];\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n return RetrierExecutor;\r\n}());\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (RetrierExecutor);\r\n\n\n//# sourceURL=webpack:///./src/modules/Loaders/RetrierExecutor.ts?");
eval("__webpack_require__.r(__webpack_exports__);\n/* harmony import */ var _Helpers_AsyncHelpers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Helpers/AsyncHelpers */ \"./src/modules/Helpers/AsyncHelpers.ts\");\nvar __awaiter = (undefined && undefined.__awaiter) || function (thisArg, _arguments, P, generator) {\r\n return new (P || (P = Promise))(function (resolve, reject) {\r\n function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\r\n function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\r\n function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }\r\n step((generator = generator.apply(thisArg, _arguments || [])).next());\r\n });\r\n};\r\nvar __generator = (undefined && undefined.__generator) || function (thisArg, body) {\r\n var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;\r\n return g = { next: verb(0), \"throw\": verb(1), \"return\": verb(2) }, typeof Symbol === \"function\" && (g[Symbol.iterator] = function() { return this; }), g;\r\n function verb(n) { return function (v) { return step([n, v]); }; }\r\n function step(op) {\r\n if (f) throw new TypeError(\"Generator is already executing.\");\r\n while (_) try {\r\n if (f = 1, y && (t = y[op[0] & 2 ? \"return\" : op[0] ? \"throw\" : \"next\"]) && !(t = t.call(y, op[1])).done) return t;\r\n if (y = 0, t) op = [0, t.value];\r\n switch (op[0]) {\r\n case 0: case 1: t = op; break;\r\n case 4: _.label++; return { value: op[1], done: false };\r\n case 5: _.label++; y = op[1]; op = [0]; continue;\r\n case 7: op = _.ops.pop(); _.trys.pop(); continue;\r\n default:\r\n if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }\r\n if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }\r\n if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }\r\n if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }\r\n if (t[2]) _.ops.pop();\r\n _.trys.pop(); continue;\r\n }\r\n op = body.call(thisArg, _);\r\n } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }\r\n if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };\r\n }\r\n};\r\n\r\nvar RetrierExecutor = /** @class */ (function () {\r\n function RetrierExecutor(command, timeout, maxTime) {\r\n if (timeout === void 0) { timeout = 100; }\r\n if (maxTime === void 0) { maxTime = 1000; }\r\n this.iterationCount = 0;\r\n this.command = command;\r\n this.timeout = timeout;\r\n this.maxTime = maxTime;\r\n }\r\n /**\r\n * Shortcut to use executor functionally.\r\n */\r\n RetrierExecutor.waitUntil = function (command, timeout, maxTime) {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var executor;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n executor = new RetrierExecutor(command, timeout, maxTime);\r\n return [4 /*yield*/, executor.run()];\r\n case 1:\r\n _a.sent();\r\n return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n Object.defineProperty(RetrierExecutor.prototype, \"timeElapsed\", {\r\n get: function () {\r\n return this.timeout * this.iterationCount;\r\n },\r\n enumerable: true,\r\n configurable: true\r\n });\r\n RetrierExecutor.prototype.takesTooLong = function () {\r\n return this.timeElapsed > this.maxTime;\r\n };\r\n RetrierExecutor.prototype.run = function () {\r\n return __awaiter(this, void 0, void 0, function () {\r\n var result;\r\n return __generator(this, function (_a) {\r\n switch (_a.label) {\r\n case 0:\r\n this.iterationCount = 0;\r\n result = this.command();\r\n _a.label = 1;\r\n case 1:\r\n if (!!result) return [3 /*break*/, 3];\r\n return [4 /*yield*/, _Helpers_AsyncHelpers__WEBPACK_IMPORTED_MODULE_0__[\"default\"].sleep(this.timeout)];\r\n case 2:\r\n _a.sent();\r\n this.iterationCount++;\r\n if (this.takesTooLong()) {\r\n throw new Error(\"Max time (\" + this.maxTime + \") elapsed.\");\r\n }\r\n result = this.command();\r\n return [3 /*break*/, 1];\r\n case 3: return [2 /*return*/];\r\n }\r\n });\r\n });\r\n };\r\n return RetrierExecutor;\r\n}());\r\n/* harmony default export */ __webpack_exports__[\"default\"] = (RetrierExecutor);\r\n\n\n//# sourceURL=webpack:///./src/modules/Loaders/RetrierExecutor.ts?");

@@ -231,0 +219,0 @@ /***/ })

2

dist/src/modules/Loaders/InfiniteLoader.d.ts

@@ -33,3 +33,3 @@ import LadderExecutor from '../Executors/LadderExecutor';

next(): void;
protected runRequest(pointerRequest: PointerRequest): Promise<void>;
protected runExecutor(): Promise<void>;
/**

@@ -36,0 +36,0 @@ * Refresh the list.

@@ -0,0 +0,0 @@

{
"name": "asva-executors",
"version": "0.1.14",
"version": "0.1.15",
"description": "Helper classes for your async flow control",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -8,2 +8,3 @@ import LadderExecutor from '../Executors/LadderExecutor'

public isFinished: boolean = false
public isRefreshing: boolean = false

@@ -13,6 +14,8 @@ protected readonly executor: LadderExecutor

protected pointer: number = 0
// Means no runs were executed
protected isFresh: boolean = true
// Is currently running from 0 pointer
constructor (run: PointerRequest, perStep: number = 20) {
this.executor = new LadderExecutor(async () => await this.runRequest(run))
this.executor = new LadderExecutor(async (refresh = false) => await this.runRequest(run, refresh))
this.perStep = perStep

@@ -30,2 +33,3 @@ }

* We tried to load, but list is empty
* Is false when executor is loading or is fresh.
*/

@@ -41,4 +45,11 @@ get isEmpty (): boolean {

* We tried to load, and list is not empty
* Is false when executor is loading or is fresh.
*/
get isFull (): boolean {
if (this.isFresh) {
return false
}
if (this.executor.isRunning) {
return false
}
return !!this.items.length

@@ -48,26 +59,26 @@ }

/**
* Is loading anew. This could happen in two cases.
* 1) Executor is running for the first time. Meaning the list is empty.
* 2) Executor is refreshing. Meaning the list is not empty.
* Loads a bunch of items
*/
get isRefreshing (): boolean {
return this.pointer === 0 && this.isRunning
public next (): void {
this.executor.run()
}
/**
* Loads a bunch of items
* Refresh the list.
*/
public next (): void {
if (this.isRunning || this.isFinished) {
return
}
this.isFresh = false
this.executor.run()
public refresh (): void {
this.executor.run(true)
}
protected async runRequest (pointerRequest: PointerRequest): Promise<void> {
protected async runRequest (pointerRequest: PointerRequest, refresh = false): Promise<void> {
if (this.pointer === 0) {
refresh = true
}
if (refresh) {
this.pointer = 0
this.isFresh = true
this.isRefreshing = true
this.isFinished = false
}
try {
// We declare it here because concurrent reset might conflict when using increment
const expectedPointer = this.pointer + this.perStep
const result = await pointerRequest(this.pointer, this.perStep)

@@ -82,21 +93,14 @@

}
this.pointer = expectedPointer
this.applyNew(result)
this.pointer = this.pointer + this.perStep
this.isFresh = false
} catch (exception) {
this.isFinished = true
throw exception
} finally {
this.isRefreshing = false
}
}
/**
* Refresh the list.
* This will replace current items with new ones after loading. Not clear the list immediately.
*/
public refresh (): void {
this.pointer = 0
this.isFresh = true
this.isFinished = false
this.executor.run()
}
protected applyNew (items: any[]): void {

@@ -103,0 +107,0 @@ if (this.isFresh) {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc