@hyperfrontend/time-utils 0.0.2 → 0.0.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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;gBACpB,aAAa,CAAC,OAAO,CAAC;gBACtB,OAAO,GAAG,IAAI;YAChB;IACF,IAAA,CAAC;IAED,IAAA,MAAM,SAAS,GAAG,CAAC,QAAqC,KAAU;IAChE,QAAA,WAAW,CAAC,IAAI,CAAC,QAAQ,CAAC;IAC5B,IAAA,CAAC;IAED,IAAA,MAAM,WAAW,GAAG,CAAC,QAAqC,KAAU;IAClE,QAAA,WAAW,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,UAAU,KAAK,UAAU,KAAK,QAAQ,CAAC;IAC3E,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AY,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,EAAE;IAC7D,QAAA,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC;QACvC;IAEA,IAAA,IAAI,cAAc,IAAI,CAAC,EAAE;IACvB,QAAA,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC;QACtD;IAEA,IAAA,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,EAAE;IAC/B,IAAA,MAAM,UAAU,GAAG,cAAc,GAAG,EAAE,GAAG,IAAI;IAC7C,IAAA,MAAM,kBAAkB,GAAG,IAAI,CAAC,KAAK,CAAC,QAAQ,GAAG,UAAU,CAAC,GAAG,UAAU;IACzE,IAAA,OAAO,IAAI,IAAI,CAAC,kBAAkB,CAAC;IACrC;;ICpBA;;;;;;IAMG;IACG,SAAU,mBAAmB,CAAC,QAAoB,EAAE,QAAgB,EAAA;QACxE,MAAM,OAAO,GAAmB,WAAW,CAAC,QAAQ,EAAE,QAAQ,CAAC;IAC/D,IAAA,OAAO,MAAY,aAAa,CAAC,OAAO,CAAC;IAC3C;;ICVA;;;;;IAKG;IACG,SAAU,KAAK,CAAC,YAAoB,EAAA;IACxC,IAAA,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,KAAK,UAAU,CAAC,OAAO,EAAE,YAAY,CAAC,CAAC;IACpE;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.umd.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;;;;;;;IAOG;IACI,MAAM,UAAU,GAAG,CACxB,QAAkC,EAClC,KAAc,EACd,GAAG,IAAW,KAC+B,WAAW,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAEpF;;;;;;;IAOG;IACI,MAAM,WAAW,GAAG,CACzB,QAAkC,EAClC,KAAc,EACd,GAAG,IAAW,KACgC,YAAY,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC;IAEtF;;;;IAIG;IACI,MAAM,YAAY,GAAG,CAAC,EAAwD,KAAU;QAC7F,aAAa,CAAC,EAAE,CAAC;IACnB,CAAC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AAC,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 +1,2 @@
1
- !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))}});
1
+ !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}});
2
2
  //# sourceMappingURL=index.umd.min.js.map
