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-beta.1 to 0.1.14-beta.2

43

dist/src/index.esm.js

@@ -246,8 +246,11 @@ import { __extends, __awaiter, __generator } from 'tslib';

this.isFresh = true;
this.executor = new LadderExecutor(function () { return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.runRequest(run)];
case 1: return [2 /*return*/, _a.sent()];
}
}); }); });
this.executor = new LadderExecutor(function (refresh) {
if (refresh === void 0) { refresh = false; }
return __awaiter(_this, void 0, void 0, function () { return __generator(this, function (_a) {
switch (_a.label) {
case 0: return [4 /*yield*/, this.runRequest(run, refresh)];
case 1: return [2 /*return*/, _a.sent()];
}
}); });
});
this.perStep = perStep;

@@ -310,3 +313,4 @@ }

};
InfiniteLoader.prototype.runRequest = function (pointerRequest) {
InfiniteLoader.prototype.runRequest = function (pointerRequest, refresh) {
if (refresh === void 0) { refresh = false; }
return __awaiter(this, void 0, void 0, function () {

@@ -317,6 +321,9 @@ var expectedPointer, result, exception_1;

case 0:
_a.trys.push([0, 2, , 3]);
console.log('SP', this.pointer);
_a.label = 1;
case 1:
_a.trys.push([1, 3, , 4]);
expectedPointer = this.pointer + this.perStep;
return [4 /*yield*/, pointerRequest(this.pointer, this.perStep)];
case 1:
case 2:
result = _a.sent();

@@ -330,10 +337,18 @@ if (!Array.isArray(result)) {

}
this.pointer = expectedPointer;
if (refresh) {
this.pointer = this.perStep;
this.isFresh = true;
this.isFinished = false;
}
else {
this.pointer = expectedPointer;
}
console.log('EP', this.pointer);
this.applyNew(result);
return [3 /*break*/, 3];
case 2:
return [3 /*break*/, 4];
case 3:
exception_1 = _a.sent();
this.isFinished = true;
throw exception_1;
case 3: return [2 /*return*/];
case 4: return [2 /*return*/];
}

@@ -351,3 +366,3 @@ });

this.isFinished = false;
this.executor.run();
this.executor.run(true);
};

@@ -354,0 +369,0 @@ InfiniteLoader.prototype.applyNew = function (items) {

@@ -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 () { 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 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?");

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

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

next(): void;
protected runRequest(pointerRequest: PointerRequest): Promise<void>;
protected runRequest(pointerRequest: PointerRequest, refresh?: boolean): Promise<void>;
/**

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

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

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

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

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

@@ -65,3 +65,4 @@ }

protected async runRequest (pointerRequest: PointerRequest): Promise<void> {
protected async runRequest (pointerRequest: PointerRequest, refresh = false): Promise<void> {
console.log('SP', this.pointer)
try {

@@ -79,3 +80,10 @@ // We declare it here because concurrent reset might conflict when using increment

}
this.pointer = expectedPointer
if ( refresh ) {
this.pointer = this.perStep
this.isFresh = true
this.isFinished = false
} else {
this.pointer = expectedPointer
}
console.log('EP', this.pointer)
this.applyNew(result)

@@ -96,3 +104,3 @@ } catch (exception) {

this.isFinished = false
this.executor.run()
this.executor.run(true)
}

@@ -99,0 +107,0 @@

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