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

asva-executors

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

asva-executors - npm Package Compare versions

Comparing version

to
0.1.14-beta.3

@@ -315,3 +315,3 @@ import { __extends, __awaiter, __generator } from 'tslib';

return __awaiter(this, void 0, void 0, function () {
var expectedPointer, result, exception_1;
var pointer, result, exception_1;
return __generator(this, function (_a) {

@@ -324,4 +324,4 @@ switch (_a.label) {

_a.trys.push([1, 3, , 4]);
expectedPointer = this.pointer + this.perStep;
return [4 /*yield*/, pointerRequest(this.pointer, this.perStep)];
pointer = refresh ? this.pointer : 0;
return [4 /*yield*/, pointerRequest(pointer, this.perStep)];
case 2:

@@ -337,3 +337,2 @@ result = _a.sent();

if (refresh) {
this.pointer = this.perStep;
this.isFresh = true;

@@ -343,3 +342,3 @@ this.isFinished = false;

else {
this.pointer = expectedPointer;
this.pointer = pointer + this.perStep;
}

@@ -346,0 +345,0 @@ console.log('EP', this.pointer);

@@ -176,3 +176,3 @@ (function webpackUniversalModuleDefinition(root, factory) {

"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 (refresh) {\r\n if (refresh === void 0) { refresh = false; }\r\n 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, refresh)];\r\n case 1: return [2 /*return*/, _a.sent()];\r\n }\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, refresh) {\r\n if (refresh === void 0) { refresh = false; }\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 console.log('SP', this.pointer);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n expectedPointer = this.pointer + this.perStep;\r\n return [4 /*yield*/, pointerRequest(this.pointer, this.perStep)];\r\n case 2:\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 if (refresh) {\r\n this.pointer = this.perStep;\r\n this.isFresh = true;\r\n this.isFinished = false;\r\n }\r\n else {\r\n this.pointer = expectedPointer;\r\n }\r\n console.log('EP', this.pointer);\r\n this.applyNew(result);\r\n return [3 /*break*/, 4];\r\n case 3:\r\n exception_1 = _a.sent();\r\n this.isFinished = true;\r\n throw exception_1;\r\n case 4: 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(true);\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 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 (refresh) {\r\n if (refresh === void 0) { refresh = false; }\r\n 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, refresh)];\r\n case 1: return [2 /*return*/, _a.sent()];\r\n }\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, refresh) {\r\n if (refresh === void 0) { refresh = false; }\r\n return tslib__WEBPACK_IMPORTED_MODULE_0__[\"__awaiter\"](this, void 0, void 0, function () {\r\n var pointer, 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 console.log('SP', this.pointer);\r\n _a.label = 1;\r\n case 1:\r\n _a.trys.push([1, 3, , 4]);\r\n pointer = refresh ? this.pointer : 0;\r\n return [4 /*yield*/, pointerRequest(pointer, this.perStep)];\r\n case 2:\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 if (refresh) {\r\n this.isFresh = true;\r\n this.isFinished = false;\r\n }\r\n else {\r\n this.pointer = pointer + this.perStep;\r\n }\r\n console.log('EP', this.pointer);\r\n this.applyNew(result);\r\n return [3 /*break*/, 4];\r\n case 3:\r\n exception_1 = _a.sent();\r\n this.isFinished = true;\r\n throw exception_1;\r\n case 4: 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(true);\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?");

@@ -179,0 +179,0 @@ /***/ }),

{
"name": "asva-executors",
"version": "0.1.14-beta.2",
"version": "0.1.14-beta.3",
"description": "Helper classes for your async flow control",

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

@@ -67,5 +67,4 @@ import LadderExecutor from '../Executors/LadderExecutor'

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)
const pointer = refresh ? this.pointer : 0
const result = await pointerRequest(pointer, this.perStep)

@@ -80,7 +79,6 @@ if (!Array.isArray(result)) {

if ( refresh ) {
this.pointer = this.perStep
this.isFresh = true
this.isFinished = false
} else {
this.pointer = expectedPointer
this.pointer = pointer + this.perStep
}

@@ -87,0 +85,0 @@ console.log('EP', this.pointer)