@gjsify/timers 0.3.19 → 0.3.21

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.
package/lib/esm/index.js CHANGED
@@ -1 +1 @@
1
- import{Immediate as e,Timeout as t}from"./timeout.js";function n(e,n=0,...r){return new t(e,n,r,!1)}function r(e){e instanceof t?e.close():e!=null&&clearTimeout(e)}function i(e,n=0,...r){return new t(e,n,r,!0)}function a(e){e instanceof t?e.close():e!=null&&clearInterval(e)}function o(t,...n){return new e(t,n)}function s(t){t instanceof e?t.close():t!=null&&clearTimeout(t)}var c={setTimeout:n,clearTimeout:r,setInterval:i,clearInterval:a,setImmediate:o,clearImmediate:s,Timeout:t,Immediate:e};export{e as Immediate,t as Timeout,s as clearImmediate,a as clearInterval,r as clearTimeout,c as default,o as setImmediate,i as setInterval,n as setTimeout};
1
+ import{Immediate as e,Timeout as t}from"./timeout.js";function _setTimeout(e,n=0,...r){return new t(e,n,r,!1)}function _clearTimeout(e){e instanceof t?e.close():e!=null&&clearTimeout(e)}function _setInterval(e,n=0,...r){return new t(e,n,r,!0)}function _clearInterval(e){e instanceof t?e.close():e!=null&&clearInterval(e)}function _setImmediate(t,...n){return new e(t,n)}function _clearImmediate(t){t instanceof e?t.close():t!=null&&clearTimeout(t)}var n={setTimeout:_setTimeout,clearTimeout:_clearTimeout,setInterval:_setInterval,clearInterval:_clearInterval,setImmediate:_setImmediate,clearImmediate:_clearImmediate,Timeout:t,Immediate:e};export{e as Immediate,t as Timeout,_clearImmediate as clearImmediate,_clearInterval as clearInterval,_clearTimeout as clearTimeout,n as default,_setImmediate as setImmediate,_setInterval as setInterval,_setTimeout as setTimeout};
@@ -1 +1 @@
1
- import{Timeout as e}from"./timeout.js";function t(t=0,n,r){return new Promise((i,a)=>{if(r?.signal?.aborted){a(r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`));return}let o=new e(()=>{c(),i(n)},t,[],!1);r?.ref===!1&&o.unref();let s;function c(){s&&r?.signal&&r.signal.removeEventListener(`abort`,s)}r?.signal&&(s=()=>{o.close(),a(r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`))},r.signal.addEventListener(`abort`,s,{once:!0}))})}function n(e,n){return t(0,e,n)}async function*r(t=0,n,r){if(r?.signal?.aborted)throw r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`);for(;;){if(r?.signal?.aborted)throw r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`);yield await new Promise((i,a)=>{let o=new e(()=>{c(),i(n)},t,[],!1);r?.ref===!1&&o.unref();let s;function c(){s&&r?.signal&&r.signal.removeEventListener(`abort`,s)}r?.signal&&(s=()=>{o.close(),a(r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`))},r.signal.addEventListener(`abort`,s,{once:!0}))})}}export{n as setImmediate,r as setInterval,t as setTimeout};
1
+ import{Timeout as e}from"./timeout.js";function setTimeout(t=0,n,r){return new Promise((i,a)=>{if(r?.signal?.aborted){a(r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`));return}let o=new e(()=>{cleanup(),i(n)},t,[],!1);r?.ref===!1&&o.unref();let onAbort;function cleanup(){onAbort&&r?.signal&&r.signal.removeEventListener(`abort`,onAbort)}r?.signal&&(onAbort=()=>{o.close(),a(r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`))},r.signal.addEventListener(`abort`,onAbort,{once:!0}))})}function setImmediate(e,t){return setTimeout(0,e,t)}async function*setInterval(t=0,n,r){if(r?.signal?.aborted)throw r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`);for(;;){if(r?.signal?.aborted)throw r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`);yield await new Promise((i,a)=>{let o=new e(()=>{cleanup(),i(n)},t,[],!1);r?.ref===!1&&o.unref();let onAbort;function cleanup(){onAbort&&r?.signal&&r.signal.removeEventListener(`abort`,onAbort)}r?.signal&&(onAbort=()=>{o.close(),a(r.signal.reason??new DOMException(`The operation was aborted`,`AbortError`))},r.signal.addEventListener(`abort`,onAbort,{once:!0}))})}}export{setImmediate,setInterval,setTimeout};
@@ -1 +1 @@
1
- var e=class{_id;_ref=!0;_callback;_delay;_args;_isInterval;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._isInterval=r,r?this._id=setInterval(e,t,...n):this._id=setTimeout(e,t,...n)}ref(){return this._ref=!0,this}unref(){return this._ref=!1,this}hasRef(){return this._ref}refresh(){return this._id!=null&&(this._isInterval?(clearInterval(this._id),this._id=setInterval(this._callback,this._delay,...this._args)):(clearTimeout(this._id),this._id=setTimeout(this._callback,this._delay,...this._args))),this}close(){this._id!=null&&(this._isInterval?clearInterval(this._id):clearTimeout(this._id),this._id=null)}[Symbol.toPrimitive](){return this._id}},t=class{_id=null;_ref=!0;_cancelled=!1;constructor(e,t){Promise.resolve().then(()=>{this._cancelled||e(...t)})}ref(){return this._ref=!0,this}unref(){return this._ref=!1,this}hasRef(){return this._ref}close(){this._cancelled=!0,this._id!=null&&(clearTimeout(this._id),this._id=null)}[Symbol.toPrimitive](){return this._id}};export{t as Immediate,e as Timeout};
1
+ var Timeout=class{_id;_ref=!0;_callback;_delay;_args;_isInterval;constructor(e,t,n,r){this._callback=e,this._delay=t,this._args=n,this._isInterval=r,r?this._id=setInterval(e,t,...n):this._id=setTimeout(e,t,...n)}ref(){return this._ref=!0,this}unref(){return this._ref=!1,this}hasRef(){return this._ref}refresh(){return this._id!=null&&(this._isInterval?(clearInterval(this._id),this._id=setInterval(this._callback,this._delay,...this._args)):(clearTimeout(this._id),this._id=setTimeout(this._callback,this._delay,...this._args))),this}close(){this._id!=null&&(this._isInterval?clearInterval(this._id):clearTimeout(this._id),this._id=null)}[Symbol.toPrimitive](){return this._id}},Immediate=class{_id=null;_ref=!0;_cancelled=!1;constructor(e,t){Promise.resolve().then(()=>{this._cancelled||e(...t)})}ref(){return this._ref=!0,this}unref(){return this._ref=!1,this}hasRef(){return this._ref}close(){this._cancelled=!0,this._id!=null&&(clearTimeout(this._id),this._id=null)}[Symbol.toPrimitive](){return this._id}};export{Immediate,Timeout};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gjsify/timers",
3
- "version": "0.3.19",
3
+ "version": "0.3.21",
4
4
  "description": "Node.js timers module for Gjs",
5
5
  "type": "module",
6
6
  "module": "lib/esm/index.js",
@@ -34,8 +34,8 @@
34
34
  "timers"
35
35
  ],
36
36
  "devDependencies": {
37
- "@gjsify/cli": "^0.3.19",
38
- "@gjsify/unit": "^0.3.19",
37
+ "@gjsify/cli": "^0.3.21",
38
+ "@gjsify/unit": "^0.3.21",
39
39
  "@types/node": "^25.6.2",
40
40
  "typescript": "^6.0.3"
41
41
  }