asva-executors
Advanced tools
Comparing version 0.1.25 to 0.1.26
@@ -1,299 +0,2 @@ | ||
!function (t, e) { | ||
if ('object' == typeof exports && 'object' == typeof module) module.exports = e(require('tslib')) else if ('function' == typeof define && define.amd) define(['tslib'], e) else { | ||
var n = 'object' == typeof exports ? e(require('tslib')) : e(t.tslib) | ||
for (var i in n) ('object' == typeof exports ? exports : t)[i] = n[i] | ||
} | ||
}(Function('return this')(), (function (t) { | ||
return (() => { | ||
'use strict' | ||
var e = { | ||
780: e => { | ||
e.exports = t | ||
}, | ||
}, n = {} | ||
function i (t) { | ||
var r = n[t] | ||
if (void 0 !== r) return r.exports | ||
var o = n[t] = { exports: {} } | ||
return e[t](o, o.exports, i), o.exports | ||
} | ||
i.d = (t, e) => { | ||
for (var n in e) i.o(e, n) && !i.o(t, n) && Object.defineProperty(t, n, { | ||
enumerable: !0, | ||
get: e[n], | ||
}) | ||
}, i.o = (t, e) => Object.prototype.hasOwnProperty.call(t, e), i.r = t => { | ||
'undefined' != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, { value: 'Module' }), Object.defineProperty(t, '__esModule', { value: !0 }) | ||
} | ||
var r = {} | ||
return (() => { | ||
i.r(r), i.d(r, { | ||
CacheExecutor: () => n, | ||
DebounceLoader: () => s, | ||
Executor: () => e, | ||
InfiniteLoader: () => c, | ||
InfiniteLoaderFactory: () => f, | ||
LadderExecutor: () => o, | ||
RepeatLoader: () => u, | ||
RetrierExecutor: () => h, | ||
StatefulExecutor: () => l, | ||
}) | ||
var t = i(780) | ||
const e = function () { | ||
function t (t) { | ||
this.runCount = 0, this.wasLastRunFine = !1, this.wasRun = !1, this.wasRunFine = !1, this.wasRunBad = !1, this.command = t | ||
} | ||
return t.createAndRun = function (e) { | ||
var n = new t(e) | ||
return n.run(), n | ||
}, Object.defineProperty(t.prototype, 'isRunning', { | ||
get: function () { | ||
return !!this.runCount | ||
}, enumerable: !1, configurable: !0, | ||
}), t.prototype.run = function () { | ||
for (var t = [], e = 0; e < arguments.length; e++) t[e] = arguments[e] | ||
this.beforeRun() | ||
var n = this.command.apply(this, t) | ||
return this.afterRun(n), n | ||
}, t.prototype.beforeRun = function () { | ||
this.runCount++ | ||
}, t.prototype.afterRun = function (t) { | ||
var e = this | ||
t.then((function () { | ||
e.runCount--, e.setRunResultFlags(!0) | ||
})), t.catch((function () { | ||
e.runCount--, e.setRunResultFlags(!1) | ||
})) | ||
}, t.prototype.setRunResultFlags = function (t) { | ||
this.wasRun = !0, this.wasLastRunFine = t, t && (this.wasRunFine = !0), t || (this.wasRunBad = !0) | ||
}, t | ||
}(), n = function (e) { | ||
function n () { | ||
var t = null !== e && e.apply(this, arguments) || this | ||
return t.cachedPromise = null, t | ||
} | ||
return (0, t.__extends)(n, e), n.prototype.run = function () { | ||
for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n] | ||
return this.cachedPromise || (this.cachedPromise = e.prototype.run.apply(this, t)), this.cachedPromise | ||
}, n.prototype.runFresh = function () { | ||
for (var t = [], n = 0; n < arguments.length; n++) t[n] = arguments[n] | ||
return this.cachedPromise = e.prototype.run.apply(this, t), this.cachedPromise | ||
}, n.prototype.cleanCache = function () { | ||
this.cachedPromise = null | ||
}, n | ||
}(e), o = function (e) { | ||
function n () { | ||
var t = null !== e && e.apply(this, arguments) || this | ||
return t.trigger = null, t | ||
} | ||
return (0, t.__extends)(n, e), n.prototype.run = function () { | ||
for (var t = this, n = [], i = 0; i < arguments.length; i++) n[i] = arguments[i] | ||
if (!this.isRunning) { | ||
var r = e.prototype.run.apply(this, n) | ||
return r.then((function () { | ||
t.trigger && t.trigger(), t.trigger = null | ||
})), r | ||
} | ||
return new Promise((function (e) { | ||
t.trigger = function () { | ||
return t.run.apply(t, n).then(e) | ||
} | ||
})) | ||
}, n | ||
}(e), s = function () { | ||
function t (t, n) { | ||
void 0 === n && (n = 3e3), this.identityCheck = {}, this.isWaiting = !1, this.executor = new e(t), this.timeout = n | ||
} | ||
return Object.defineProperty(t.prototype, 'isRunning', { | ||
get: function () { | ||
return this.executor.isRunning | ||
}, enumerable: !1, configurable: !0, | ||
}), Object.defineProperty(t.prototype, 'isActive', { | ||
get: function () { | ||
return this.isRunning || this.isWaiting | ||
}, enumerable: !1, configurable: !0, | ||
}), t.prototype.run = function () { | ||
for (var t = this, e = [], n = 0; n < arguments.length; n++) e[n] = arguments[n] | ||
this.isWaiting = !0 | ||
var i = this.registerIdentity() | ||
setTimeout((function () { | ||
var n | ||
t.checkIdentity(i) && (t.isWaiting = !1, (n = t.executor).run.apply(n, e)) | ||
}), this.timeout) | ||
}, t.prototype.reset = function () { | ||
this.isWaiting = !1, this.identityCheck = {} | ||
}, t.prototype.registerIdentity = function () { | ||
return this.identityCheck = {}, this.identityCheck | ||
}, t.prototype.checkIdentity = function (t) { | ||
return this.identityCheck === t | ||
}, t | ||
}(), u = function () { | ||
function t (t, e) { | ||
this.time = 100, this.id = null, this.command = t, this.time = e | ||
} | ||
return t.prototype.start = function () { | ||
this.id || (this.id = setInterval(this.command, this.time)) | ||
}, t.prototype.stop = function () { | ||
this.id && clearInterval(this.id), this.id = null | ||
}, t | ||
}(), c = function () { | ||
function e (e, n) { | ||
var i = this | ||
void 0 === n && (n = 20), this.items = [], this.isFinished = !1, this.isRefreshing = !1, this.perStep = 20, this.pointer = 0, this.isFresh = !0, this.executor = new o((function (n) { | ||
return void 0 === n && (n = !1), (0, t.__awaiter)(i, void 0, void 0, (function () { | ||
return (0, t.__generator)(this, (function (t) { | ||
switch (t.label) { | ||
case 0: | ||
return [4, this.runRequest(e, n)] | ||
case 1: | ||
return [2, t.sent()] | ||
} | ||
})) | ||
})) | ||
})), this.perStep = n | ||
} | ||
return Object.defineProperty(e.prototype, 'isRunning', { | ||
get: function () { | ||
return this.executor.isRunning | ||
}, enumerable: !1, configurable: !0, | ||
}), Object.defineProperty(e.prototype, 'isEmpty', { | ||
get: function () { | ||
return !this.executor.isRunning && this.isFinished && 0 === this.items.length | ||
}, enumerable: !1, configurable: !0, | ||
}), Object.defineProperty(e.prototype, 'isFull', { | ||
get: function () { | ||
return !this.isFresh && !this.executor.isRunning && !!this.items.length | ||
}, enumerable: !1, configurable: !0, | ||
}), e.prototype.next = function () { | ||
this.executor.run() | ||
}, e.prototype.refresh = function () { | ||
this.executor.run(!0) | ||
}, e.prototype.runRequest = function (e, n) { | ||
return void 0 === n && (n = !1), (0, t.__awaiter)(this, void 0, void 0, (function () { | ||
var i, r | ||
return (0, t.__generator)(this, (function (t) { | ||
switch (t.label) { | ||
case 0: | ||
0 === this.pointer && (n = !0), n && (this.pointer = 0, this.isFresh = !0, this.isRefreshing = !0, this.isFinished = !1), t.label = 1 | ||
case 1: | ||
return t.trys.push([1, 3, 4, 5]), [4, e(this.pointer, this.perStep)] | ||
case 2: | ||
return i = t.sent(), Array.isArray(i) ? (i.length < this.perStep && (this.isFinished = !0), this.applyNew(i), this.pointer = this.pointer + this.perStep, this.isFresh = !1, [3, 5]) : (console.warn('InfiniteLoader function must return array'), [2]) | ||
case 3: | ||
throw r = t.sent(), this.isFinished = !0, r | ||
case 4: | ||
return this.isRefreshing = !1, [7] | ||
case 5: | ||
return [2] | ||
} | ||
})) | ||
})) | ||
}, e.prototype.applyNew = function (e) { | ||
this.isFresh ? this.items = e : this.items = (0, t.__spreadArray)((0, t.__spreadArray)([], this.items), e) | ||
}, e | ||
}(), a = function () { | ||
function t () { | ||
} | ||
return t.sleep = function (t) { | ||
return new Promise((function (e) { | ||
return setTimeout(e, t) | ||
})) | ||
}, t | ||
}(), h = function () { | ||
function e (t, e, n) { | ||
void 0 === e && (e = 100), void 0 === n && (n = 1e3), this.iterationCount = 0, this.command = t, this.timeout = e, this.maxTime = n | ||
} | ||
return e.waitUntil = function (n, i, r) { | ||
return (0, t.__awaiter)(this, void 0, void 0, (function () { | ||
return (0, t.__generator)(this, (function (t) { | ||
switch (t.label) { | ||
case 0: | ||
return [4, new e(n, i, r).run()] | ||
case 1: | ||
return t.sent(), [2] | ||
} | ||
})) | ||
})) | ||
}, Object.defineProperty(e.prototype, 'timeElapsed', { | ||
get: function () { | ||
return this.timeout * this.iterationCount | ||
}, enumerable: !1, configurable: !0, | ||
}), e.prototype.takesTooLong = function () { | ||
return this.timeElapsed > this.maxTime | ||
}, e.prototype.run = function () { | ||
return (0, t.__awaiter)(this, void 0, void 0, (function () { | ||
var e | ||
return (0, t.__generator)(this, (function (t) { | ||
switch (t.label) { | ||
case 0: | ||
this.iterationCount = 0, e = this.command(), t.label = 1 | ||
case 1: | ||
return e ? [3, 3] : [4, a.sleep(this.timeout)] | ||
case 2: | ||
if (t.sent(), this.iterationCount++, this.takesTooLong()) throw new Error('Max time (' + this.maxTime + ') elapsed.') | ||
return e = this.command(), [3, 1] | ||
case 3: | ||
return [2] | ||
} | ||
})) | ||
})) | ||
}, e | ||
}(), p = function () { | ||
function t () { | ||
} | ||
return t.getPointerRequest = function (t) { | ||
return void 0 === t && (t = 100), function (e, n) { | ||
return new Promise((function (i) { | ||
setTimeout((function () { | ||
var t | ||
i((t = e, Array(e + n - t).fill(0).map((function (e, n) { | ||
return t + n | ||
})))) | ||
}), t) | ||
})) | ||
} | ||
}, t | ||
}() | ||
var f = function () { | ||
function t () { | ||
} | ||
return t.createNumberedList = function (t) { | ||
void 0 === t && (t = 300) | ||
var e = p.getPointerRequest(t) | ||
return new c(e, 10) | ||
}, t | ||
}(), l = function (e) { | ||
function n (t, n) { | ||
void 0 === n && (n = null) | ||
var i = e.call(this, t) || this | ||
return i.state = n, i | ||
} | ||
return (0, t.__extends)(n, e), n.createAndRun = function (t, e) { | ||
void 0 === e && (e = null) | ||
var i = new n(t, e) | ||
return i.run(), i | ||
}, n.prototype.run = function () { | ||
for (var t = this, n = [], i = 0; i < arguments.length; i++) n[i] = arguments[i] | ||
var r = e.prototype.run.apply(this, n) | ||
return r.then((function (e) { | ||
t.state = e | ||
})), r | ||
}, n | ||
}(e) | ||
})(), r | ||
})() | ||
})) | ||
//# sourceMappingURL=index.js.map | ||
!function(t,e){if("object"==typeof exports&&"object"==typeof module)module.exports=e(require("tslib"));else if("function"==typeof define&&define.amd)define(["tslib"],e);else{var n="object"==typeof exports?e(require("tslib")):e(t.tslib);for(var i in n)("object"==typeof exports?exports:t)[i]=n[i]}}(Function("return this")(),(function(t){return(()=>{"use strict";var e={780:e=>{e.exports=t}},n={};function i(t){var r=n[t];if(void 0!==r)return r.exports;var o=n[t]={exports:{}};return e[t](o,o.exports,i),o.exports}i.d=(t,e)=>{for(var n in e)i.o(e,n)&&!i.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},i.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),i.r=t=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})};var r={};return(()=>{i.r(r),i.d(r,{CacheExecutor:()=>n,DebounceLoader:()=>s,Executor:()=>e,InfiniteLoader:()=>c,InfiniteLoaderFactory:()=>f,LadderExecutor:()=>o,RepeatLoader:()=>u,RetrierExecutor:()=>h,StatefulExecutor:()=>l});var t=i(780);const e=function(){function t(t){this.runCount=0,this.wasLastRunFine=!1,this.wasRun=!1,this.wasRunFine=!1,this.wasRunBad=!1,this.command=t}return t.createAndRun=function(e){var n=new t(e);return n.run(),n},Object.defineProperty(t.prototype,"isRunning",{get:function(){return!!this.runCount},enumerable:!1,configurable:!0}),t.prototype.run=function(){for(var t=[],e=0;e<arguments.length;e++)t[e]=arguments[e];this.beforeRun();var n=this.command.apply(this,t);return this.afterRun(n),n},t.prototype.beforeRun=function(){this.runCount++},t.prototype.afterRun=function(t){var e=this;t.then((function(){e.runCount--,e.setRunResultFlags(!0)})),t.catch((function(){e.runCount--,e.setRunResultFlags(!1)}))},t.prototype.setRunResultFlags=function(t){this.wasRun=!0,this.wasLastRunFine=t,t&&(this.wasRunFine=!0),t||(this.wasRunBad=!0)},t}(),n=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.cachedPromise=null,t}return(0,t.__extends)(n,e),n.prototype.run=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this.cachedPromise||(this.cachedPromise=e.prototype.run.apply(this,t)),this.cachedPromise},n.prototype.runFresh=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return this.cachedPromise=e.prototype.run.apply(this,t),this.cachedPromise},n.prototype.cleanCache=function(){this.cachedPromise=null},n}(e),o=function(e){function n(){var t=null!==e&&e.apply(this,arguments)||this;return t.trigger=null,t}return(0,t.__extends)(n,e),n.prototype.run=function(){for(var t=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];if(!this.isRunning){var r=e.prototype.run.apply(this,n);return r.then((function(){t.trigger&&t.trigger(),t.trigger=null})),r}return new Promise((function(e){t.trigger=function(){return t.run.apply(t,n).then(e)}}))},n}(e),s=function(){function t(t,n){void 0===n&&(n=3e3),this.identityCheck={},this.isWaiting=!1,this.executor=new e(t),this.timeout=n}return Object.defineProperty(t.prototype,"isRunning",{get:function(){return this.executor.isRunning},enumerable:!1,configurable:!0}),Object.defineProperty(t.prototype,"isActive",{get:function(){return this.isRunning||this.isWaiting},enumerable:!1,configurable:!0}),t.prototype.run=function(){for(var t=this,e=[],n=0;n<arguments.length;n++)e[n]=arguments[n];this.isWaiting=!0;var i=this.registerIdentity();setTimeout((function(){var n;t.checkIdentity(i)&&(t.isWaiting=!1,(n=t.executor).run.apply(n,e))}),this.timeout)},t.prototype.reset=function(){this.isWaiting=!1,this.identityCheck={}},t.prototype.registerIdentity=function(){return this.identityCheck={},this.identityCheck},t.prototype.checkIdentity=function(t){return this.identityCheck===t},t}(),u=function(){function t(t,e){this.time=100,this.id=null,this.command=t,this.time=e}return t.prototype.start=function(){this.id||(this.id=setInterval(this.command,this.time))},t.prototype.stop=function(){this.id&&clearInterval(this.id),this.id=null},t}(),c=function(){function e(e,n){var i=this;void 0===n&&(n=20),this.items=[],this.isFinished=!1,this.isRefreshing=!1,this.perStep=20,this.pointer=0,this.isFresh=!0,this.executor=new o((function(n){return void 0===n&&(n=!1),(0,t.__awaiter)(i,void 0,void 0,(function(){return(0,t.__generator)(this,(function(t){switch(t.label){case 0:return[4,this.runRequest(e,n)];case 1:return[2,t.sent()]}}))}))})),this.perStep=n}return Object.defineProperty(e.prototype,"isRunning",{get:function(){return this.executor.isRunning},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isEmpty",{get:function(){return!this.executor.isRunning&&this.isFinished&&0===this.items.length},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"isFull",{get:function(){return!this.isFresh&&!this.executor.isRunning&&!!this.items.length},enumerable:!1,configurable:!0}),e.prototype.next=function(){this.executor.run()},e.prototype.refresh=function(){this.executor.run(!0)},e.prototype.runRequest=function(e,n){return void 0===n&&(n=!1),(0,t.__awaiter)(this,void 0,void 0,(function(){var i,r;return(0,t.__generator)(this,(function(t){switch(t.label){case 0:0===this.pointer&&(n=!0),n&&(this.pointer=0,this.isFresh=!0,this.isRefreshing=!0,this.isFinished=!1),t.label=1;case 1:return t.trys.push([1,3,4,5]),[4,e(this.pointer,this.perStep)];case 2:return i=t.sent(),Array.isArray(i)?(i.length<this.perStep&&(this.isFinished=!0),this.applyNew(i),this.pointer=this.pointer+this.perStep,this.isFresh=!1,[3,5]):(console.warn("InfiniteLoader function must return array"),[2]);case 3:throw r=t.sent(),this.isFinished=!0,r;case 4:return this.isRefreshing=!1,[7];case 5:return[2]}}))}))},e.prototype.applyNew=function(e){this.isFresh?this.items=e:this.items=(0,t.__spreadArray)((0,t.__spreadArray)([],this.items),e)},e}(),a=function(){function t(){}return t.sleep=function(t){return new Promise((function(e){return setTimeout(e,t)}))},t}(),h=function(){function e(t,e,n){void 0===e&&(e=100),void 0===n&&(n=1e3),this.iterationCount=0,this.command=t,this.timeout=e,this.maxTime=n}return e.waitUntil=function(n,i,r){return(0,t.__awaiter)(this,void 0,void 0,(function(){return(0,t.__generator)(this,(function(t){switch(t.label){case 0:return[4,new e(n,i,r).run()];case 1:return t.sent(),[2]}}))}))},Object.defineProperty(e.prototype,"timeElapsed",{get:function(){return this.timeout*this.iterationCount},enumerable:!1,configurable:!0}),e.prototype.takesTooLong=function(){return this.timeElapsed>this.maxTime},e.prototype.run=function(){return(0,t.__awaiter)(this,void 0,void 0,(function(){var e;return(0,t.__generator)(this,(function(t){switch(t.label){case 0:this.iterationCount=0,e=this.command(),t.label=1;case 1:return e?[3,3]:[4,a.sleep(this.timeout)];case 2:if(t.sent(),this.iterationCount++,this.takesTooLong())throw new Error("Max time ("+this.maxTime+") elapsed.");return e=this.command(),[3,1];case 3:return[2]}}))}))},e}(),p=function(){function t(){}return t.getPointerRequest=function(t){return void 0===t&&(t=100),function(e,n){return new Promise((function(i){setTimeout((function(){var t;i((t=e,Array(e+n-t).fill(0).map((function(e,n){return t+n}))))}),t)}))}},t}();var f=function(){function t(){}return t.createNumberedList=function(t){void 0===t&&(t=300);var e=p.getPointerRequest(t);return new c(e,10)},t}(),l=function(e){function n(t,n){void 0===n&&(n=null);var i=e.call(this,t)||this;return i.state=n,i}return(0,t.__extends)(n,e),n.createAndRun=function(t,e){void 0===e&&(e=null);var i=new n(t,e);return i.run(),i},n.prototype.run=function(){for(var t=this,n=[],i=0;i<arguments.length;i++)n[i]=arguments[i];var r=e.prototype.run.apply(this,n);return r.then((function(e){t.state=e})),r},n}(e)})(),r})()})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "asva-executors", | ||
"version": "0.1.25", | ||
"version": "0.1.26", | ||
"description": "Helper classes for your async flow control", | ||
@@ -12,3 +12,3 @@ "main": "dist/src/index.js", | ||
"scripts": { | ||
"build": "yarn build-webpack & yarn build-rollup", | ||
"build": "yarn build-webpack && yarn build-rollup", | ||
"build-webpack": "webpack --progress --config src/build/webpack-config-build.js", | ||
@@ -32,4 +32,6 @@ "build-rollup": "rollup -c", | ||
"homepage": "https://github.com/asvae/executors#readme", | ||
"peerDependencies": { | ||
"tslib": "^2.2.0" | ||
}, | ||
"devDependencies": { | ||
"tslib": "^2.2.0", | ||
"@types/jasmine": "^3.7.6", | ||
@@ -52,4 +54,7 @@ "@types/node": "^15.9.0", | ||
"requirejs": "^2.3.5", | ||
"rollup": "^2.51.1", | ||
"rollup-plugin-typescript": "^1.0.1", | ||
"rollup-plugin-uglify": "^6.0.4", | ||
"ts-loader": "^9.2.2", | ||
"tslib": "^2.2.0", | ||
"typedoc": "^0.20.36", | ||
@@ -56,0 +61,0 @@ "typescript": "^4.3.2", |
import typescriptPlugin from 'rollup-plugin-typescript' | ||
import typescript from 'typescript' | ||
import { uglify } from "rollup-plugin-uglify"; | ||
@@ -12,4 +13,5 @@ export default { | ||
typescriptPlugin({typescript}), | ||
uglify() | ||
], | ||
external: ['tslib'], | ||
} |
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
Uses eval
Supply chain riskPackage uses dynamic code execution (e.g., eval()), which is a dangerous practice. This can prevent the code from running in certain environments and increases the risk that the code may contain exploits or malicious behavior.
Found 1 instance in 1 package
79620
44
1
27
914
2