@@ -1 +1 @@
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"}
1
+ {"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,EAASM,KAAKH,KAAKH,GAKbA,EAASO,WAAWJ,KAAKH,GAKhCA,EAASQ,IAAIL,KAAKH,GAOFA,EAAUS,eAAeN,KAAKH,iBCxClE,SAAsBU,EAAW,KACrC,IAAIC,EAAiC,KACjCC,EAA+C,GA0BnD,OAAOlC,EAAO,CAAEmC,MAxBF,KACI,OAAZF,IACFA,EAAU5B,EAAY,KACpB,MAAM+B,EAAczC,IACpBuC,EAAYG,QAASC,GAAeA,EAAWF,KAC9CJ,KAmBgBO,KAfV,KACK,OAAZN,IACFxB,EAAcwB,GACdA,EAAU,OAYeO,UARV9B,IACjBwB,EAAYO,KAAK/B,IAOqBgC,YAJnBhC,IACnBwB,EAAcA,EAAYS,OAAQL,GAAeA,IAAe5B,IAGbsB,YACvD,gBC/BM,SAAsBtB,EAAsBC,GAChD,IAAIiC,EAAiC,KACjCT,EAAuB,KACvBU,EAAoBlC,EAExB,MAAMmC,EAAQ,KACZ,GAAgB,OAAZF,EAAkB,CN0BxBtC,EMzBiBsC,GACb,MAAM7C,EAAMD,IAEE,OAAVqC,IACFU,GAAa9C,EAAMoC,GAErBS,EAAU,IACZ,GAGIG,EAAS,KACG,OAAZH,IACFT,EAAQrC,IACR8C,EAAUzC,EAAW,KACnBO,IACAkC,EAAU,MACTC,KAUP,OAAO7C,EAAO,CAAE8C,QAAOC,SAAQC,MANjB,CAACC,EAAmBtC,KAChCmC,IACAD,EAAYI,EACZF,MAIJ,8BC3CM,SAAoCG,EAAYC,GACpD,IAAKD,KAAUA,aAAgB1D,OAAS4B,EAAY8B,EAAKE,WACvD,MAAMrC,EAAY,sBAGpB,GAAIoC,GAAkB,EACpB,MAAMpC,EAAY,qCAGpB,MAAMsC,EAAWH,EAAKE,UAChBE,EAA8B,GAAjBH,EAAsB,IAEzC,OAAOxD,EADoBuB,EAAMmC,EAAWC,GAAcA,EAE5D,wBChBM,SAA8B5C,EAAsBsB,GACxD,MAAMY,EAAUvC,EAAYK,EAAUsB,GACtC,MAAO,IAAYvB,EAAcmC,EACnC,UCHM,SAAgBW,GACpB,OLeAC,EKfsBhC,GAAYrB,EAAWqB,EAAS+B,GLgB3B9D,EAASI,UAAUyB,EAAU,CAACkC,IAF9B,IAC3BA,CKdF"}
@@ -1 +1 @@
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"}
1
+ {"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 @@
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"}
1
+ {"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"}
package/index.cjs.js CHANGED
@@ -1,5 +1,91 @@
1
1
  'use strict';
2
2
 
3
+ /**
4
+ * Safe copies of Date built-in via factory function and static methods.
5
+ *
6
+ * Since constructors cannot be safely captured via Object.assign, this module
7
+ * provides a factory function that uses Reflect.construct internally.
8
+ *
9
+ * These references are captured at module initialization time to protect against
10
+ * prototype pollution attacks. Import only what you need for tree-shaking.
11
+ *
12
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/date
13
+ */
14
+ // Capture references at module initialization time
15
+ const _Date = globalThis.Date;
16
+ const _Reflect$2 = globalThis.Reflect;
17
+ function createDate(...args) {
18
+ return _Reflect$2.construct(_Date, args);
19
+ }
20
+ /**
21
+ * (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
22
+ */
23
+ const dateNow = _Date.now;
24
+
25
+ /**
26
+ * Safe copies of Object built-in methods.
27
+ *
28
+ * These references are captured at module initialization time to protect against
29
+ * prototype pollution attacks. Import only what you need for tree-shaking.
30
+ *
31
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/object
32
+ */
33
+ // Capture references at module initialization time
34
+ const _Object = globalThis.Object;
35
+ /**
36
+ * (Safe copy) Prevents modification of existing property attributes and values,
37
+ * and prevents the addition of new properties.
38
+ */
39
+ const freeze = _Object.freeze;
40
+
41
+ /**
42
+ * Safe copies of Timer/Scheduling built-in functions.
43
+ *
44
+ * These references are captured at module initialization time to protect against
45
+ * prototype pollution attacks. Import only what you need for tree-shaking.
46
+ *
47
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/timers
48
+ */
49
+ // Capture references at module initialization time
50
+ const _setTimeout = globalThis.setTimeout;
51
+ const _setInterval = globalThis.setInterval;
52
+ const _clearTimeout = globalThis.clearTimeout;
53
+ const _clearInterval = globalThis.clearInterval;
54
+ /**
55
+ * (Safe copy) Sets a timer which executes a function once the timer expires.
56
+ *
57
+ * @param callback - Function to call when the timer elapses.
58
+ * @param delay - Time in milliseconds before executing.
59
+ * @param args - Additional arguments to pass to the callback.
60
+ * @returns A numeric ID for the timer.
61
+ */
62
+ const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args);
63
+ /**
64
+ * (Safe copy) Repeatedly calls a function with a fixed time delay between each call.
65
+ *
66
+ * @param callback - Function to call at each interval.
67
+ * @param delay - Time in milliseconds between calls.
68
+ * @param args - Additional arguments to pass to the callback.
69
+ * @returns A numeric ID for the interval.
70
+ */
71
+ const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args);
72
+ /**
73
+ * (Safe copy) Cancels a timeout previously established by setTimeout.
74
+ *
75
+ * @param id - The identifier of the timeout to cancel.
76
+ */
77
+ const clearTimeout = (id) => {
78
+ _clearTimeout(id);
79
+ };
80
+ /**
81
+ * (Safe copy) Cancels a timed, repeating action previously established by setInterval.
82
+ *
83
+ * @param id - The identifier of the interval to cancel.
84
+ */
85
+ const clearInterval = (id) => {
86
+ _clearInterval(id);
87
+ };
88
+
3
89
  /**
4
90
  * Creates an interval loop that invokes one or more subscribed callback functions
5
91
  * at the specified internal (in milliseconds).
@@ -16,7 +102,7 @@ function createClock(interval = 1000) {
16
102
  const start = () => {
17
103
  if (clockId === null) {
18
104
  clockId = setInterval(() => {
19
- const currentTime = new Date();
105
+ const currentTime = createDate();
20
106
  subscribers.forEach((subscriber) => subscriber(currentTime));
21
107
  }, interval);
22
108
  }
@@ -33,7 +119,7 @@ function createClock(interval = 1000) {
33
119
  const unsubscribe = (callback) => {
34
120
  subscribers = subscribers.filter((subscriber) => subscriber !== callback);
35
121
  };
36
- return Object.freeze({ start, stop, subscribe, unsubscribe, interval });
122
+ return freeze({ start, stop, subscribe, unsubscribe, interval });
37
123
  }
38
124
 
39
125
  /**
@@ -51,7 +137,7 @@ function createTimer(callback, delay) {
51
137
  const pause = () => {
52
138
  if (timerId !== null) {
53
139
  clearTimeout(timerId);
54
- const now = Date.now();
140
+ const now = dateNow();
55
141
  /* istanbul ignore else - start is always set when timerId is not null */
