@statx/utils
Advanced tools
| export {}; |
+24
| export const throttled = /*#__PURE__*/ (time, df) => { | ||
| let timer; | ||
| let lastArgs; | ||
| let lastCall = 0; | ||
| const f = ((...args) => { | ||
| const currtime = Date.now(); | ||
| const diffTime = currtime - lastCall; | ||
| if (diffTime > time) { | ||
| df(...args); | ||
| lastCall = currtime; | ||
| } | ||
| else { | ||
| lastArgs = args; | ||
| if (!timer) { | ||
| timer = setTimeout(() => { | ||
| f(lastArgs); | ||
| timer = null; | ||
| }, diffTime); | ||
| } | ||
| } | ||
| }); | ||
| return f; | ||
| }; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,SAAS,GAAG,aAAa,CAAC,CAAoC,IAAY,EAAE,EAAK,EAAK,EAAE;IACnG,IAAI,KAAU,CAAA;IACd,IAAI,QAAe,CAAA;IACnB,IAAI,QAAQ,GAAG,CAAC,CAAA;IAEhB,MAAM,CAAC,GAAG,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE;QACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,CAAA;QAC3B,MAAM,QAAQ,GAAG,QAAQ,GAAG,QAAQ,CAAA;QACpC,IAAI,QAAQ,GAAG,IAAI,EAAE;YACnB,EAAE,CAAC,GAAG,IAAI,CAAC,CAAA;YACX,QAAQ,GAAG,QAAQ,CAAA;SACpB;aAAM;YACL,QAAQ,GAAG,IAAI,CAAA;YACf,IAAI,CAAC,KAAK,EAAE;gBACV,KAAK,GAAG,UAAU,CAAC,GAAG,EAAE;oBACtB,CAAC,CAAC,QAAQ,CAAC,CAAA;oBACX,KAAK,GAAG,IAAI,CAAA;gBACd,CAAC,EAAE,QAAQ,CAAC,CAAA;aACb;SACF;IACH,CAAC,CAAM,CAAA;IAEP,OAAO,CAAC,CAAA;AACV,CAAC,CAAA"} |
| import { test } from 'uvu'; | ||
| test(`base API`, async () => { | ||
| //assert.ok(false, `You forgot test you code`) | ||
| }); | ||
| test.run(); | ||
| //# sourceMappingURL=index.test.js.map |
| {"version":3,"file":"index.test.js","sourceRoot":"","sources":["index.test.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,IAAI,EAAC,MAAM,KAAK,CAAA;AAExB,IAAI,CAAC,UAAU,EAAE,KAAK,IAAI,EAAE;IAC1B,8CAA8C;AAChD,CAAC,CAAC,CAAA;AAEF,IAAI,CAAC,GAAG,EAAE,CAAA"} |
+6
-12
| { | ||
| "name": "@statx/utils", | ||
| "version": "1.1.1", | ||
| "version": "1.1.2", | ||
| "private": false, | ||
@@ -27,10 +27,6 @@ "description": "Extry tiny smart statx manager", | ||
| "exports": { | ||
| "require": "./build/index.js", | ||
| "types": "./build/index.d.ts", | ||
| "default": "./build/index.module.js" | ||
| "default": "./build/index.js" | ||
| }, | ||
| "main": "./build/index.js", | ||
| "module": "./build/index.module.js", | ||
| "unpkg": "./build/index.umd.js", | ||
| "types": "./build/index.d.ts", | ||
| "type": "module", | ||
| "source": "./src/index.ts", | ||
@@ -44,6 +40,4 @@ "files": [ | ||
| "scripts": { | ||
| "build": "rimraf ./build/ && npm run build:mb", | ||
| "build:parcel": "parcel build --target=build", | ||
| "build:mb": "microbundle", | ||
| "build:types": "tsc", | ||
| "build": "rimraf ./build/ && npm run build:tsc", | ||
| "build:tsc": "tsc", | ||
| "test": "tsx src/index.test.ts", | ||
@@ -65,3 +59,3 @@ "test:watch": "tsx watch src/index.test.ts" | ||
| }, | ||
| "gitHead": "1bcd35b45ca323a401ef0a3aaee075c0f00e2595" | ||
| "gitHead": "5380557359b61c2a26603869a555e10b7e2a0d12" | ||
| } |
| exports.throttled=(t,e)=>{let l,n,o=0;const c=function(){var r=[].slice.call(arguments);const s=Date.now(),u=s-o;u>t?(e(...r),o=s):(n=r,l||(l=setTimeout(()=>{c(n),l=null},u)))};return c}; | ||
| //# sourceMappingURL=index.js.map |
| exports.throttled=(t,e)=>{let l,n,o=0;const c=function(){var r=[].slice.call(arguments);const s=Date.now(),u=s-o;u>t?(e(...r),o=s):(n=r,l||(l=setTimeout(()=>{c(n),l=null},u)))};return c}; | ||
| //# sourceMappingURL=index.js.map |
| {"version":3,"file":"index.js","sources":["../src/index.ts"],"sourcesContent":["export const throttled = /*#__PURE__*/ <F extends (...args: any[]) => any>(time: number, df: F): F => {\r\n let timer: any\r\n let lastArgs: any[]\r\n let lastCall = 0\r\n\r\n const f = ((...args) => {\r\n const currtime = Date.now()\r\n const diffTime = currtime - lastCall\r\n if (diffTime > time) {\r\n df(...args)\r\n lastCall = currtime\r\n } else {\r\n lastArgs = args\r\n if (!timer) {\r\n timer = setTimeout(() => {\r\n f(lastArgs)\r\n timer = null\r\n }, diffTime)\r\n }\r\n }\r\n }) as F\r\n\r\n return f\r\n}\r\n"],"names":["time","df","f","slice","call","arguments","Date","now","diffTime","currtime","lastCall","args","lastArgs","timer","setTimeout"],"mappings":"kBAAuC,CAAoCA,EAAcC,KACvF,UAEe,EAEf,MAAMC,EAAK,WAAY,MACrB,GAAAC,MAAAC,KAAAC,WAAA,QAAiBC,KAAKC,MAChBC,EAAWC,EAAWC,EACxBF,EAAWR,GACbC,KAAMU,GACND,EAAWD,IAEXG,EAAWD,EACNE,IACHA,EAAQC,WAAW,KACjBZ,EAAEU,GACFC,EAAQ,IAAA,EACPL,IAGT,EAEA,OAAON"} |
| const t=(t,e)=>{let n,o,s=0;const c=(...l)=>{const r=Date.now(),u=r-s;u>t?(e(...l),s=r):(o=l,n||(n=setTimeout(()=>{c(o),n=null},u)))};return c};export{t as throttled}; | ||
| //# sourceMappingURL=index.modern.mjs.map |
| {"version":3,"file":"index.modern.mjs","sources":["../src/index.ts"],"sourcesContent":["export const throttled = /*#__PURE__*/ <F extends (...args: any[]) => any>(time: number, df: F): F => {\r\n let timer: any\r\n let lastArgs: any[]\r\n let lastCall = 0\r\n\r\n const f = ((...args) => {\r\n const currtime = Date.now()\r\n const diffTime = currtime - lastCall\r\n if (diffTime > time) {\r\n df(...args)\r\n lastCall = currtime\r\n } else {\r\n lastArgs = args\r\n if (!timer) {\r\n timer = setTimeout(() => {\r\n f(lastArgs)\r\n timer = null\r\n }, diffTime)\r\n }\r\n }\r\n }) as F\r\n\r\n return f\r\n}\r\n"],"names":["throttled","time","df","f","args","currtime","Date","now","lastCall","diffTime","lastArgs","timer","setTimeout"],"mappings":"AAAaA,QAA0B,CAAoCC,EAAcC,KACvF,UAEe,EAEf,MAAMC,EAAK,IAAIC,KACb,MAAcC,EAAGC,KAAKC,QACLF,EAAWG,EACxBC,EAAWR,GACbC,KAAME,GACNI,EAAWH,IAEXK,EAAWN,EACNO,IACHA,EAAQC,WAAW,KACjBT,EAAEO,GACFC,EAAQ,MACPF,IAEN,EAGH,OAAON"} |
| const t=(t,n)=>{let e,o,c=0;const l=function(){var s=[].slice.call(arguments);const r=Date.now(),u=r-c;u>t?(n(...s),c=r):(o=s,e||(e=setTimeout(()=>{l(o),e=null},u)))};return l};export{t as throttled}; | ||
| //# sourceMappingURL=index.module.js.map |
| {"version":3,"file":"index.module.js","sources":["../src/index.ts"],"sourcesContent":["export const throttled = /*#__PURE__*/ <F extends (...args: any[]) => any>(time: number, df: F): F => {\r\n let timer: any\r\n let lastArgs: any[]\r\n let lastCall = 0\r\n\r\n const f = ((...args) => {\r\n const currtime = Date.now()\r\n const diffTime = currtime - lastCall\r\n if (diffTime > time) {\r\n df(...args)\r\n lastCall = currtime\r\n } else {\r\n lastArgs = args\r\n if (!timer) {\r\n timer = setTimeout(() => {\r\n f(lastArgs)\r\n timer = null\r\n }, diffTime)\r\n }\r\n }\r\n }) as F\r\n\r\n return f\r\n}\r\n"],"names":["throttled","time","df","f","slice","call","arguments","Date","now","diffTime","currtime","lastCall","args","lastArgs","timer","setTimeout"],"mappings":"AAAaA,QAA0B,CAAoCC,EAAcC,KACvF,UAEe,EAEf,MAAMC,EAAK,WAAY,MACrB,GAAAC,MAAAC,KAAAC,WAAA,QAAiBC,KAAKC,MAChBC,EAAWC,EAAWC,EACxBF,EAAWR,GACbC,KAAMU,GACND,EAAWD,IAEXG,EAAWD,EACNE,IACHA,EAAQC,WAAW,KACjBZ,EAAEU,GACFC,EAAQ,IAAA,EACPL,IAGT,EAEA,OAAON"} |
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e||self).utils={})}(this,function(e){e.throttled=(e,t)=>{let n,o,i=0;const f=function(){var l=[].slice.call(arguments);const s=Date.now(),u=s-i;u>e?(t(...l),i=s):(o=l,n||(n=setTimeout(()=>{f(o),n=null},u)))};return f}}); | ||
| //# sourceMappingURL=index.umd.js.map |
| {"version":3,"file":"index.umd.js","sources":["../src/index.ts"],"sourcesContent":["export const throttled = /*#__PURE__*/ <F extends (...args: any[]) => any>(time: number, df: F): F => {\r\n let timer: any\r\n let lastArgs: any[]\r\n let lastCall = 0\r\n\r\n const f = ((...args) => {\r\n const currtime = Date.now()\r\n const diffTime = currtime - lastCall\r\n if (diffTime > time) {\r\n df(...args)\r\n lastCall = currtime\r\n } else {\r\n lastArgs = args\r\n if (!timer) {\r\n timer = setTimeout(() => {\r\n f(lastArgs)\r\n timer = null\r\n }, diffTime)\r\n }\r\n }\r\n }) as F\r\n\r\n return f\r\n}\r\n"],"names":["time","df","f","slice","call","arguments","Date","now","diffTime","currtime","lastCall","args","lastArgs","timer","setTimeout"],"mappings":"2OAAuC,CAAoCA,EAAcC,KACvF,UAEe,EAEf,MAAMC,EAAK,WAAY,MACrB,GAAAC,MAAAC,KAAAC,WAAA,QAAiBC,KAAKC,MAChBC,EAAWC,EAAWC,EACxBF,EAAWR,GACbC,KAAMU,GACND,EAAWD,IAEXG,EAAWD,EACNE,IACHA,EAAQC,WAAW,KACjBZ,EAAEU,GACFC,EAAQ,IAAA,EACPL,IAGT,EAEA,OAAON"} |
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 2 instances in 1 package
57
46.15%1
-75%Yes
NaN5009
-44.61%11
-26.67%