@hyperfrontend/time-utils
Advanced tools
+207
-11
@@ -5,2 +5,88 @@ var HyperfrontendTimeUtils = (function (exports) { | ||
| /** | ||
| * Safe copies of Date built-in via factory function and static methods. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides a factory function that uses Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/date | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Date = globalThis.Date; | ||
| const _Reflect$2 = globalThis.Reflect; | ||
| function createDate(...args) { | ||
| return _Reflect$2.construct(_Date, args); | ||
| } | ||
| /** | ||
| * (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
| */ | ||
| const dateNow = _Date.now; | ||
| /** | ||
| * Safe copies of Object built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/object | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Object = globalThis.Object; | ||
| /** | ||
| * (Safe copy) Prevents modification of existing property attributes and values, | ||
| * and prevents the addition of new properties. | ||
| */ | ||
| const freeze = _Object.freeze; | ||
| /** | ||
| * Safe copies of Timer/Scheduling built-in functions. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/timers | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _setTimeout = globalThis.setTimeout; | ||
| const _setInterval = globalThis.setInterval; | ||
| const _clearTimeout = globalThis.clearTimeout; | ||
| const _clearInterval = globalThis.clearInterval; | ||
| /** | ||
| * (Safe copy) Sets a timer which executes a function once the timer expires. | ||
| * | ||
| * @param callback - Function to call when the timer elapses. | ||
| * @param delay - Time in milliseconds before executing. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the timer. | ||
| */ | ||
| const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Repeatedly calls a function with a fixed time delay between each call. | ||
| * | ||
| * @param callback - Function to call at each interval. | ||
| * @param delay - Time in milliseconds between calls. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the interval. | ||
| */ | ||
| const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Cancels a timeout previously established by setTimeout. | ||
| * | ||
| * @param id - The identifier of the timeout to cancel. | ||
| */ | ||
| const clearTimeout = (id) => { | ||
| _clearTimeout(id); | ||
| }; | ||
| /** | ||
| * (Safe copy) Cancels a timed, repeating action previously established by setInterval. | ||
| * | ||
| * @param id - The identifier of the interval to cancel. | ||
| */ | ||
| const clearInterval = (id) => { | ||
| _clearInterval(id); | ||
| }; | ||
| /** | ||
| * Creates an interval loop that invokes one or more subscribed callback functions | ||
@@ -21,3 +107,3 @@ * at the specified internal (in milliseconds). | ||
| clockId = setInterval(() => { | ||
| const currentTime = new Date(); | ||
| const currentTime = createDate(); | ||
| subscribers.forEach((subscriber) => subscriber(currentTime)); | ||
@@ -39,3 +125,3 @@ }, interval); | ||
| }; | ||
| return Object.freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| return freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| } | ||
@@ -58,3 +144,3 @@ | ||
| clearTimeout(timerId); | ||
| const now = Date.now(); | ||
| const now = dateNow(); | ||
| /* istanbul ignore else - start is always set when timerId is not null */ | ||
@@ -69,3 +155,3 @@ if (start !== null) { | ||
| if (timerId === null) { | ||
| start = Date.now(); | ||
| start = dateNow(); | ||
| timerId = setTimeout(() => { | ||
@@ -82,6 +168,63 @@ callback(); | ||
| }; | ||
| return Object.freeze({ pause, resume, reset }); | ||
| return freeze({ pause, resume, reset }); | ||
| } | ||
| /** | ||
| * Safe copies of Error built-ins via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/error | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Error = globalThis.Error; | ||
| const _Reflect$1 = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Error using the captured Error constructor. | ||
| * Use this instead of `new Error()`. | ||
| * | ||
| * @param message - Optional error message. | ||
| * @param options - Optional error options. | ||
| * @returns A new Error instance. | ||
| */ | ||
| const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]); | ||
| /** | ||
| * Safe copies of Math built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/math | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Math = globalThis.Math; | ||
| /** | ||
| * (Safe copy) Returns the largest integer less than or equal to a number. | ||
| */ | ||
| const floor = _Math.floor; | ||
| /** | ||
| * Safe copies of Number built-in methods and constants. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/number | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _isNaN = globalThis.isNaN; | ||
| // ============================================================================ | ||
| // Global Type Checking (legacy, less strict) | ||
| // ============================================================================ | ||
| /** | ||
| * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN). | ||
| */ | ||
| const globalIsNaN = _isNaN; | ||
| /** | ||
| * Normalizes a given time to the nearest base time window. | ||
@@ -94,12 +237,12 @@ * | ||
| function normalizeToBaseTimeWindow(time, baseTimeWindow) { | ||
| if (!time || !(time instanceof Date) || isNaN(time.getTime())) { | ||
| throw new Error('Invalid time input'); | ||
| if (!time || !(time instanceof Date) || globalIsNaN(time.getTime())) { | ||
| throw createError('Invalid time input'); | ||
| } | ||
| if (baseTimeWindow <= 0) { | ||
| throw new Error('Base time window must be positive'); | ||
| throw createError('Base time window must be positive'); | ||
| } | ||
| const timeInMs = time.getTime(); | ||
| const windowInMs = baseTimeWindow * 60 * 1000; | ||
| const normalizedTimeInMs = Math.floor(timeInMs / windowInMs) * windowInMs; | ||
| return new Date(normalizedTimeInMs); | ||
| const normalizedTimeInMs = floor(timeInMs / windowInMs) * windowInMs; | ||
| return createDate(normalizedTimeInMs); | ||
| } | ||
@@ -120,2 +263,55 @@ | ||
| /** | ||
| * Safe copies of Promise built-in methods via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Promise = globalThis.Promise; | ||
| const _Reflect = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Promise using the captured Promise constructor. | ||
| * Use this instead of `new Promise()`. | ||
| * | ||
| * @param executor - The executor function. | ||
| * @returns A new Promise instance. | ||
| */ | ||
| const createPromise = (executor) => _Reflect.construct(_Promise, [executor]); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the given value. | ||
| */ | ||
| _Promise.resolve.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that rejects with the given reason. | ||
| */ | ||
| _Promise.reject.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises resolve. | ||
| */ | ||
| _Promise.all.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise. | ||
| */ | ||
| _Promise.race.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises settle. | ||
| */ | ||
| _Promise.allSettled.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the first fulfilled promise. | ||
| */ | ||
| _Promise.any.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Creates a Promise along with its resolve and reject functions. | ||
| * Note: Available only in ES2024+ environments. | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| _Promise.withResolvers?.bind(_Promise); | ||
| /** | ||
| * Pauses execution for a specified duration. | ||
@@ -127,3 +323,3 @@ * | ||
| function sleep(milliseconds) { | ||
| return new Promise((resolve) => setTimeout(resolve, milliseconds)); | ||
| return createPromise((resolve) => setTimeout(resolve, milliseconds)); | ||
| } | ||
@@ -130,0 +326,0 @@ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.iife.js","sources":["../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;IASA;;;;;;;;;IASG;IACG,SAAU,WAAW,CAAC,QAAQ,GAAG,IAAI,EAAA;QACzC,IAAI,OAAO,GAA0B,IAAI;QACzC,IAAI,WAAW,GAAoC,EAAE;QAErD,MAAM,KAAK,GAAG,MAAW;IACvB,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;IACpB,YAAA,OAAO,GAAG,WAAW,CAAC,MAAK;IACzB,gBAAA,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE;IAC9B,gBAAA,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,WAAW,CAAC,CAAC;gBAC9D,CAAC,EAAE,QAAQ,CAAC;YACd;IACF,IAAA,CAAC;QAED,MAAM,IAAI,GAAG,MA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;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"index.iife.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/date/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/timers/index.ts","../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/number/index.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/promise/index.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":";;;IAAA;;;;;;;;;;IAUG;IAEH;IACA,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI;IAC7B,MAAMA,UAAQ,GAAG,UAAU,CAAC,OAAO;IAoB7B,SAAU,UAAU,CAAC,GAAG,IAAe,EAAA;QAC3C,OAAaA,UAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC;IAC9C;IAEA;;IAEG;IACI,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG;;ICzChC;;;;;;;IAOG;IAEH;IACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;IAMjC;;;IAGG;IACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;ICpBpC;;;;;;;IAOG;IAEH;IACA,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU;IACzC,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW;IAC3C,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY;IAC7C,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa;IAM/C;;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;;;IAUG;IAEH;IACA,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;IACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;IAGnC;;;;;;IAMG;IACI,MAAM,aAAa,GAAG,CAC3B,QAAoG,KACzE,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;IAErE;;IAEG;IAC2B,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;IAE5D;;IAEG;IAC0B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;IAE1D;;IAEG;IACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IAEpD;;IAEG;IACwB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;IAEtD;;IAEG;IAC8B,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ;IAElE;;IAEG;IACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IAEpD;;;IAGG;IACH;IAC0C,QAAS,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ;;IC5DhF;;;;;IAKG;IACG,SAAU,KAAK,CAAC,YAAoB,EAAA;IACxC,IAAA,OAAO,aAAa,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACtE;;;;;;;;;;;;;;"} |
@@ -1,2 +0,2 @@ | ||
| var HyperfrontendTimeUtils=function(e){"use strict";return e.createClock=function(e=1e3){let t=null,n=[];return Object.freeze({start:()=>{null===t&&(t=setInterval(()=>{const e=new Date;n.forEach(t=>t(e))},e))},stop:()=>{null!==t&&(clearInterval(t),t=null)},subscribe:e=>{n.push(e)},unsubscribe:e=>{n=n.filter(t=>t!==e)},interval:e})},e.createTimer=function(e,t){let n=null,r=null,l=t;const i=()=>{if(null!==n){clearTimeout(n);const e=Date.now();null!==r&&(l-=e-r),n=null}},u=()=>{null===n&&(r=Date.now(),n=setTimeout(()=>{e(),n=null},l))};return Object.freeze({pause:i,resume:u,reset:(e=t)=>{i(),l=e,u()}})},e.normalizeToBaseTimeWindow=function(e,t){if(!e||!(e instanceof Date)||isNaN(e.getTime()))throw new Error("Invalid time input");if(t<=0)throw new Error("Base time window must be positive");const n=e.getTime(),r=60*t*1e3,l=Math.floor(n/r)*r;return new Date(l)},e.setIntervalCallback=function(e,t){const n=setInterval(e,t);return()=>clearInterval(n)},e.sleep=function(e){return new Promise(t=>setTimeout(t,e))},e}({}); | ||
| var HyperfrontendTimeUtils=function(e){"use strict";const l=globalThis.Date,t=globalThis.Reflect;function n(...e){return t.construct(l,e)}const i=l.now,o=globalThis.Object.freeze,s=globalThis.setTimeout,r=globalThis.setInterval,a=globalThis.clearTimeout,c=globalThis.clearInterval,u=(e,l,...t)=>s(e,l,...t),b=(e,l,...t)=>r(e,l,...t),T=e=>{c(e)};const f=globalThis.Error,h=globalThis.Reflect,g=(e,l)=>h.construct(f,[e,l]),m=globalThis.Math.floor,d=globalThis.isNaN;const v=globalThis.Promise,p=globalThis.Reflect;return v.resolve.bind(v),v.reject.bind(v),v.all.bind(v),v.race.bind(v),v.allSettled.bind(v),v.any.bind(v),v.withResolvers?.bind(v),e.createClock=function(e=1e3){let l=null,t=[];return o({start:()=>{null===l&&(l=b(()=>{const e=n();t.forEach(l=>l(e))},e))},stop:()=>{null!==l&&(T(l),l=null)},subscribe:e=>{t.push(e)},unsubscribe:e=>{t=t.filter(l=>l!==e)},interval:e})},e.createTimer=function(e,l){let t=null,n=null,s=l;const r=()=>{if(null!==t){a(t);const e=i();null!==n&&(s-=e-n),t=null}},c=()=>{null===t&&(n=i(),t=u(()=>{e(),t=null},s))};return o({pause:r,resume:c,reset:(e=l)=>{r(),s=e,c()}})},e.normalizeToBaseTimeWindow=function(e,l){if(!e||!(e instanceof Date)||d(e.getTime()))throw g("Invalid time input");if(l<=0)throw g("Base time window must be positive");const t=e.getTime(),i=60*l*1e3;return n(m(t/i)*i)},e.setIntervalCallback=function(e,l){const t=b(e,l);return()=>T(t)},e.sleep=function(e){return l=l=>u(l,e),p.construct(v,[l]);var l},e}({}); | ||
| //# sourceMappingURL=index.iife.min.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.iife.min.js","sources":["../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null],"names":["interval","clockId","subscribers","Object","freeze","start","setInterval","currentTime","Date","forEach","subscriber","stop","clearInterval","subscribe","callback","push","unsubscribe","filter","delay","timerId","remaining","pause","clearTimeout","now","resume","setTimeout","reset","newDelay","time","baseTimeWindow","isNaN","getTime","Error","timeInMs","windowInMs","normalizedTimeInMs","Math","floor","milliseconds","Promise","resolve"],"mappings":"yEAmBM,SAAsBA,EAAW,KACrC,IAAIC,EAAiC,KACjCC,EAA+C,GA0BnD,OAAOC,OAAOC,OAAO,CAAEC,MAxBT,KACI,OAAZJ,IACFA,EAAUK,YAAY,KACpB,MAAMC,EAAc,IAAIC,KACxBN,EAAYO,QAASC,GAAeA,EAAWH,KAC9CP,KAmBuBW,KAfjB,KACK,OAAZV,IACFW,cAAcX,GACdA,EAAU,OAYsBY,UARjBC,IACjBZ,EAAYa,KAAKD,IAO4BE,YAJ1BF,IACnBZ,EAAcA,EAAYe,OAAQP,GAAeA,IAAeI,IAGNd,YAC9D,gBC/BM,SAAsBc,EAAsBI,GAChD,IAAIC,EAAiC,KACjCd,EAAuB,KACvBe,EAAoBF,EAExB,MAAMG,EAAQ,KACZ,GAAgB,OAAZF,EAAkB,CACpBG,aAAaH,GACb,MAAMI,EAAMf,KAAKe,MAEH,OAAVlB,IACFe,GAAaG,EAAMlB,GAErBc,EAAU,IACZ,GAGIK,EAAS,KACG,OAAZL,IACFd,EAAQG,KAAKe,MACbJ,EAAUM,WAAW,KACnBX,IACAK,EAAU,MACTC,KAUP,OAAOjB,OAAOC,OAAO,CAAEiB,QAAOG,SAAQE,MANxB,CAACC,EAAmBT,KAChCG,IACAD,EAAYO,EACZH,MAIJ,8BC5CM,SAAoCI,EAAYC,GACpD,IAAKD,KAAUA,aAAgBpB,OAASsB,MAAMF,EAAKG,WACjD,MAAM,IAAIC,MAAM,sBAGlB,GAAIH,GAAkB,EACpB,MAAM,IAAIG,MAAM,qCAGlB,MAAMC,EAAWL,EAAKG,UAChBG,EAA8B,GAAjBL,EAAsB,IACnCM,EAAqBC,KAAKC,MAAMJ,EAAWC,GAAcA,EAC/D,OAAO,IAAI1B,KAAK2B,EAClB,wBCbM,SAA8BrB,EAAsBd,GACxD,MAAMmB,EAA0Bb,YAAYQ,EAAUd,GACtD,MAAO,IAAYY,cAAcO,EACnC,UCJM,SAAgBmB,GACpB,OAAO,IAAIC,QAASC,GAAYf,WAAWe,EAASF,GACtD"} | ||
| {"version":3,"file":"index.iife.min.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/date/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/timers/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/number/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/promise/index.ts","../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Date","globalThis","Date","_Reflect","Reflect","createDate","args","construct","dateNow","now","freeze","Object","_setTimeout","setTimeout","_setInterval","setInterval","_clearTimeout","clearTimeout","_clearInterval","clearInterval","callback","delay","id","_Error","Error","createError","message","options","floor","Math","globalIsNaN","isNaN","_Promise","Promise","resolve","bind","reject","all","race","allSettled","any","withResolvers","interval","clockId","subscribers","start","currentTime","forEach","subscriber","stop","subscribe","push","unsubscribe","filter","timerId","remaining","pause","resume","reset","newDelay","time","baseTimeWindow","getTime","timeInMs","windowInMs","milliseconds","executor"],"mappings":"oDAaA,MAAMA,EAAQC,WAAWC,KACnBC,EAAWF,WAAWG,QAoBtB,SAAUC,KAAcC,GAC5B,OAAaH,EAASI,UAAUP,EAAOM,EACzC,CAKO,MAAME,EAAUR,EAAMS,ICrBhBC,EAVGT,WAAWU,OAUGD,OCVxBE,EAAcX,WAAWY,WACzBC,EAAeb,WAAWc,YAC1BC,EAAgBf,WAAWgB,aAC3BC,EAAiBjB,WAAWkB,cAcrBN,EAAa,CACxBO,EACAC,KACGf,IAC0CM,EAAYQ,EAAUC,KAAUf,GAUlES,EAAc,CACzBK,EACAC,KACGf,IAC2CQ,EAAaM,EAAUC,KAAUf,GAgBpEa,EAAiBG,IAC5BJ,EAAeI,ICjDjB,MAAMC,EAAStB,WAAWuB,MAQpBrB,EAAWF,WAAWG,QAWfqB,EAAc,CAACC,EAAkBC,IAAyCxB,EAASI,UAAUgB,EAAQ,CAACG,EAASC,IC+C/GC,EArEC3B,WAAW4B,KAqEED,MC2BdE,EA7FE7B,WAAW8B,MCA1B,MAAMC,EAAW/B,WAAWgC,QACtB9B,EAAWF,WAAWG,eAiBE4B,EAASE,QAAQC,KAAKH,GAKvBA,EAASI,OAAOD,KAAKH,GAKxBA,EAASK,IAAIF,KAAKH,GAKjBA,EAASM,KAAKH,KAAKH,GAKbA,EAASO,WAAWJ,KAAKH,GAKhCA,EAASQ,IAAIL,KAAKH,GAOFA,EAAUS,eAAeN,KAAKH,iBCxClE,SAAsBU,EAAW,KACrC,IAAIC,EAAiC,KACjC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8,2 +8,88 @@ (function (global, factory) { | ||
| /** | ||
| * Safe copies of Date built-in via factory function and static methods. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides a factory function that uses Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/date | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Date = globalThis.Date; | ||
| const _Reflect$2 = globalThis.Reflect; | ||
| function createDate(...args) { | ||
| return _Reflect$2.construct(_Date, args); | ||
| } | ||
| /** | ||
| * (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
| */ | ||
| const dateNow = _Date.now; | ||
| /** | ||
| * Safe copies of Object built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/object | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Object = globalThis.Object; | ||
| /** | ||
| * (Safe copy) Prevents modification of existing property attributes and values, | ||
| * and prevents the addition of new properties. | ||
| */ | ||
| const freeze = _Object.freeze; | ||
| /** | ||
| * Safe copies of Timer/Scheduling built-in functions. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/timers | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _setTimeout = globalThis.setTimeout; | ||
| const _setInterval = globalThis.setInterval; | ||
| const _clearTimeout = globalThis.clearTimeout; | ||
| const _clearInterval = globalThis.clearInterval; | ||
| /** | ||
| * (Safe copy) Sets a timer which executes a function once the timer expires. | ||
| * | ||
| * @param callback - Function to call when the timer elapses. | ||
| * @param delay - Time in milliseconds before executing. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the timer. | ||
| */ | ||
| const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Repeatedly calls a function with a fixed time delay between each call. | ||
| * | ||
| * @param callback - Function to call at each interval. | ||
| * @param delay - Time in milliseconds between calls. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the interval. | ||
| */ | ||
| const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Cancels a timeout previously established by setTimeout. | ||
| * | ||
| * @param id - The identifier of the timeout to cancel. | ||
| */ | ||
| const clearTimeout = (id) => { | ||
| _clearTimeout(id); | ||
| }; | ||
| /** | ||
| * (Safe copy) Cancels a timed, repeating action previously established by setInterval. | ||
| * | ||
| * @param id - The identifier of the interval to cancel. | ||
| */ | ||
| const clearInterval = (id) => { | ||
| _clearInterval(id); | ||
| }; | ||
| /** | ||
| * Creates an interval loop that invokes one or more subscribed callback functions | ||
@@ -24,3 +110,3 @@ * at the specified internal (in milliseconds). | ||
| clockId = setInterval(() => { | ||
| const currentTime = new Date(); | ||
| const currentTime = createDate(); | ||
| subscribers.forEach((subscriber) => subscriber(currentTime)); | ||
@@ -42,3 +128,3 @@ }, interval); | ||
| }; | ||
| return Object.freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| return freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| } | ||
@@ -61,3 +147,3 @@ | ||
| clearTimeout(timerId); | ||
| const now = Date.now(); | ||
| const now = dateNow(); | ||
| /* istanbul ignore else - start is always set when timerId is not null */ | ||
@@ -72,3 +158,3 @@ if (start !== null) { | ||
| if (timerId === null) { | ||
| start = Date.now(); | ||
| start = dateNow(); | ||
| timerId = setTimeout(() => { | ||
@@ -85,6 +171,63 @@ callback(); | ||
| }; | ||
| return Object.freeze({ pause, resume, reset }); | ||
| return freeze({ pause, resume, reset }); | ||
| } | ||
| /** | ||
| * Safe copies of Error built-ins via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/error | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Error = globalThis.Error; | ||
| const _Reflect$1 = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Error using the captured Error constructor. | ||
| * Use this instead of `new Error()`. | ||
| * | ||
| * @param message - Optional error message. | ||
| * @param options - Optional error options. | ||
| * @returns A new Error instance. | ||
| */ | ||
| const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]); | ||
| /** | ||
| * Safe copies of Math built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/math | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Math = globalThis.Math; | ||
| /** | ||
| * (Safe copy) Returns the largest integer less than or equal to a number. | ||
| */ | ||
| const floor = _Math.floor; | ||
| /** | ||
| * Safe copies of Number built-in methods and constants. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/number | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _isNaN = globalThis.isNaN; | ||
| // ============================================================================ | ||
| // Global Type Checking (legacy, less strict) | ||
| // ============================================================================ | ||
| /** | ||
| * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN). | ||
| */ | ||
| const globalIsNaN = _isNaN; | ||
| /** | ||
| * Normalizes a given time to the nearest base time window. | ||
@@ -97,12 +240,12 @@ * | ||
| function normalizeToBaseTimeWindow(time, baseTimeWindow) { | ||
| if (!time || !(time instanceof Date) || isNaN(time.getTime())) { | ||
| throw new Error('Invalid time input'); | ||
| if (!time || !(time instanceof Date) || globalIsNaN(time.getTime())) { | ||
| throw createError('Invalid time input'); | ||
| } | ||
| if (baseTimeWindow <= 0) { | ||
| throw new Error('Base time window must be positive'); | ||
| throw createError('Base time window must be positive'); | ||
| } | ||
| const timeInMs = time.getTime(); | ||
| const windowInMs = baseTimeWindow * 60 * 1000; | ||
| const normalizedTimeInMs = Math.floor(timeInMs / windowInMs) * windowInMs; | ||
| return new Date(normalizedTimeInMs); | ||
| const normalizedTimeInMs = floor(timeInMs / windowInMs) * windowInMs; | ||
| return createDate(normalizedTimeInMs); | ||
| } | ||
@@ -123,2 +266,55 @@ | ||
| /** | ||
| * Safe copies of Promise built-in methods via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Promise = globalThis.Promise; | ||
| const _Reflect = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Promise using the captured Promise constructor. | ||
| * Use this instead of `new Promise()`. | ||
| * | ||
| * @param executor - The executor function. | ||
| * @returns A new Promise instance. | ||
| */ | ||
| const createPromise = (executor) => _Reflect.construct(_Promise, [executor]); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the given value. | ||
| */ | ||
| _Promise.resolve.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that rejects with the given reason. | ||
| */ | ||
| _Promise.reject.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises resolve. | ||
| */ | ||
| _Promise.all.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise. | ||
| */ | ||
| _Promise.race.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises settle. | ||
| */ | ||
| _Promise.allSettled.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the first fulfilled promise. | ||
| */ | ||
| _Promise.any.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Creates a Promise along with its resolve and reject functions. | ||
| * Note: Available only in ES2024+ environments. | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| _Promise.withResolvers?.bind(_Promise); | ||
| /** | ||
| * Pauses execution for a specified duration. | ||
@@ -130,3 +326,3 @@ * | ||
| function sleep(milliseconds) { | ||
| return new Promise((resolve) => setTimeout(resolve, milliseconds)); | ||
| return createPromise((resolve) => setTimeout(resolve, milliseconds)); | ||
| } | ||
@@ -133,0 +329,0 @@ |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.umd.js","sources":["../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;;;;;IASA;;;;;;;;;IASG;IACG,SAAU,WAAW,CAAC,QAAQ,GAAG,IAAI,EAAA;QACzC,IAAI,OAAO,GAA0B,IAAI;QACzC,IAAI,WAAW,GAAoC,EAAE;QAErD,MAAM,KAAK,GAAG,MAAW;IACvB,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;IACpB,YAAA,OAAO,GAAG,WAAW,CAAC,MAAK;IACzB,gBAAA,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE;IAC9B,gBAAA,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,WAAW,CAAC,CAAC;gBAC9D,CAAC,EAAE,QAAQ,CAAC;YACd;IACF,IAAA,CAAC;QAED,MAAM,IAAI,GAAG,MAAW;IACtB,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;gBAC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../../../../../../../../libs/utils/immutable-api/src/built-in-copy/date/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/timers/index.ts","../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/number/index.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/promise/index.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":";;;;;;IAAA;;;;;;;;;;IAUG;IAEH;IACA,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI;IAC7B,MAAMA,UAAQ,GAAG,UAAU,CAAC,OAAO;IAoB7B,SAAU,UAAU,CAAC,GAAG,IAAe,EAAA;QAC3C,OAAaA,UAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC;IAC9C;IAEA;;IAEG;IACI,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG;;ICzChC;;;;;;;IAOG;IAEH;IACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;IAMjC;;;IAGG;IACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;ICpBpC;;;;;;;IAOG;IAEH;IACA,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU;IACzC,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW;IAC3C,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY;IAC7C,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa;IAM/C;;;;;;;IAOG;IACI,MAAM,UAAU,GAAG,CACxB,QAAkC,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AC,OAAO;IACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;IAGnC;;;;;;IAMG;IACI,MAAM,aAAa,GAAG,CAC3B,QAAoG,KACzE,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;IAErE;;IAEG;IAC2B,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;IAE5D;;IAEG;IAC0B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;IAE1D;;IAEG;IACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IAEpD;;IAEG;IACwB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;IAEtD;;IAEG;IAC8B,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ;IAElE;;IAEG;IACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;IAEpD;;;IAGG;IACH;IAC0C,QAAS,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ;;IC5DhF;;;;;IAKG;IACG,SAAU,KAAK,CAAC,YAAoB,EAAA;IACxC,IAAA,OAAO,aAAa,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACtE;;;;;;;;;;;;"} |
@@ -1,2 +0,2 @@ | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HyperfrontendTimeUtils={})}(this,function(e){"use strict";e.createClock=function(e=1e3){let t=null,n=[];return Object.freeze({start:()=>{null===t&&(t=setInterval(()=>{const e=new Date;n.forEach(t=>t(e))},e))},stop:()=>{null!==t&&(clearInterval(t),t=null)},subscribe:e=>{n.push(e)},unsubscribe:e=>{n=n.filter(t=>t!==e)},interval:e})},e.createTimer=function(e,t){let n=null,l=null,r=t;const o=()=>{if(null!==n){clearTimeout(n);const e=Date.now();null!==l&&(r-=e-l),n=null}},i=()=>{null===n&&(l=Date.now(),n=setTimeout(()=>{e(),n=null},r))};return Object.freeze({pause:o,resume:i,reset:(e=t)=>{o(),r=e,i()}})},e.normalizeToBaseTimeWindow=function(e,t){if(!e||!(e instanceof Date)||isNaN(e.getTime()))throw new Error("Invalid time input");if(t<=0)throw new Error("Base time window must be positive");const n=e.getTime(),l=60*t*1e3,r=Math.floor(n/l)*l;return new Date(r)},e.setIntervalCallback=function(e,t){const n=setInterval(e,t);return()=>clearInterval(n)},e.sleep=function(e){return new Promise(t=>setTimeout(t,e))}}); | ||
| !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).HyperfrontendTimeUtils={})}(this,function(e){"use strict";const t=globalThis.Date,l=globalThis.Reflect;function n(...e){return l.construct(t,e)}const i=t.now,o=globalThis.Object.freeze,s=globalThis.setTimeout,r=globalThis.setInterval,a=globalThis.clearTimeout,u=globalThis.clearInterval,c=(e,t,...l)=>s(e,t,...l),f=(e,t,...l)=>r(e,t,...l),b=e=>{u(e)};const T=globalThis.Error,h=globalThis.Reflect,d=(e,t)=>h.construct(T,[e,t]),g=globalThis.Math.floor,m=globalThis.isNaN;const p=globalThis.Promise,v=globalThis.Reflect;p.resolve.bind(p),p.reject.bind(p),p.all.bind(p),p.race.bind(p),p.allSettled.bind(p),p.any.bind(p),p.withResolvers?.bind(p),e.createClock=function(e=1e3){let t=null,l=[];return o({start:()=>{null===t&&(t=f(()=>{const e=n();l.forEach(t=>t(e))},e))},stop:()=>{null!==t&&(b(t),t=null)},subscribe:e=>{l.push(e)},unsubscribe:e=>{l=l.filter(t=>t!==e)},interval:e})},e.createTimer=function(e,t){let l=null,n=null,s=t;const r=()=>{if(null!==l){a(l);const e=i();null!==n&&(s-=e-n),l=null}},u=()=>{null===l&&(n=i(),l=c(()=>{e(),l=null},s))};return o({pause:r,resume:u,reset:(e=t)=>{r(),s=e,u()}})},e.normalizeToBaseTimeWindow=function(e,t){if(!e||!(e instanceof Date)||m(e.getTime()))throw d("Invalid time input");if(t<=0)throw d("Base time window must be positive");const l=e.getTime(),i=60*t*1e3;return n(g(l/i)*i)},e.setIntervalCallback=function(e,t){const l=f(e,t);return()=>b(l)},e.sleep=function(e){return t=t=>c(t,e),v.construct(p,[t]);var t}}); | ||
| //# sourceMappingURL=index.umd.min.js.map |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.umd.min.js","sources":["../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null],"names":["interval","clockId","subscribers","Object","freeze","start","setInterval","currentTime","Date","forEach","subscriber","stop","clearInterval","subscribe","callback","push","unsubscribe","filter","delay","timerId","remaining","pause","clearTimeout","now","resume","setTimeout","reset","newDelay","time","baseTimeWindow","isNaN","getTime","Error","timeInMs","windowInMs","normalizedTimeInMs","Math","floor","milliseconds","Promise","resolve"],"mappings":"2QAmBM,SAAsBA,EAAW,KACrC,IAAIC,EAAiC,KACjCC,EAA+C,GA0BnD,OAAOC,OAAOC,OAAO,CAAEC,MAxBT,KACI,OAAZJ,IACFA,EAAUK,YAAY,KACpB,MAAMC,EAAc,IAAIC,KACxBN,EAAYO,QAASC,GAAeA,EAAWH,KAC9CP,KAmBuBW,KAfjB,KACK,OAAZV,IACFW,cAAcX,GACdA,EAAU,OAYsBY,UARjBC,IACjBZ,EAAYa,KAAKD,IAO4BE,YAJ1BF,IACnBZ,EAAcA,EAAYe,OAAQP,GAAeA,IAAeI,IAGNd,YAC9D,gBC/BM,SAAsBc,EAAsBI,GAChD,IAAIC,EAAiC,KACjCd,EAAuB,KACvBe,EAAoBF,EAExB,MAAMG,EAAQ,KACZ,GAAgB,OAAZF,EAAkB,CACpBG,aAAaH,GACb,MAAMI,EAAMf,KAAKe,MAEH,OAAVlB,IACFe,GAAaG,EAAMlB,GAErBc,EAAU,IACZ,GAGIK,EAAS,KACG,OAAZL,IACFd,EAAQG,KAAKe,MACbJ,EAAUM,WAAW,KACnBX,IACAK,EAAU,MACTC,KAUP,OAAOjB,OAAOC,OAAO,CAAEiB,QAAOG,SAAQE,MANxB,CAACC,EAAmBT,KAChCG,IACAD,EAAYO,EACZH,MAIJ,8BC5CM,SAAoCI,EAAYC,GACpD,IAAKD,KAAUA,aAAgBpB,OAASsB,MAAMF,EAAKG,WACjD,MAAM,IAAIC,MAAM,sBAGlB,GAAIH,GAAkB,EACpB,MAAM,IAAIG,MAAM,qCAGlB,MAAMC,EAAWL,EAAKG,UAChBG,EAA8B,GAAjBL,EAAsB,IACnCM,EAAqBC,KAAKC,MAAMJ,EAAWC,GAAcA,EAC/D,OAAO,IAAI1B,KAAK2B,EAClB,wBCbM,SAA8BrB,EAAsBd,GACxD,MAAMmB,EAA0Bb,YAAYQ,EAAUd,GACtD,MAAO,IAAYY,cAAcO,EACnC,UCJM,SAAgBmB,GACpB,OAAO,IAAIC,QAASC,GAAYf,WAAWe,EAASF,GACtD"} | ||
| {"version":3,"file":"index.umd.min.js","sources":["../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/date/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/timers/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/number/index.ts","../../../../../../../../../../libs/utils/immutable-api/src/built-in-copy/promise/index.ts","../../../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Date","globalThis","Date","_Reflect","Reflect","createDate","args","construct","dateNow","now","freeze","Object","_setTimeout","setTimeout","_setInterval","setInterval","_clearTimeout","clearTimeout","_clearInterval","clearInterval","callback","delay","id","_Error","Error","createError","message","options","floor","Math","globalIsNaN","isNaN","_Promise","Promise","resolve","bind","reject","all","race","allSettled","any","withResolvers","interval","clockId","subscribers","start","currentTime","forEach","subscriber","stop","subscribe","push","unsubscribe","filter","timerId","remaining","pause","resume","reset","newDelay","time","baseTimeWindow","getTime","timeInMs","windowInMs","milliseconds","executor"],"mappings":"6PAaA,MAAMA,EAAQC,WAAWC,KACnBC,EAAWF,WAAWG,QAoBtB,SAAUC,KAAcC,GAC5B,OAAaH,EAASI,UAAUP,EAAOM,EACzC,CAKO,MAAME,EAAUR,EAAMS,ICrBhBC,EAVGT,WAAWU,OAUGD,OCVxBE,EAAcX,WAAWY,WACzBC,EAAeb,WAAWc,YAC1BC,EAAgBf,WAAWgB,aAC3BC,EAAiBjB,WAAWkB,cAcrBN,EAAa,CACxBO,EACAC,KACGf,IAC0CM,EAAYQ,EAAUC,KAAUf,GAUlES,EAAc,CACzBK,EACAC,KACGf,IAC2CQ,EAAaM,EAAUC,KAAUf,GAgBpEa,EAAiBG,IAC5BJ,EAAeI,ICjDjB,MAAMC,EAAStB,WAAWuB,MAQpBrB,EAAWF,WAAWG,QAWfqB,EAAc,CAACC,EAAkBC,IAAyCxB,EAASI,UAAUgB,EAAQ,CAACG,EAASC,IC+C/GC,EArEC3B,WAAW4B,KAqEED,MC2BdE,EA7FE7B,WAAW8B,MCA1B,MAAMC,EAAW/B,WAAWgC,QACtB9B,EAAWF,WAAWG,QAiBE4B,EAASE,QAAQC,KAAKH,GAKvBA,EAASI,OAAOD,KAAKH,GAKxBA,EAASK,IAAIF,KAAKH,GAKjBA,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vB,EAAcmC,EACnC,UCHM,SAAgBW,GACpB,OLeAC,EKfsBhC,GAAYrB,EAAWqB,EAAS+B,GLgB3B9D,EAASI,UAAUyB,EAAU,CAACkC,IAF9B,IAC3BA,CKdF"} |
+7
-0
@@ -5,4 +5,11 @@ # Changelog | ||
| ## [0.0.3](https://github.com/AndrewRedican/hyperfrontend/compare/lib-time-utils@0.0.2...lib-time-utils@0.0.3) (2026-03-02) | ||
| ### Bug Fixes | ||
| * **lib-time-utils:** correct package exports and dependencies ([3b9096b](https://github.com/AndrewRedican/hyperfrontend/commit/3b9096b54337c2c2f3e06d6b97865a772e79aad9)) | ||
| ## [0.0.2](https://github.com/AndrewRedican/hyperfrontend/compare/lib-time-utils@0.0.1...lib-time-utils@0.0.2) (2026-02-26) | ||
| ## 0.0.1 (2026-02-15) |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-clock.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/create-clock.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,CAAA;IACnE,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,CAAA;IACrE,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,SAAO,GAAG,KAAK,CA6BlD"} | ||
| {"version":3,"file":"create-clock.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/create-clock.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,KAAK;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,IAAI,CAAA;IACzB,QAAQ,CAAC,SAAS,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,CAAA;IACnE,QAAQ,CAAC,WAAW,EAAE,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,IAAI,KAAK,IAAI,KAAK,IAAI,CAAA;IACrE,+BAA+B;IAC/B,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAA;CAC1B;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,QAAQ,SAAO,GAAG,KAAK,CA6BlD"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"create-timer.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/create-timer.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,KAAK;IACpB,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAkCtE"} | ||
| {"version":3,"file":"create-timer.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/create-timer.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,KAAK;IACpB,kEAAkE;IAClE,QAAQ,CAAC,KAAK,EAAE,MAAM,IAAI,CAAA;IAC1B,kDAAkD;IAClD,QAAQ,CAAC,MAAM,EAAE,MAAM,IAAI,CAAA;IAC3B,0DAA0D;IAC1D,QAAQ,CAAC,KAAK,EAAE,CAAC,QAAQ,CAAC,EAAE,MAAM,KAAK,IAAI,CAAA;CAC5C;AAED;;;;;;;GAOG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK,CAkCtE"} |
+207
-11
| 'use strict'; | ||
| /** | ||
| * Safe copies of Date built-in via factory function and static methods. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides a factory function that uses Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/date | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Date = globalThis.Date; | ||
| const _Reflect$2 = globalThis.Reflect; | ||
| function createDate(...args) { | ||
| return _Reflect$2.construct(_Date, args); | ||
| } | ||
| /** | ||
| * (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
| */ | ||
| const dateNow = _Date.now; | ||
| /** | ||
| * Safe copies of Object built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/object | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Object = globalThis.Object; | ||
| /** | ||
| * (Safe copy) Prevents modification of existing property attributes and values, | ||
| * and prevents the addition of new properties. | ||
| */ | ||
| const freeze = _Object.freeze; | ||
| /** | ||
| * Safe copies of Timer/Scheduling built-in functions. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/timers | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _setTimeout = globalThis.setTimeout; | ||
| const _setInterval = globalThis.setInterval; | ||
| const _clearTimeout = globalThis.clearTimeout; | ||
| const _clearInterval = globalThis.clearInterval; | ||
| /** | ||
| * (Safe copy) Sets a timer which executes a function once the timer expires. | ||
| * | ||
| * @param callback - Function to call when the timer elapses. | ||
| * @param delay - Time in milliseconds before executing. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the timer. | ||
| */ | ||
| const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Repeatedly calls a function with a fixed time delay between each call. | ||
| * | ||
| * @param callback - Function to call at each interval. | ||
| * @param delay - Time in milliseconds between calls. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the interval. | ||
| */ | ||
| const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Cancels a timeout previously established by setTimeout. | ||
| * | ||
| * @param id - The identifier of the timeout to cancel. | ||
| */ | ||
| const clearTimeout = (id) => { | ||
| _clearTimeout(id); | ||
| }; | ||
| /** | ||
| * (Safe copy) Cancels a timed, repeating action previously established by setInterval. | ||
| * | ||
| * @param id - The identifier of the interval to cancel. | ||
| */ | ||
| const clearInterval = (id) => { | ||
| _clearInterval(id); | ||
| }; | ||
| /** | ||
| * Creates an interval loop that invokes one or more subscribed callback functions | ||
@@ -19,3 +105,3 @@ * at the specified internal (in milliseconds). | ||
| clockId = setInterval(() => { | ||
| const currentTime = new Date(); | ||
| const currentTime = createDate(); | ||
| subscribers.forEach((subscriber) => subscriber(currentTime)); | ||
@@ -37,3 +123,3 @@ }, interval); | ||
| }; | ||
| return Object.freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| return freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| } | ||
@@ -56,3 +142,3 @@ | ||
| clearTimeout(timerId); | ||
| const now = Date.now(); | ||
| const now = dateNow(); | ||
| /* istanbul ignore else - start is always set when timerId is not null */ | ||
@@ -67,3 +153,3 @@ if (start !== null) { | ||
| if (timerId === null) { | ||
| start = Date.now(); | ||
| start = dateNow(); | ||
| timerId = setTimeout(() => { | ||
@@ -80,6 +166,63 @@ callback(); | ||
| }; | ||
| return Object.freeze({ pause, resume, reset }); | ||
| return freeze({ pause, resume, reset }); | ||
| } | ||
| /** | ||
| * Safe copies of Error built-ins via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/error | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Error = globalThis.Error; | ||
| const _Reflect$1 = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Error using the captured Error constructor. | ||
| * Use this instead of `new Error()`. | ||
| * | ||
| * @param message - Optional error message. | ||
| * @param options - Optional error options. | ||
| * @returns A new Error instance. | ||
| */ | ||
| const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]); | ||
| /** | ||
| * Safe copies of Math built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/math | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Math = globalThis.Math; | ||
| /** | ||
| * (Safe copy) Returns the largest integer less than or equal to a number. | ||
| */ | ||
| const floor = _Math.floor; | ||
| /** | ||
| * Safe copies of Number built-in methods and constants. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/number | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _isNaN = globalThis.isNaN; | ||
| // ============================================================================ | ||
| // Global Type Checking (legacy, less strict) | ||
| // ============================================================================ | ||
| /** | ||
| * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN). | ||
| */ | ||
| const globalIsNaN = _isNaN; | ||
| /** | ||
| * Normalizes a given time to the nearest base time window. | ||
@@ -92,12 +235,12 @@ * | ||
| function normalizeToBaseTimeWindow(time, baseTimeWindow) { | ||
| if (!time || !(time instanceof Date) || isNaN(time.getTime())) { | ||
| throw new Error('Invalid time input'); | ||
| if (!time || !(time instanceof Date) || globalIsNaN(time.getTime())) { | ||
| throw createError('Invalid time input'); | ||
| } | ||
| if (baseTimeWindow <= 0) { | ||
| throw new Error('Base time window must be positive'); | ||
| throw createError('Base time window must be positive'); | ||
| } | ||
| const timeInMs = time.getTime(); | ||
| const windowInMs = baseTimeWindow * 60 * 1000; | ||
| const normalizedTimeInMs = Math.floor(timeInMs / windowInMs) * windowInMs; | ||
| return new Date(normalizedTimeInMs); | ||
| const normalizedTimeInMs = floor(timeInMs / windowInMs) * windowInMs; | ||
| return createDate(normalizedTimeInMs); | ||
| } | ||
@@ -118,2 +261,55 @@ | ||
| /** | ||
| * Safe copies of Promise built-in methods via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Promise = globalThis.Promise; | ||
| const _Reflect = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Promise using the captured Promise constructor. | ||
| * Use this instead of `new Promise()`. | ||
| * | ||
| * @param executor - The executor function. | ||
| * @returns A new Promise instance. | ||
| */ | ||
| const createPromise = (executor) => _Reflect.construct(_Promise, [executor]); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the given value. | ||
| */ | ||
| _Promise.resolve.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that rejects with the given reason. | ||
| */ | ||
| _Promise.reject.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises resolve. | ||
| */ | ||
| _Promise.all.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise. | ||
| */ | ||
| _Promise.race.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises settle. | ||
| */ | ||
| _Promise.allSettled.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the first fulfilled promise. | ||
| */ | ||
| _Promise.any.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Creates a Promise along with its resolve and reject functions. | ||
| * Note: Available only in ES2024+ environments. | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| _Promise.withResolvers?.bind(_Promise); | ||
| /** | ||
| * Pauses execution for a specified duration. | ||
@@ -125,3 +321,3 @@ * | ||
| function sleep(milliseconds) { | ||
| return new Promise((resolve) => setTimeout(resolve, milliseconds)); | ||
| return createPromise((resolve) => setTimeout(resolve, milliseconds)); | ||
| } | ||
@@ -128,0 +324,0 @@ |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.cjs.js","sources":["../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":";;AASA;;;;;;;;;AASG;AACG,SAAU,WAAW,CAAC,QAAQ,GAAG,IAAI,EAAA;IACzC,IAAI,OAAO,GAA0B,IAAI;IACzC,IAAI,WAAW,GAAoC,EAAE;IAErD,MAAM,KAAK,GAAG,MAAW;AACvB,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACpB,YAAA,OAAO,GAAG,WAAW,CAAC,MAAK;AACzB,gBAAA,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE;AAC9B,gBAAA,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,WAAW,C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AAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACpE;;;;;;;;"} | ||
| {"version":3,"file":"index.cjs.js","sources":["../../../../../../../../libs/utils/immutable-api/src/built-in-copy/date/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/timers/index.ts","../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/number/index.ts","../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/promise/index.ts","../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":";;AAAA;;;;;;;;;;AAUG;AAEH;AACA,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI;AAC7B,MAAMA,UAAQ,GAAG,UAAU,CAAC,OAAO;AAoB7B,SAAU,UAAU,CAAC,GAAG,IAAe,EAAA;IAC3C,OAAaA,UAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC;AAC9C;AAEA;;AAEG;AACI,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG;;ACzChC;;;;;;;AAOG;AAEH;AACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;AAMjC;;;AAGG;AACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;ACpBpC;;;;;;;AAOG;AAEH;AACA,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU;AACzC,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW;AAC3C,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY;AAC7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AC,OAAO,CAAC;AAC3C;;ACZA;;;;;;;;;;AAUG;AAEH;AACA,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;AACnC,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO;AAGnC;;;;;;AAMG;AACI,MAAM,aAAa,GAAG,CAC3B,QAAoG,KACzE,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC;AAErE;;AAEG;AAC2B,QAAQ,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ;AAE5D;;AAEG;AAC0B,QAAQ,CAAC,MAAM,CAAC,IAAI,CAAC,QAAQ;AAE1D;;AAEG;AACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAEpD;;AAEG;AACwB,QAAQ,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ;AAEtD;;AAEG;AAC8B,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ;AAElE;;AAEG;AACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAEpD;;;AAGG;AACH;AAC0C,QAAS,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ;;AC5DhF;;;;;AAKG;AACG,SAAU,KAAK,CAAC,YAAoB,EAAA;AACxC,IAAA,OAAO,aAAa,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtE;;;;;;;;"} |
+207
-11
| /** | ||
| * Safe copies of Date built-in via factory function and static methods. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides a factory function that uses Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/date | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Date = globalThis.Date; | ||
| const _Reflect$2 = globalThis.Reflect; | ||
| function createDate(...args) { | ||
| return _Reflect$2.construct(_Date, args); | ||
| } | ||
| /** | ||
| * (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC. | ||
| */ | ||
| const dateNow = _Date.now; | ||
| /** | ||
| * Safe copies of Object built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/object | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Object = globalThis.Object; | ||
| /** | ||
| * (Safe copy) Prevents modification of existing property attributes and values, | ||
| * and prevents the addition of new properties. | ||
| */ | ||
| const freeze = _Object.freeze; | ||
| /** | ||
| * Safe copies of Timer/Scheduling built-in functions. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/timers | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _setTimeout = globalThis.setTimeout; | ||
| const _setInterval = globalThis.setInterval; | ||
| const _clearTimeout = globalThis.clearTimeout; | ||
| const _clearInterval = globalThis.clearInterval; | ||
| /** | ||
| * (Safe copy) Sets a timer which executes a function once the timer expires. | ||
| * | ||
| * @param callback - Function to call when the timer elapses. | ||
| * @param delay - Time in milliseconds before executing. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the timer. | ||
| */ | ||
| const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Repeatedly calls a function with a fixed time delay between each call. | ||
| * | ||
| * @param callback - Function to call at each interval. | ||
| * @param delay - Time in milliseconds between calls. | ||
| * @param args - Additional arguments to pass to the callback. | ||
| * @returns A numeric ID for the interval. | ||
| */ | ||
| const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args); | ||
| /** | ||
| * (Safe copy) Cancels a timeout previously established by setTimeout. | ||
| * | ||
| * @param id - The identifier of the timeout to cancel. | ||
| */ | ||
| const clearTimeout = (id) => { | ||
| _clearTimeout(id); | ||
| }; | ||
| /** | ||
| * (Safe copy) Cancels a timed, repeating action previously established by setInterval. | ||
| * | ||
| * @param id - The identifier of the interval to cancel. | ||
| */ | ||
| const clearInterval = (id) => { | ||
| _clearInterval(id); | ||
| }; | ||
| /** | ||
| * Creates an interval loop that invokes one or more subscribed callback functions | ||
@@ -17,3 +103,3 @@ * at the specified internal (in milliseconds). | ||
| clockId = setInterval(() => { | ||
| const currentTime = new Date(); | ||
| const currentTime = createDate(); | ||
| subscribers.forEach((subscriber) => subscriber(currentTime)); | ||
@@ -35,3 +121,3 @@ }, interval); | ||
| }; | ||
| return Object.freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| return freeze({ start, stop, subscribe, unsubscribe, interval }); | ||
| } | ||
@@ -54,3 +140,3 @@ | ||
| clearTimeout(timerId); | ||
| const now = Date.now(); | ||
| const now = dateNow(); | ||
| /* istanbul ignore else - start is always set when timerId is not null */ | ||
@@ -65,3 +151,3 @@ if (start !== null) { | ||
| if (timerId === null) { | ||
| start = Date.now(); | ||
| start = dateNow(); | ||
| timerId = setTimeout(() => { | ||
@@ -78,6 +164,63 @@ callback(); | ||
| }; | ||
| return Object.freeze({ pause, resume, reset }); | ||
| return freeze({ pause, resume, reset }); | ||
| } | ||
| /** | ||
| * Safe copies of Error built-ins via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/error | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Error = globalThis.Error; | ||
| const _Reflect$1 = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Error using the captured Error constructor. | ||
| * Use this instead of `new Error()`. | ||
| * | ||
| * @param message - Optional error message. | ||
| * @param options - Optional error options. | ||
| * @returns A new Error instance. | ||
| */ | ||
| const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]); | ||
| /** | ||
| * Safe copies of Math built-in methods. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/math | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Math = globalThis.Math; | ||
| /** | ||
| * (Safe copy) Returns the largest integer less than or equal to a number. | ||
| */ | ||
| const floor = _Math.floor; | ||
| /** | ||
| * Safe copies of Number built-in methods and constants. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/number | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _isNaN = globalThis.isNaN; | ||
| // ============================================================================ | ||
| // Global Type Checking (legacy, less strict) | ||
| // ============================================================================ | ||
| /** | ||
| * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN). | ||
| */ | ||
| const globalIsNaN = _isNaN; | ||
| /** | ||
| * Normalizes a given time to the nearest base time window. | ||
@@ -90,12 +233,12 @@ * | ||
| function normalizeToBaseTimeWindow(time, baseTimeWindow) { | ||
| if (!time || !(time instanceof Date) || isNaN(time.getTime())) { | ||
| throw new Error('Invalid time input'); | ||
| if (!time || !(time instanceof Date) || globalIsNaN(time.getTime())) { | ||
| throw createError('Invalid time input'); | ||
| } | ||
| if (baseTimeWindow <= 0) { | ||
| throw new Error('Base time window must be positive'); | ||
| throw createError('Base time window must be positive'); | ||
| } | ||
| const timeInMs = time.getTime(); | ||
| const windowInMs = baseTimeWindow * 60 * 1000; | ||
| const normalizedTimeInMs = Math.floor(timeInMs / windowInMs) * windowInMs; | ||
| return new Date(normalizedTimeInMs); | ||
| const normalizedTimeInMs = floor(timeInMs / windowInMs) * windowInMs; | ||
| return createDate(normalizedTimeInMs); | ||
| } | ||
@@ -116,2 +259,55 @@ | ||
| /** | ||
| * Safe copies of Promise built-in methods via factory functions. | ||
| * | ||
| * Since constructors cannot be safely captured via Object.assign, this module | ||
| * provides factory functions that use Reflect.construct internally. | ||
| * | ||
| * These references are captured at module initialization time to protect against | ||
| * prototype pollution attacks. Import only what you need for tree-shaking. | ||
| * | ||
| * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise | ||
| */ | ||
| // Capture references at module initialization time | ||
| const _Promise = globalThis.Promise; | ||
| const _Reflect = globalThis.Reflect; | ||
| /** | ||
| * (Safe copy) Creates a new Promise using the captured Promise constructor. | ||
| * Use this instead of `new Promise()`. | ||
| * | ||
| * @param executor - The executor function. | ||
| * @returns A new Promise instance. | ||
| */ | ||
| const createPromise = (executor) => _Reflect.construct(_Promise, [executor]); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the given value. | ||
| */ | ||
| _Promise.resolve.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that rejects with the given reason. | ||
| */ | ||
| _Promise.reject.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises resolve. | ||
| */ | ||
| _Promise.all.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise. | ||
| */ | ||
| _Promise.race.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves when all promises settle. | ||
| */ | ||
| _Promise.allSettled.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Returns a Promise that resolves with the first fulfilled promise. | ||
| */ | ||
| _Promise.any.bind(_Promise); | ||
| /** | ||
| * (Safe copy) Creates a Promise along with its resolve and reject functions. | ||
| * Note: Available only in ES2024+ environments. | ||
| */ | ||
| // eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
| _Promise.withResolvers?.bind(_Promise); | ||
| /** | ||
| * Pauses execution for a specified duration. | ||
@@ -123,3 +319,3 @@ * | ||
| function sleep(milliseconds) { | ||
| return new Promise((resolve) => setTimeout(resolve, milliseconds)); | ||
| return createPromise((resolve) => setTimeout(resolve, milliseconds)); | ||
| } | ||
@@ -126,0 +322,0 @@ |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"index.esm.js","sources":["../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null],"names":[],"mappings":"AASA;;;;;;;;;AASG;AACG,SAAU,WAAW,CAAC,QAAQ,GAAG,IAAI,EAAA;IACzC,IAAI,OAAO,GAA0B,IAAI;IACzC,IAAI,WAAW,GAAoC,EAAE;IAErD,MAAM,KAAK,GAAG,MAAW;AACvB,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;AACpB,YAAA,OAAO,GAAG,WAAW,CAAC,MAAK;AACzB,gBAAA,MAAM,WAAW,GAAG,IAAI,IAAI,EAAE;AAC9B,gBAAA,WAAW,CAAC,OAAO,CAAC,CAAC,UAAU,KAAK,UAAU,CAAC,WAAW,CAAC,CAAC;YAC9D,CAAC,EAAE,QAAQ,CAAC;QACd;AACF,IAAA,CAAC;IAED,MAAM,IAAI,GAAG,MAAW;AACtB,QAAA,IAAI,OAAO,KAAK,IAAI,EAAE;YACpB,aAAa,CAAC,OAAO,CAAC;YACtB,OAAO,GAAG,IAAI;QAChB;AACF,IAAA,CAAC;AAED,IAAA,MAAM,SAAS,GAAG,CAAC,QAAqC,KAAU;AAChE,QAAA,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;AAC5B,IAAA,CAAC;AAED,IAAA,MAAM,WAAW,GAAG,CAAC,QAAqC,KAAU;AAClE,QAAA,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,KAAK,UAAU,KAAK,QAAQ,CAAC;AAC3E,IAAA,CAAC;AAED,IAAA,OAAO,MAAM,CA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AC,OAAO,EAAE,CAAC,EAAE;AAC7D,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;IACvC;AAEA,IAAA,IAAI,cAAc,IAAI,CAAC,EAAE;AACvB,QAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC;IACtD;AAEA,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE;AAC/B,IAAA,MAAM,UAAU,GAAG,cAAc,GAAG,EAAE,GAAG,IAAI;AAC7C,IAAA,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,UAAU;AACzE,IAAA,OAAO,IAAI,IAAI,CAAC,kBAAkB,CAAC;AACrC;;ACpBA;;;;;;AAMG;AACG,SAAU,mBAAmB,CAAC,QAAoB,EAAE,QAAgB,EAAA;IACxE,MAAM,OAAO,GAAmB,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC/D,IAAA,OAAO,MAAY,aAAa,CAAC,OAAO,CAAC;AAC3C;;ACVA;;;;;AAKG;AACG,SAAU,KAAK,CAAC,YAAoB,EAAA;AACxC,IAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACpE;;;;"} | ||
| {"version":3,"file":"index.esm.js","sources":["../../../../../../../../libs/utils/immutable-api/src/built-in-copy/date/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/object/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/timers/index.ts","../../../../../../../../libs/utils/time/src/create-clock.ts","../../../../../../../../libs/utils/time/src/create-timer.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/error/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/math/index.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/number/index.ts","../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts","../../../../../../../../libs/utils/time/src/set-interval-callback.ts","../../../../../../../../libs/utils/immutable-api/src/built-in-copy/promise/index.ts","../../../../../../../../libs/utils/time/src/sleep.ts"],"sourcesContent":[null,null,null,null,null,null,null,null,null,null,null,null],"names":["_Reflect"],"mappings":"AAAA;;;;;;;;;;AAUG;AAEH;AACA,MAAM,KAAK,GAAG,UAAU,CAAC,IAAI;AAC7B,MAAMA,UAAQ,GAAG,UAAU,CAAC,OAAO;AAoB7B,SAAU,UAAU,CAAC,GAAG,IAAe,EAAA;IAC3C,OAAaA,UAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,IAAI,CAAC;AAC9C;AAEA;;AAEG;AACI,MAAM,OAAO,GAAG,KAAK,CAAC,GAAG;;ACzChC;;;;;;;AAOG;AAEH;AACA,MAAM,OAAO,GAAG,UAAU,CAAC,MAAM;AAMjC;;;AAGG;AACI,MAAM,MAAM,GAAG,OAAO,CAAC,MAAM;;ACpBpC;;;;;;;AAOG;AAEH;AACA,MAAM,WAAW,GAAG,UAAU,CAAC,UAAU;AACzC,MAAM,YAAY,GAAG,UAAU,CAAC,WAAW;AAC3C,MAAM,aAAa,GAAG,UAAU,CAAC,YAAY;AAC7C,MAAM,cAAc,GAAG,UAAU,CAAC,aAAa;AAM/C;;;;;;;AAOG;AACI,MAAM,UAAU,GAAG,CACxB,QAAkC,EAClC,KAAc,EACd,GAAG,IAAW,KAC+B,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;AAEpF;;;;;;;AAOG;AACI,MAAM,WAAW,GAAG,CACzB,QAAkC,EAClC,KAAc,EACd,GAAG,IAAW,KACgC,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;AAEtF;;;;AAIG;AACI,MAAM,YAAY,GAAG,CAAC,EAAwD,KAAU;IAC7F,aAAa,CAAC,EAAE,CAAC;AACnB,CAAC;AAED;;;;AAIG;AACI,MAAM,aAAa,GAAG,CAAC,EAAyD,KAAU;IAC/F,cAAc,CAAC,EAAE,CAA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AQ;AAEtD;;AAEG;AAC8B,QAAQ,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ;AAElE;;AAEG;AACuB,QAAQ,CAAC,GAAG,CAAC,IAAI,CAAC,QAAQ;AAEpD;;;AAGG;AACH;AAC0C,QAAS,CAAC,aAAa,EAAE,IAAI,CAAC,QAAQ;;AC5DhF;;;;;AAKG;AACG,SAAU,KAAK,CAAC,YAAoB,EAAA;AACxC,IAAA,OAAO,aAAa,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;AACtE;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"normalize-to-base-time-window.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAalF"} | ||
| {"version":3,"file":"normalize-to-base-time-window.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/normalize-to-base-time-window.ts"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,wBAAgB,yBAAyB,CAAC,IAAI,EAAE,IAAI,EAAE,cAAc,EAAE,MAAM,GAAG,IAAI,CAalF"} |
+14
-14
| { | ||
| "name": "@hyperfrontend/time-utils", | ||
| "version": "0.0.2", | ||
| "version": "0.0.3", | ||
| "description": "Functional time utilities for async operations, intervals, and time normalization.", | ||
@@ -29,3 +29,14 @@ "license": "MIT", | ||
| ], | ||
| "main": "./index.cjs.js", | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| ".": { | ||
| "types": "./index.d.ts", | ||
| "import": "./index.esm.js", | ||
| "require": "./index.cjs.js" | ||
| }, | ||
| "./bundle": { | ||
| "import": "./bundle/index.iife.min.js", | ||
| "require": "./bundle/index.iife.min.js" | ||
| } | ||
| }, | ||
| "repository": { | ||
@@ -43,14 +54,3 @@ "type": "git", | ||
| }, | ||
| "exports": { | ||
| "./package.json": "./package.json", | ||
| ".": { | ||
| "types": "./index.d.ts", | ||
| "import": "./index.esm.js", | ||
| "require": "./index.cjs.js" | ||
| }, | ||
| "./bundle": { | ||
| "import": "./bundle/index.iife.min.js", | ||
| "require": "./bundle/index.iife.min.js" | ||
| } | ||
| }, | ||
| "main": "./index.cjs.js", | ||
| "module": "./index.esm.js", | ||
@@ -57,0 +57,0 @@ "types": "./index.d.ts", |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"set-interval-callback.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/set-interval-callback.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,IAAI,CAGtF"} | ||
| {"version":3,"file":"set-interval-callback.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/set-interval-callback.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,wBAAgB,mBAAmB,CAAC,QAAQ,EAAE,MAAM,IAAI,EAAE,QAAQ,EAAE,MAAM,GAAG,MAAM,IAAI,CAGtF"} |
+1
-1
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/sleep.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD"} | ||
| {"version":3,"file":"sleep.d.ts","sourceRoot":"","sources":["../../../../../../../../libs/utils/time/src/sleep.ts"],"names":[],"mappings":"AAGA;;;;;GAKG;AACH,wBAAgB,KAAK,CAAC,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAEzD"} |
103126
74.75%1318
136.2%