56
142
  if (start !== null) {
57
143
  remaining -= now - start;
@@ -61,7 +147,7 @@ function createTimer(callback, delay) {
61
147
  };
62
148
  const resume = () => {
63
149
  if (timerId === null) {
64
- start = Date.now();
150
+ start = dateNow();
65
151
  timerId = setTimeout(() => {
66
152
  callback();
67
153
  timerId = null;
@@ -73,9 +159,66 @@ function createTimer(callback, delay) {
73
159
  remaining = newDelay;
74
160
  resume();
75
161
  };
76
- return Object.freeze({ pause, resume, reset });
162
+ return freeze({ pause, resume, reset });
77
163
  }
78
164
 
165
+ /**
166
+ * Safe copies of Error built-ins via factory functions.
167
+ *
168
+ * Since constructors cannot be safely captured via Object.assign, this module
169
+ * provides factory functions that use Reflect.construct internally.
170
+ *
171
+ * These references are captured at module initialization time to protect against
172
+ * prototype pollution attacks. Import only what you need for tree-shaking.
173
+ *
174
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/error
175
+ */
176
+ // Capture references at module initialization time
177
+ const _Error = globalThis.Error;
178
+ const _Reflect$1 = globalThis.Reflect;
179
+ /**
180
+ * (Safe copy) Creates a new Error using the captured Error constructor.
181
+ * Use this instead of `new Error()`.
182
+ *
183
+ * @param message - Optional error message.
184
+ * @param options - Optional error options.
185
+ * @returns A new Error instance.
186
+ */
187
+ const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]);
188
+
189
+ /**
190
+ * Safe copies of Math built-in methods.
191
+ *
192
+ * These references are captured at module initialization time to protect against
193
+ * prototype pollution attacks. Import only what you need for tree-shaking.
194
+ *
195
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/math
196
+ */
197
+ // Capture references at module initialization time
198
+ const _Math = globalThis.Math;
199
+ /**
200
+ * (Safe copy) Returns the largest integer less than or equal to a number.
201
+ */
202
+ const floor = _Math.floor;
203
+
204
+ /**
205
+ * Safe copies of Number built-in methods and constants.
206
+ *
207
+ * These references are captured at module initialization time to protect against
208
+ * prototype pollution attacks. Import only what you need for tree-shaking.
209
+ *
210
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/number
211
+ */
212
+ // Capture references at module initialization time
213
+ const _isNaN = globalThis.isNaN;
214
+ // ============================================================================
215
+ // Global Type Checking (legacy, less strict)
216
+ // ============================================================================
217
+ /**
218
+ * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN).
219
+ */
220
+ const globalIsNaN = _isNaN;
221
+
79
222
  /**
80
223
  * Normalizes a given time to the nearest base time window.
81
224
  *
@@ -84,16 +227,16 @@ function createTimer(callback, delay) {
84
227
  * @returns A new Date object normalized to the start of the time window
85
228
  */
86
229
  function normalizeToBaseTimeWindow(time, baseTimeWindow) {
87
- if (!time || !(time instanceof Date) || isNaN(time.getTime())) {
88
- throw new Error('Invalid time input');
230
+ if (!time || !(time instanceof Date) || globalIsNaN(time.getTime())) {
231
+ throw createError('Invalid time input');
89
232
  }
90
233
  if (baseTimeWindow <= 0) {
91
- throw new Error('Base time window must be positive');
234
+ throw createError('Base time window must be positive');
92
235
  }
93
236
  const timeInMs = time.getTime();
94
237
  const windowInMs = baseTimeWindow * 60 * 1000;
95
- const normalizedTimeInMs = Math.floor(timeInMs / windowInMs) * windowInMs;
96
- return new Date(normalizedTimeInMs);
238
+ const normalizedTimeInMs = floor(timeInMs / windowInMs) * windowInMs;
239
+ return createDate(normalizedTimeInMs);
97
240
  }
98
241
 
99
242
  /**
@@ -108,6 +251,59 @@ function setIntervalCallback(callback, interval) {
108
251
  return () => clearInterval(timerId);
109
252
  }
110
253
 
254
+ /**
255
+ * Safe copies of Promise built-in methods via factory functions.
256
+ *
257
+ * Since constructors cannot be safely captured via Object.assign, this module
258
+ * provides factory functions that use Reflect.construct internally.
259
+ *
260
+ * These references are captured at module initialization time to protect against
261
+ * prototype pollution attacks. Import only what you need for tree-shaking.
262
+ *
263
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise
264
+ */
265
+ // Capture references at module initialization time
266
+ const _Promise = globalThis.Promise;
267
+ const _Reflect = globalThis.Reflect;
268
+ /**
269
+ * (Safe copy) Creates a new Promise using the captured Promise constructor.
270
+ * Use this instead of `new Promise()`.
271
+ *
272
+ * @param executor - The executor function.
273
+ * @returns A new Promise instance.
274
+ */
275
+ const createPromise = (executor) => _Reflect.construct(_Promise, [executor]);
276
+ /**
277
+ * (Safe copy) Returns a Promise that resolves with the given value.
278
+ */
279
+ _Promise.resolve.bind(_Promise);
280
+ /**
281
+ * (Safe copy) Returns a Promise that rejects with the given reason.
282
+ */
283
+ _Promise.reject.bind(_Promise);
284
+ /**
285
+ * (Safe copy) Returns a Promise that resolves when all promises resolve.
286
+ */
287
+ _Promise.all.bind(_Promise);
288
+ /**
289
+ * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise.
290
+ */
291
+ _Promise.race.bind(_Promise);
292
+ /**
293
+ * (Safe copy) Returns a Promise that resolves when all promises settle.
294
+ */
295
+ _Promise.allSettled.bind(_Promise);
296
+ /**
297
+ * (Safe copy) Returns a Promise that resolves with the first fulfilled promise.
298
+ */
299
+ _Promise.any.bind(_Promise);
300
+ /**
301
+ * (Safe copy) Creates a Promise along with its resolve and reject functions.
302
+ * Note: Available only in ES2024+ environments.
303
+ */
304
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
305
+ _Promise.withResolvers?.bind(_Promise);
306
+
111
307
  /**
112
308
  * Pauses execution for a specified duration.
113
309
  *
@@ -115,7 +311,7 @@ function setIntervalCallback(callback, interval) {
115
311
  * @returns A promise that resolves after the specified duration
116
312
  */
117
313
  function sleep(milliseconds) {
118
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
314
+ return createPromise((resolve) => setTimeout(resolve, milliseconds));
119
315
  }
120
316
 
121
317
  exports.createClock = createClock;
package/index.cjs.js.map CHANGED
@@ -1 +1 @@
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,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;Y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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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,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;;;;;;;;"}
package/index.esm.js CHANGED
@@ -1,3 +1,89 @@
1
+ /**
2
+ * Safe copies of Date built-in via factory function and static methods.
3
+ *
4
+ * Since constructors cannot be safely captured via Object.assign, this module
5
+ * provides a factory function that uses Reflect.construct internally.
6
+ *
7
+ * These references are captured at module initialization time to protect against
8
+ * prototype pollution attacks. Import only what you need for tree-shaking.
9
+ *
10
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/date
11
+ */
12
+ // Capture references at module initialization time
13
+ const _Date = globalThis.Date;
14
+ const _Reflect$2 = globalThis.Reflect;
15
+ function createDate(...args) {
16
+ return _Reflect$2.construct(_Date, args);
17
+ }
18
+ /**
19
+ * (Safe copy) Returns the number of milliseconds elapsed since January 1, 1970 00:00:00 UTC.
20
+ */
21
+ const dateNow = _Date.now;
22
+
23
+ /**
24
+ * Safe copies of Object built-in methods.
25
+ *
26
+ * These references are captured at module initialization time to protect against
27
+ * prototype pollution attacks. Import only what you need for tree-shaking.
28
+ *
29
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/object
30
+ */
31
+ // Capture references at module initialization time
32
+ const _Object = globalThis.Object;
33
+ /**
34
+ * (Safe copy) Prevents modification of existing property attributes and values,
35
+ * and prevents the addition of new properties.
36
+ */
37
+ const freeze = _Object.freeze;
38
+
39
+ /**
40
+ * Safe copies of Timer/Scheduling built-in functions.
41
+ *
42
+ * These references are captured at module initialization time to protect against
43
+ * prototype pollution attacks. Import only what you need for tree-shaking.
44
+ *
45
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/timers
46
+ */
47
+ // Capture references at module initialization time
48
+ const _setTimeout = globalThis.setTimeout;
49
+ const _setInterval = globalThis.setInterval;
50
+ const _clearTimeout = globalThis.clearTimeout;
51
+ const _clearInterval = globalThis.clearInterval;
52
+ /**
53
+ * (Safe copy) Sets a timer which executes a function once the timer expires.
54
+ *
55
+ * @param callback - Function to call when the timer elapses.
56
+ * @param delay - Time in milliseconds before executing.
57
+ * @param args - Additional arguments to pass to the callback.
58
+ * @returns A numeric ID for the timer.
59
+ */
60
+ const setTimeout = (callback, delay, ...args) => _setTimeout(callback, delay, ...args);
61
+ /**
62
+ * (Safe copy) Repeatedly calls a function with a fixed time delay between each call.
63
+ *
64
+ * @param callback - Function to call at each interval.
65
+ * @param delay - Time in milliseconds between calls.
66
+ * @param args - Additional arguments to pass to the callback.
67
+ * @returns A numeric ID for the interval.
68
+ */
69
+ const setInterval = (callback, delay, ...args) => _setInterval(callback, delay, ...args);
70
+ /**
71
+ * (Safe copy) Cancels a timeout previously established by setTimeout.
72
+ *
73
+ * @param id - The identifier of the timeout to cancel.
74
+ */
75
+ const clearTimeout = (id) => {
76
+ _clearTimeout(id);
77
+ };
78
+ /**
79
+ * (Safe copy) Cancels a timed, repeating action previously established by setInterval.
80
+ *
81
+ * @param id - The identifier of the interval to cancel.
82
+ */
83
+ const clearInterval = (id) => {
84
+ _clearInterval(id);
85
+ };
86
+
1
87
  /**
2
88
  * Creates an interval loop that invokes one or more subscribed callback functions
3
89
  * at the specified internal (in milliseconds).
@@ -14,7 +100,7 @@ function createClock(interval = 1000) {
14
100
  const start = () => {
15
101
  if (clockId === null) {
16
102
  clockId = setInterval(() => {
17
- const currentTime = new Date();
103
+ const currentTime = createDate();
18
104
  subscribers.forEach((subscriber) => subscriber(currentTime));
19
105
  }, interval);
20
106
  }
@@ -31,7 +117,7 @@ function createClock(interval = 1000) {
31
117
  const unsubscribe = (callback) => {
32
118
  subscribers = subscribers.filter((subscriber) => subscriber !== callback);
33
119
  };
34
- return Object.freeze({ start, stop, subscribe, unsubscribe, interval });
120
+ return freeze({ start, stop, subscribe, unsubscribe, interval });
35
121
  }
36
122
 
37
123
  /**
@@ -49,7 +135,7 @@ function createTimer(callback, delay) {
49
135
  const pause = () => {
50
136
  if (timerId !== null) {
51
137
  clearTimeout(timerId);
52
- const now = Date.now();
138
+ const now = dateNow();
53
139
  /* istanbul ignore else - start is always set when timerId is not null */
54
140
  if (start !== null) {
55
141
  remaining -= now - start;
@@ -59,7 +145,7 @@ function createTimer(callback, delay) {
59
145
  };
60
146
  const resume = () => {
61
147
  if (timerId === null) {
62
- start = Date.now();
148
+ start = dateNow();
63
149
  timerId = setTimeout(() => {
64
150
  callback();
65
151
  timerId = null;
@@ -71,9 +157,66 @@ function createTimer(callback, delay) {
71
157
  remaining = newDelay;
72
158
  resume();
73
159
  };
74
- return Object.freeze({ pause, resume, reset });
160
+ return freeze({ pause, resume, reset });
75
161
  }
76
162
 
163
+ /**
164
+ * Safe copies of Error built-ins via factory functions.
165
+ *
166
+ * Since constructors cannot be safely captured via Object.assign, this module
167
+ * provides factory functions that use Reflect.construct internally.
168
+ *
169
+ * These references are captured at module initialization time to protect against
170
+ * prototype pollution attacks. Import only what you need for tree-shaking.
171
+ *
172
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/error
173
+ */
174
+ // Capture references at module initialization time
175
+ const _Error = globalThis.Error;
176
+ const _Reflect$1 = globalThis.Reflect;
177
+ /**
178
+ * (Safe copy) Creates a new Error using the captured Error constructor.
179
+ * Use this instead of `new Error()`.
180
+ *
181
+ * @param message - Optional error message.
182
+ * @param options - Optional error options.
183
+ * @returns A new Error instance.
184
+ */
185
+ const createError = (message, options) => _Reflect$1.construct(_Error, [message, options]);
186
+
187
+ /**
188
+ * Safe copies of Math built-in methods.
189
+ *
190
+ * These references are captured at module initialization time to protect against
191
+ * prototype pollution attacks. Import only what you need for tree-shaking.
192
+ *
193
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/math
194
+ */
195
+ // Capture references at module initialization time
196
+ const _Math = globalThis.Math;
197
+ /**
198
+ * (Safe copy) Returns the largest integer less than or equal to a number.
199
+ */
200
+ const floor = _Math.floor;
201
+
202
+ /**
203
+ * Safe copies of Number built-in methods and constants.
204
+ *
205
+ * These references are captured at module initialization time to protect against
206
+ * prototype pollution attacks. Import only what you need for tree-shaking.
207
+ *
208
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/number
209
+ */
210
+ // Capture references at module initialization time
211
+ const _isNaN = globalThis.isNaN;
212
+ // ============================================================================
213
+ // Global Type Checking (legacy, less strict)
214
+ // ============================================================================
215
+ /**
216
+ * (Safe copy) Global isNaN function (coerces to number first, less strict than Number.isNaN).
217
+ */
218
+ const globalIsNaN = _isNaN;
219
+
77
220
  /**
78
221
  * Normalizes a given time to the nearest base time window.
79
222
  *
@@ -82,16 +225,16 @@ function createTimer(callback, delay) {
82
225
  * @returns A new Date object normalized to the start of the time window
83
226
  */
84
227
  function normalizeToBaseTimeWindow(time, baseTimeWindow) {
85
- if (!time || !(time instanceof Date) || isNaN(time.getTime())) {
86
- throw new Error('Invalid time input');
228
+ if (!time || !(time instanceof Date) || globalIsNaN(time.getTime())) {
229
+ throw createError('Invalid time input');
87
230
  }
88
231
  if (baseTimeWindow <= 0) {
89
- throw new Error('Base time window must be positive');
232
+ throw createError('Base time window must be positive');
90
233
  }
91
234
  const timeInMs = time.getTime();
92
235
  const windowInMs = baseTimeWindow * 60 * 1000;
93
- const normalizedTimeInMs = Math.floor(timeInMs / windowInMs) * windowInMs;
94
- return new Date(normalizedTimeInMs);
236
+ const normalizedTimeInMs = floor(timeInMs / windowInMs) * windowInMs;
237
+ return createDate(normalizedTimeInMs);
95
238
  }
96
239
 
97
240
  /**
@@ -106,6 +249,59 @@ function setIntervalCallback(callback, interval) {
106
249
  return () => clearInterval(timerId);
107
250
  }
108
251
 
252
+ /**
253
+ * Safe copies of Promise built-in methods via factory functions.
254
+ *
255
+ * Since constructors cannot be safely captured via Object.assign, this module
256
+ * provides factory functions that use Reflect.construct internally.
257
+ *
258
+ * These references are captured at module initialization time to protect against
259
+ * prototype pollution attacks. Import only what you need for tree-shaking.
260
+ *
261
+ * @module @hyperfrontend/immutable-api-utils/built-in-copy/promise
262
+ */
263
+ // Capture references at module initialization time
264
+ const _Promise = globalThis.Promise;
265
+ const _Reflect = globalThis.Reflect;
266
+ /**
267
+ * (Safe copy) Creates a new Promise using the captured Promise constructor.
268
+ * Use this instead of `new Promise()`.
269
+ *
270
+ * @param executor - The executor function.
271
+ * @returns A new Promise instance.
272
+ */
273
+ const createPromise = (executor) => _Reflect.construct(_Promise, [executor]);
274
+ /**
275
+ * (Safe copy) Returns a Promise that resolves with the given value.
276
+ */
277
+ _Promise.resolve.bind(_Promise);
278
+ /**
279
+ * (Safe copy) Returns a Promise that rejects with the given reason.
280
+ */
281
+ _Promise.reject.bind(_Promise);
282
+ /**
283
+ * (Safe copy) Returns a Promise that resolves when all promises resolve.
284
+ */
285
+ _Promise.all.bind(_Promise);
286
+ /**
287
+ * (Safe copy) Returns a Promise that resolves/rejects with the first settled promise.
288
+ */
289
+ _Promise.race.bind(_Promise);
290
+ /**
291
+ * (Safe copy) Returns a Promise that resolves when all promises settle.
292
+ */
293
+ _Promise.allSettled.bind(_Promise);
294
+ /**
295
+ * (Safe copy) Returns a Promise that resolves with the first fulfilled promise.
296
+ */
297
+ _Promise.any.bind(_Promise);
298
+ /**
299
+ * (Safe copy) Creates a Promise along with its resolve and reject functions.
300
+ * Note: Available only in ES2024+ environments.
301
+ */
302
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
303
+ _Promise.withResolvers?.bind(_Promise);
304
+
109
305
  /**
110
306
  * Pauses execution for a specified duration.
111
307
  *
@@ -113,7 +309,7 @@ function setIntervalCallback(callback, interval) {
113
309
  * @returns A promise that resolves after the specified duration
114
310
  */
115
311
  function sleep(milliseconds) {
116
- return new Promise((resolve) => setTimeout(resolve, milliseconds));
312
+ return createPromise((resolve) => setTimeout(resolve, milliseconds));
117
313
  }
118
314
 
119
315
  export { createClock, createTimer, normalizeToBaseTimeWindow, setIntervalCallback, sleep };