@peter.naydenov/walk-async 7.0.1 → 7.0.2

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/Changelog.md CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
 
4
4
 
5
+ ### 7.0.2 (2026-10-31)
6
+ - [x] Dependency updates. Ask-for-promise to version 3.2.2;
7
+ - [x] Restore `ask-for-promise` for traversal and callback settlement, replacing the library's internal async/await implementation while keeping the current callback and error behavior;
8
+ - [x] Build: The build moved from Rollup to Vite. Vite builds with Rolldown and resolves the modules on its own. The 'rollup' and the three '@rollup/plugin-*' dev dependencies are gone;
9
+ - [x] Fix: '@rollup/plugin-node-resolve' was removed from the build. It was not needed, and its 'deepmerge' dependency had a prototype poisoning advisory with no fixed version;
10
+ - [x] Build: The build target is pinned to ES2015. The bundles carried the syntax of the source, so the output level was an accident. The target makes it a guarantee;
11
+ - [x] The UMD bundle calls the AMD loader with the standard 'define ( dependencies, factory )' signature. The AMD mock of the distribution test follows the signature now;
12
+ - [x] Test: The examples of the skill are run against the source and the shipped bundle. A change in the bundle that breaks a documented example fails the suite now;
13
+
14
+
15
+
5
16
  ### 7.0.1 (2026-10-16)
6
17
  - [x] Dependency updates. Ask-for-promise to version 3.2.1;
7
18
 
package/README.md CHANGED
@@ -66,6 +66,9 @@ The [benchmark script](https://github.com/PeterNaydenov/walk-async/blob/main/ben
66
66
 
67
67
  ## Installation
68
68
 
69
+ Walk Async uses `ask-for-promise` and requires a JavaScript runtime with
70
+ `WeakRef` support, including when using the bundled browser distributions.
71
+
69
72
  ```sh
70
73
  npm install @peter.naydenov/walk-async
71
74
  ```
@@ -1 +1 @@
1
- "use strict";function e(e){return null==e||e.nodeType?"simple":Array.isArray(e)?"array":"object"==typeof e?e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)?"simple":"object":"simple"}function t(e,t){if(!Array.isArray(t))return!1;const a=Number(e);return Number.isInteger(a)&&a>=0&&a<4294967295&&String(a)===e}function a(e,t,a){"__proto__"===t?Object.defineProperty(e,t,{value:a,enumerable:!0,writable:!0,configurable:!0}):e[t]=a}const n=new WeakSet;function r(e){const t=Object.freeze({value:e,hasValue:arguments.length>0});return n.add(t),t}function i(e){return n.has(e)}function o(e,t,a,n,i,o){return o.breadcrumbs&&o.parentPath?{value:e,key:t,breadcrumbs:n,parentPath:i,IGNORE:a,FINISH:r}:o.breadcrumbs?{value:e,key:t,breadcrumbs:n,IGNORE:a,FINISH:r}:o.parentPath?{value:e,key:t,parentPath:i,IGNORE:a,FINISH:r}:{value:e,key:t,IGNORE:a,FINISH:r}}const c=new WeakSet;function s(e){const t=Object.freeze({value:e,hasValue:arguments.length>0});return c.add(t),t}function u(e){return c.has(e)}const l=Symbol("ignore___");function f(){return l}function p(e){return e===l}async function d(e,t,a,n,...o){let c,l,p=`${n} at '${t.breadcrumbs??t.key}'`;function d(){c||(c=new Promise(e=>{l=e}),c.catch(()=>{}))}Object.defineProperties(t,{resolve:{enumerable:!0,get:()=>(d(),l)},reject:{enumerable:!0,get:()=>(d(),()=>l(f()))}}),a.add(p);try{const a=await e(t,...o),l=c?await c:a;return"objectCallback"===n&&u(l)&&l.hasValue?s(await l.value):i(l)&&l.hasValue?r(await l.value):l}finally{a.delete(p)}}async function y(n,r,c,l,y,v,k,w,j,P,g,S,...I){let[O,C]=l,F=Object.keys(n),V=v.detectCycles?{data:n,location:r,parent:P,depth:P?P.depth+1:0}:void 0,N=!1;g&&g.set(n,V);for(let l=0;l<F.length&&!N;l++){const P=F[l];let A=n[P],$=e(A),_=v.copy&&t(P,r),E=v.breadcrumbs&&("simple"!==$||!j&&O)?`${y}/${P}`:void 0,z=!1;if("simple"!==$&&C&&!k.isFinished){const t=o(A,P,f,E,w,v);t.PASS=s;const a=await d(C,t,S,"objectCallback",...I);if(i(a)){if(!a.hasValue||!O)return b(a,r,P,_,v,k),V;c.length=0,k.restart=!0,k.isFinished=!0,N=!0,A=a.value}else{if(p(a))continue;u(a)?(z=!0,a.hasValue&&(A=a.value)):A=a}$=e(A)}if("simple"===$){if(z||j&&!k.isFinished||!O){if(!v.copy)continue;_?r.push(A):a(r,P,A);continue}const t=o(A,P,f,E,w,v);t.isFinished=k.isFinished;let n=await d(O,t,S,"keyCallback",...I);if(i(n))return b(n,r,P,_,v,k),V;if(p(n))continue;const c=e(n);if("simple"===c){if(!v.copy)continue;_?r.push(n):a(r,P,n);continue}A=n,$=c}const R=v.detectCycles?m(A,V,g):void 0;if(R){if(!v.copy)continue;_?r.push(R.location):a(r,P,R.location)}else{if("object"===$){const e=v.copy?{}:void 0;v.copy&&(_?r.push(e):a(r,P,e)),c.push(h(A,e,E,w,P,z,V))}if("array"===$){const e=v.copy?[]:void 0;v.copy&&(_?r.push(e):a(r,P,e)),c.push(h(A,e,E,w,P,z,V))}}}return V}function b(e,t,n,r,i,o){o.finished=!0,i.copy&&e.hasValue&&(r?t.push(e.value):a(t,n,e.value))}function h(e,t,a,n,r,i,o){return{data:e,location:t,breadcrumbs:a,parentPath:n,key:r,pass:i,parent:o}}function m(e,t,a){if(a)return a.get(e);for(let a=t;a;a=a.parent)if(a.data===e)return a}function v(e,t,a){if(!a){if(t.depth<32)return;a=new WeakMap;for(let e=t;e;e=e.parent)a.set(e.data,e);return a}const n=[];for(;e!==t;)e.depth>=t.depth?(a.delete(e.data),e=e.parent):(n.push(t),t=t.parent);for(let e=n.length-1;e>=0;e--){const t=n[e];a.set(t.data,t)}return a}module.exports=async function(t,...a){const n=new Set,r=async function(t,a,...n){let r,c,l,{data:b,keyCallback:h,objectCallback:m,settings:k}=t,w=e(b),j=[],P=!(!h&&!m),g={copy:!1!==k?.copy,breadcrumbs:P&&!1!==k?.breadcrumbs,parentPath:P&&!1!==k?.parentPath,detectCycles:!1!==k?.detectCycles},S=g.breadcrumbs?"root":void 0,I=g.parentPath&&"simple"!==w?Object.freeze(["root"]):void 0,O=!1,C={finished:!1,isFinished:!1,restart:!1},F=[h,m];if("simple"!==w&&m){const t=o(b,"root",f,S,g.parentPath?Object.freeze([]):void 0,g);t.PASS=s;const r=await d(m,t,a,"objectCallback",...n);if(i(r)){if(!r.hasValue){if(!g.copy)return;return"array"===w?[]:{}}if(!h)return g.copy?r.value:void 0;C.isFinished=!0,b=r.value}else{if(p(r)){if(!g.copy)return;return"array"===w?[]:{}}u(r)?(O=!0,r.hasValue&&(b=r.value)):b=r}w=e(b)}switch(w){case"array":r=g.copy?[]:void 0,l=await y(b,r,j,F,S,g,C,I,O,void 0,c,a,...n);break;case"object":r=g.copy?{}:void 0,l=await y(b,r,j,F,S,g,C,I,O,void 0,c,a,...n);break;case"simple":return g.copy?b:void 0}for(let e=0;e<j.length&&!C.finished;){const t=j[e];j[e]=void 0,C.restart=!1,g.detectCycles&&(c=v(l,t.parent,c));const r=g.parentPath?Object.freeze([...t.parentPath,t.key]):void 0;l=await y(t.data,t.location,j,F,t.breadcrumbs,g,C,r,t.pass,t.parent,c,a,...n),e=C.restart?0:e+1}return r}(t,n,...a);if(null==t.timeout)return r;let c;const l=new Promise((e,a)=>{c=setTimeout(()=>{const e=[...n].map(e=>`\n - ${e}`).join("");a(new Error(`walk-async: timed out after ${t.timeout}ms; callbacks still pending:${e}`))},t.timeout)});try{return await Promise.race([r,l])}finally{clearTimeout(c)}};
1
+ "use strict";function e(e){return e==null||e.nodeType?`simple`:Array.isArray(e)?`array`:typeof e==`object`?e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)?`simple`:`object`:`simple`}function t(e,t){if(!Array.isArray(t))return!1;let n=Number(e);return Number.isInteger(n)&&n>=0&&n<4294967295&&String(n)===e}function n(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var r=new WeakSet;function i(e){let t=Object.freeze({value:e,hasValue:arguments.length>0});return r.add(t),t}function a(e){return r.has(e)}function o(e,t,n,r,a,o){return o.breadcrumbs&&o.parentPath?{value:e,key:t,breadcrumbs:r,parentPath:a,IGNORE:n,FINISH:i}:o.breadcrumbs?{value:e,key:t,breadcrumbs:r,IGNORE:n,FINISH:i}:o.parentPath?{value:e,key:t,parentPath:a,IGNORE:n,FINISH:i}:{value:e,key:t,IGNORE:n,FINISH:i}}var s=new WeakSet;function c(e){let t=Object.freeze({value:e,hasValue:arguments.length>0});return s.add(t),t}function l(e){return s.has(e)}var u=Symbol(`ignore___`);function d(){return u}function f(e){return e===u}function p(e){return e?h(e):m()}p.sequence=function(e,...t){let n=p(),r=[];function*i(e){for(let t of e)yield t}let a=i(e);function o(e,...t){e.done?n.done(r):Promise.resolve().then(()=>e.value(...t)).then(e=>{r.push(e),o(a.next(),...t,e)},e=>{n.cancel(e)})}try{o(a.next(),...t)}catch(e){n.cancel(e)}return n},p.all=function(e,...t){let n=p(),r=[],i;try{i=e.map((e,n)=>Promise.resolve().then(()=>typeof e==`function`?e(...t):e).then(e=>r[n]=e,e=>{throw e}))}catch(e){return n.cancel(e),n}return Promise.all(i).then(()=>n.done(r),e=>n.cancel(e)),n};function m(){let e,t,n=new Promise((n,r)=>{e=n,t=r}),r={promise:n,promises:null,_activeTimer:null,done:()=>{},cancel:()=>{},each:()=>{},onComplete:g(n),timeout:_()};return r.done=function(t){r._activeTimer!==null&&(clearTimeout(r._activeTimer),r._activeTimer=null),e(t)},r.cancel=function(e){r._activeTimer!==null&&(clearTimeout(r._activeTimer),r._activeTimer=null),t(e)},r.each=function(e,...t){e({value:null,done:r.done,cancel:r.cancel,timeout:(e,t)=>this.timeout(e,t)},void 0,...t)},r}function h(e){let t=e.map(e=>m()),n=t.map(e=>e.promise),r=Promise.all(n),i={promise:r,promises:t,_list:e,_activeTimer:null,done:()=>{},cancel:()=>{},each:()=>{},onComplete:g(r),timeout:_()};return i.done=function(e){this._activeTimer!==null&&(clearTimeout(this._activeTimer),this._activeTimer=null),this.promises.forEach(t=>t.done(e))},i.cancel=function(e){this._activeTimer!==null&&(clearTimeout(this._activeTimer),this._activeTimer=null),this.promises.forEach(t=>t.cancel(e))},i.each=function(e,...t){this.promises.forEach((n,r)=>e({value:this._list[r],done:n.done,cancel:n.cancel,timeout:(e,t)=>n.timeout(e,t)},r,...t))},i}function g(e){return function(t,n=null){n===null?e.then(e=>t(e)):e.then(e=>t(e),e=>n(e))}}function _(){return function(e,t){let n=this;n._activeTimer!==null&&clearTimeout(n._activeTimer);let r=setTimeout(()=>n.done(t),e);n._activeTimer=r;let i=()=>{clearTimeout(r),n._activeTimer===r&&(n._activeTimer=null)};return n.promise.then(i,i),n}}function v(e){let t=p();function n(r,i){let a;try{a=e[r](i)}catch(e){t.cancel(e);return}if(a.done){t.done(a.value);return}let o=p();o.done(a.value),o.promise.then(e=>n(`next`,e),e=>n(`throw`,e))}return n(`next`),t.promise}function y(e,t,n,r,...o){return v(s());function*s(){var s;let u,f,m=`${r} at '${(s=t.breadcrumbs)==null?t.key:s}'`;function h(){u||(u=p(),f=u.done,u.promise.catch(()=>{}))}Object.defineProperties(t,{resolve:{enumerable:!0,get:()=>(h(),f)},reject:{enumerable:!0,get:()=>(h(),()=>f(d()))}}),n.add(m);try{let n=yield e(t,...o),s=u?yield u.promise:n;return r===`objectCallback`&&l(s)&&s.hasValue?c(yield s.value):a(s)&&s.hasValue?i(yield s.value):s}finally{n.delete(m)}}}function b(r,i,s,u,p,m,h,g,_,b,w,T,...E){return v(D());function*D(){let[v,D]=u,O=Object.keys(r),k=m.detectCycles?{data:r,location:i,parent:b,depth:b?b.depth+1:0}:void 0,A=!1;w&&w.set(r,k);for(let u=0;u<O.length&&!A;u++){let b=O[u],j=r[b],M=e(j),N=m.copy&&t(b,i),P=m.breadcrumbs&&(M!==`simple`||!_&&v)?`${p}/${b}`:void 0,F=!1;if(M!==`simple`&&D&&!h.isFinished){let t=o(j,b,d,P,g,m);t.PASS=c;let n=yield y(D,t,T,`objectCallback`,...E);if(a(n)){if(!n.hasValue||!v)return x(n,i,b,N,m,h),k;s.length=0,h.restart=!0,h.isFinished=!0,A=!0,j=n.value}else if(f(n))continue;else l(n)?(F=!0,n.hasValue&&(j=n.value)):j=n;M=e(j)}if(M===`simple`){if(F||_&&!h.isFinished||!v){if(!m.copy)continue;N?i.push(j):n(i,b,j);continue}let t=o(j,b,d,P,g,m);t.isFinished=h.isFinished;let r=yield y(v,t,T,`keyCallback`,...E);if(a(r))return x(r,i,b,N,m,h),k;if(f(r))continue;let s=e(r);if(s===`simple`){if(!m.copy)continue;N?i.push(r):n(i,b,r);continue}j=r,M=s}let I=m.detectCycles?C(j,k,w):void 0;if(I){if(!m.copy)continue;N?i.push(I.location):n(i,b,I.location)}else{if(M===`object`){let e=m.copy?{}:void 0;m.copy&&(N?i.push(e):n(i,b,e)),s.push(S(j,e,P,g,b,F,k))}if(M===`array`){let e=m.copy?[]:void 0;m.copy&&(N?i.push(e):n(i,b,e)),s.push(S(j,e,P,g,b,F,k))}}}return k}}function x(e,t,r,i,a,o){o.finished=!0,a.copy&&e.hasValue&&(i?t.push(e.value):n(t,r,e.value))}function S(e,t,n,r,i,a,o){return{data:e,location:t,breadcrumbs:n,parentPath:r,key:i,pass:a,parent:o}}function C(e,t,n){if(n)return n.get(e);for(let n=t;n;n=n.parent)if(n.data===e)return n}function w(e,...t){return v(n());function*n(){let n=new Set,r=T(e,n,...t);if(e.timeout==null)return yield r;let i=p(),a=setTimeout(()=>{let t=[...n].map(e=>`\n - ${e}`).join(``);i.cancel(Error(`walk-async: timed out after ${e.timeout}ms; callbacks still pending:${t}`))},e.timeout);r.then(i.done,i.cancel);try{return yield i.promise}finally{clearTimeout(a)}}}function T(t,n,...r){return v(i());function*i(){let{data:i,keyCallback:s,objectCallback:u,settings:p}=t,m=e(i),h,g=[],_,v,x=!!(s||u),S={copy:(p==null?void 0:p.copy)!==!1,breadcrumbs:x&&(p==null?void 0:p.breadcrumbs)!==!1,parentPath:x&&(p==null?void 0:p.parentPath)!==!1,detectCycles:(p==null?void 0:p.detectCycles)!==!1},C=S.breadcrumbs?`root`:void 0,w=S.parentPath&&m!==`simple`?Object.freeze([`root`]):void 0,T=!1,D={finished:!1,isFinished:!1,restart:!1},O=[s,u];if(m!==`simple`&&u){let t=S.parentPath?Object.freeze([]):void 0,p=o(i,`root`,d,C,t,S);p.PASS=c;let h=yield y(u,p,n,`objectCallback`,...r);if(a(h)){if(!h.hasValue)return S.copy?m===`array`?[]:{}:void 0;if(!s)return S.copy?h.value:void 0;D.isFinished=!0,i=h.value}else if(f(h))return S.copy?m===`array`?[]:{}:void 0;else l(h)?(T=!0,h.hasValue&&(i=h.value)):i=h;m=e(i)}switch(m){case`array`:h=S.copy?[]:void 0,v=yield b(i,h,g,O,C,S,D,w,T,void 0,_,n,...r);break;case`object`:h=S.copy?{}:void 0,v=yield b(i,h,g,O,C,S,D,w,T,void 0,_,n,...r);break;case`simple`:return S.copy?i:void 0}for(let e=0;e<g.length&&!D.finished;){let t=g[e];g[e]=void 0,D.restart=!1,S.detectCycles&&(_=E(v,t.parent,_));let i=S.parentPath?Object.freeze([...t.parentPath,t.key]):void 0;v=yield b(t.data,t.location,g,O,t.breadcrumbs,S,D,i,t.pass,t.parent,_,n,...r),e=D.restart?0:e+1}return h}}function E(e,t,n){if(!n){if(t.depth<32)return;n=new WeakMap;for(let e=t;e;e=e.parent)n.set(e.data,e);return n}let r=[];for(;e!==t;)e.depth>=t.depth?(n.delete(e.data),e=e.parent):(r.push(t),t=t.parent);for(let e=r.length-1;e>=0;e--){let t=r[e];n.set(t.data,t)}return n}module.exports=w;
@@ -1 +1,396 @@
1
- function e(e){return null==e||e.nodeType?"simple":Array.isArray(e)?"array":"object"==typeof e?e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)?"simple":"object":"simple"}function t(e,t){if(!Array.isArray(t))return!1;const a=Number(e);return Number.isInteger(a)&&a>=0&&a<4294967295&&String(a)===e}function a(e,t,a){"__proto__"===t?Object.defineProperty(e,t,{value:a,enumerable:!0,writable:!0,configurable:!0}):e[t]=a}const n=new WeakSet;function r(e){const t=Object.freeze({value:e,hasValue:arguments.length>0});return n.add(t),t}function i(e){return n.has(e)}function o(e,t,a,n,i,o){return o.breadcrumbs&&o.parentPath?{value:e,key:t,breadcrumbs:n,parentPath:i,IGNORE:a,FINISH:r}:o.breadcrumbs?{value:e,key:t,breadcrumbs:n,IGNORE:a,FINISH:r}:o.parentPath?{value:e,key:t,parentPath:i,IGNORE:a,FINISH:r}:{value:e,key:t,IGNORE:a,FINISH:r}}const c=new WeakSet;function s(e){const t=Object.freeze({value:e,hasValue:arguments.length>0});return c.add(t),t}function u(e){return c.has(e)}const l=Symbol("ignore___");function f(){return l}function p(e){return e===l}async function d(e,t,a,n,...o){let c,l,p=`${n} at '${t.breadcrumbs??t.key}'`;function d(){c||(c=new Promise(e=>{l=e}),c.catch(()=>{}))}Object.defineProperties(t,{resolve:{enumerable:!0,get:()=>(d(),l)},reject:{enumerable:!0,get:()=>(d(),()=>l(f()))}}),a.add(p);try{const a=await e(t,...o),l=c?await c:a;return"objectCallback"===n&&u(l)&&l.hasValue?s(await l.value):i(l)&&l.hasValue?r(await l.value):l}finally{a.delete(p)}}async function y(n,r,c,l,y,v,k,w,j,P,g,S,...I){let[O,C]=l,F=Object.keys(n),V=v.detectCycles?{data:n,location:r,parent:P,depth:P?P.depth+1:0}:void 0,N=!1;g&&g.set(n,V);for(let l=0;l<F.length&&!N;l++){const P=F[l];let A=n[P],$=e(A),_=v.copy&&t(P,r),E=v.breadcrumbs&&("simple"!==$||!j&&O)?`${y}/${P}`:void 0,z=!1;if("simple"!==$&&C&&!k.isFinished){const t=o(A,P,f,E,w,v);t.PASS=s;const a=await d(C,t,S,"objectCallback",...I);if(i(a)){if(!a.hasValue||!O)return b(a,r,P,_,v,k),V;c.length=0,k.restart=!0,k.isFinished=!0,N=!0,A=a.value}else{if(p(a))continue;u(a)?(z=!0,a.hasValue&&(A=a.value)):A=a}$=e(A)}if("simple"===$){if(z||j&&!k.isFinished||!O){if(!v.copy)continue;_?r.push(A):a(r,P,A);continue}const t=o(A,P,f,E,w,v);t.isFinished=k.isFinished;let n=await d(O,t,S,"keyCallback",...I);if(i(n))return b(n,r,P,_,v,k),V;if(p(n))continue;const c=e(n);if("simple"===c){if(!v.copy)continue;_?r.push(n):a(r,P,n);continue}A=n,$=c}const R=v.detectCycles?m(A,V,g):void 0;if(R){if(!v.copy)continue;_?r.push(R.location):a(r,P,R.location)}else{if("object"===$){const e=v.copy?{}:void 0;v.copy&&(_?r.push(e):a(r,P,e)),c.push(h(A,e,E,w,P,z,V))}if("array"===$){const e=v.copy?[]:void 0;v.copy&&(_?r.push(e):a(r,P,e)),c.push(h(A,e,E,w,P,z,V))}}}return V}function b(e,t,n,r,i,o){o.finished=!0,i.copy&&e.hasValue&&(r?t.push(e.value):a(t,n,e.value))}function h(e,t,a,n,r,i,o){return{data:e,location:t,breadcrumbs:a,parentPath:n,key:r,pass:i,parent:o}}function m(e,t,a){if(a)return a.get(e);for(let a=t;a;a=a.parent)if(a.data===e)return a}async function v(t,...a){const n=new Set,r=async function(t,a,...n){let r,c,l,{data:b,keyCallback:h,objectCallback:m,settings:v}=t,w=e(b),j=[],P=!(!h&&!m),g={copy:!1!==v?.copy,breadcrumbs:P&&!1!==v?.breadcrumbs,parentPath:P&&!1!==v?.parentPath,detectCycles:!1!==v?.detectCycles},S=g.breadcrumbs?"root":void 0,I=g.parentPath&&"simple"!==w?Object.freeze(["root"]):void 0,O=!1,C={finished:!1,isFinished:!1,restart:!1},F=[h,m];if("simple"!==w&&m){const t=o(b,"root",f,S,g.parentPath?Object.freeze([]):void 0,g);t.PASS=s;const r=await d(m,t,a,"objectCallback",...n);if(i(r)){if(!r.hasValue){if(!g.copy)return;return"array"===w?[]:{}}if(!h)return g.copy?r.value:void 0;C.isFinished=!0,b=r.value}else{if(p(r)){if(!g.copy)return;return"array"===w?[]:{}}u(r)?(O=!0,r.hasValue&&(b=r.value)):b=r}w=e(b)}switch(w){case"array":r=g.copy?[]:void 0,l=await y(b,r,j,F,S,g,C,I,O,void 0,c,a,...n);break;case"object":r=g.copy?{}:void 0,l=await y(b,r,j,F,S,g,C,I,O,void 0,c,a,...n);break;case"simple":return g.copy?b:void 0}for(let e=0;e<j.length&&!C.finished;){const t=j[e];j[e]=void 0,C.restart=!1,g.detectCycles&&(c=k(l,t.parent,c));const r=g.parentPath?Object.freeze([...t.parentPath,t.key]):void 0;l=await y(t.data,t.location,j,F,t.breadcrumbs,g,C,r,t.pass,t.parent,c,a,...n),e=C.restart?0:e+1}return r}(t,n,...a);if(null==t.timeout)return r;let c;const l=new Promise((e,a)=>{c=setTimeout(()=>{const e=[...n].map(e=>`\n - ${e}`).join("");a(new Error(`walk-async: timed out after ${t.timeout}ms; callbacks still pending:${e}`))},t.timeout)});try{return await Promise.race([r,l])}finally{clearTimeout(c)}}function k(e,t,a){if(!a){if(t.depth<32)return;a=new WeakMap;for(let e=t;e;e=e.parent)a.set(e.data,e);return a}const n=[];for(;e!==t;)e.depth>=t.depth?(a.delete(e.data),e=e.parent):(n.push(t),t=t.parent);for(let e=n.length-1;e>=0;e--){const t=n[e];a.set(t.data,t)}return a}export{v as default};
1
+ //#region src/findType.js
2
+ function e(e) {
3
+ return e == null || e.nodeType ? "simple" : Array.isArray(e) ? "array" : typeof e == "object" ? e instanceof Date || e instanceof RegExp || e instanceof Map || e instanceof Set || e instanceof WeakMap || e instanceof WeakSet || e instanceof ArrayBuffer || e instanceof DataView || ArrayBuffer.isView(e) ? "simple" : "object" : "simple";
4
+ }
5
+ //#endregion
6
+ //#region src/validateForInsertion.js
7
+ function t(e, t) {
8
+ if (!Array.isArray(t)) return !1;
9
+ let n = Number(e);
10
+ return Number.isInteger(n) && n >= 0 && n < 4294967295 && String(n) === e;
11
+ }
12
+ //#endregion
13
+ //#region src/setKey.js
14
+ function n(e, t, n) {
15
+ t === "__proto__" ? Object.defineProperty(e, t, {
16
+ value: n,
17
+ enumerable: !0,
18
+ writable: !0,
19
+ configurable: !0
20
+ }) : e[t] = n;
21
+ }
22
+ //#endregion
23
+ //#region src/finish.js
24
+ var r = /* @__PURE__ */ new WeakSet();
25
+ function i(e) {
26
+ let t = Object.freeze({
27
+ value: e,
28
+ hasValue: arguments.length > 0
29
+ });
30
+ return r.add(t), t;
31
+ }
32
+ function a(e) {
33
+ return r.has(e);
34
+ }
35
+ //#endregion
36
+ //#region src/createCallbackArgs.js
37
+ function o(e, t, n, r, a, o) {
38
+ return o.breadcrumbs && o.parentPath ? {
39
+ value: e,
40
+ key: t,
41
+ breadcrumbs: r,
42
+ parentPath: a,
43
+ IGNORE: n,
44
+ FINISH: i
45
+ } : o.breadcrumbs ? {
46
+ value: e,
47
+ key: t,
48
+ breadcrumbs: r,
49
+ IGNORE: n,
50
+ FINISH: i
51
+ } : o.parentPath ? {
52
+ value: e,
53
+ key: t,
54
+ parentPath: a,
55
+ IGNORE: n,
56
+ FINISH: i
57
+ } : {
58
+ value: e,
59
+ key: t,
60
+ IGNORE: n,
61
+ FINISH: i
62
+ };
63
+ }
64
+ //#endregion
65
+ //#region src/pass.js
66
+ var s = /* @__PURE__ */ new WeakSet();
67
+ function c(e) {
68
+ let t = Object.freeze({
69
+ value: e,
70
+ hasValue: arguments.length > 0
71
+ });
72
+ return s.add(t), t;
73
+ }
74
+ function l(e) {
75
+ return s.has(e);
76
+ }
77
+ //#endregion
78
+ //#region src/ignore.js
79
+ var u = Symbol("ignore___");
80
+ function d() {
81
+ return u;
82
+ }
83
+ function f(e) {
84
+ return e === u;
85
+ }
86
+ //#endregion
87
+ //#region node_modules/ask-for-promise/src/askForPromise.js
88
+ function p(e) {
89
+ return e ? h(e) : m();
90
+ }
91
+ p.sequence = function(e, ...t) {
92
+ let n = p(), r = [];
93
+ function* i(e) {
94
+ for (let t of e) yield t;
95
+ }
96
+ let a = i(e);
97
+ function o(e, ...t) {
98
+ e.done ? n.done(r) : Promise.resolve().then(() => e.value(...t)).then((e) => {
99
+ r.push(e), o(a.next(), ...t, e);
100
+ }, (e) => {
101
+ n.cancel(e);
102
+ });
103
+ }
104
+ try {
105
+ o(a.next(), ...t);
106
+ } catch (e) {
107
+ n.cancel(e);
108
+ }
109
+ return n;
110
+ }, p.all = function(e, ...t) {
111
+ let n = p(), r = [], i;
112
+ try {
113
+ i = e.map((e, n) => Promise.resolve().then(() => typeof e == "function" ? e(...t) : e).then((e) => r[n] = e, (e) => {
114
+ throw e;
115
+ }));
116
+ } catch (e) {
117
+ return n.cancel(e), n;
118
+ }
119
+ return Promise.all(i).then(() => n.done(r), (e) => n.cancel(e)), n;
120
+ };
121
+ function m() {
122
+ let e, t, n = new Promise((n, r) => {
123
+ e = n, t = r;
124
+ }), r = {
125
+ promise: n,
126
+ promises: null,
127
+ _activeTimer: null,
128
+ done: () => {},
129
+ cancel: () => {},
130
+ each: () => {},
131
+ onComplete: g(n),
132
+ timeout: _()
133
+ };
134
+ return r.done = function(t) {
135
+ r._activeTimer !== null && (clearTimeout(r._activeTimer), r._activeTimer = null), e(t);
136
+ }, r.cancel = function(e) {
137
+ r._activeTimer !== null && (clearTimeout(r._activeTimer), r._activeTimer = null), t(e);
138
+ }, r.each = function(e, ...t) {
139
+ e({
140
+ value: null,
141
+ done: r.done,
142
+ cancel: r.cancel,
143
+ timeout: (e, t) => this.timeout(e, t)
144
+ }, void 0, ...t);
145
+ }, r;
146
+ }
147
+ function h(e) {
148
+ let t = e.map((e) => m()), n = t.map((e) => e.promise), r = Promise.all(n), i = {
149
+ promise: r,
150
+ promises: t,
151
+ _list: e,
152
+ _activeTimer: null,
153
+ done: () => {},
154
+ cancel: () => {},
155
+ each: () => {},
156
+ onComplete: g(r),
157
+ timeout: _()
158
+ };
159
+ return i.done = function(e) {
160
+ this._activeTimer !== null && (clearTimeout(this._activeTimer), this._activeTimer = null), this.promises.forEach((t) => t.done(e));
161
+ }, i.cancel = function(e) {
162
+ this._activeTimer !== null && (clearTimeout(this._activeTimer), this._activeTimer = null), this.promises.forEach((t) => t.cancel(e));
163
+ }, i.each = function(e, ...t) {
164
+ this.promises.forEach((n, r) => e({
165
+ value: this._list[r],
166
+ done: n.done,
167
+ cancel: n.cancel,
168
+ timeout: (e, t) => n.timeout(e, t)
169
+ }, r, ...t));
170
+ }, i;
171
+ }
172
+ function g(e) {
173
+ return function(t, n = null) {
174
+ n === null ? e.then((e) => t(e)) : e.then((e) => t(e), (e) => n(e));
175
+ };
176
+ }
177
+ function _() {
178
+ return function(e, t) {
179
+ let n = this;
180
+ n._activeTimer !== null && clearTimeout(n._activeTimer);
181
+ let r = setTimeout(() => n.done(t), e);
182
+ n._activeTimer = r;
183
+ let i = () => {
184
+ clearTimeout(r), n._activeTimer === r && (n._activeTimer = null);
185
+ };
186
+ return n.promise.then(i, i), n;
187
+ };
188
+ }
189
+ //#endregion
190
+ //#region src/runTask.js
191
+ function v(e) {
192
+ let t = p();
193
+ function n(r, i) {
194
+ let a;
195
+ try {
196
+ a = e[r](i);
197
+ } catch (e) {
198
+ t.cancel(e);
199
+ return;
200
+ }
201
+ if (a.done) {
202
+ t.done(a.value);
203
+ return;
204
+ }
205
+ let o = p();
206
+ o.done(a.value), o.promise.then((e) => n("next", e), (e) => n("throw", e));
207
+ }
208
+ return n("next"), t.promise;
209
+ }
210
+ //#endregion
211
+ //#region src/runCallback.js
212
+ function y(e, t, n, r, ...o) {
213
+ return v(s());
214
+ function* s() {
215
+ var s;
216
+ let u, f, m = `${r} at '${(s = t.breadcrumbs) == null ? t.key : s}'`;
217
+ function h() {
218
+ u || (u = p(), f = u.done, u.promise.catch(() => {}));
219
+ }
220
+ Object.defineProperties(t, {
221
+ resolve: {
222
+ enumerable: !0,
223
+ get: () => (h(), f)
224
+ },
225
+ reject: {
226
+ enumerable: !0,
227
+ get: () => (h(), () => f(d()))
228
+ }
229
+ }), n.add(m);
230
+ try {
231
+ let n = yield e(t, ...o), s = u ? yield u.promise : n;
232
+ return r === "objectCallback" && l(s) && s.hasValue ? c(yield s.value) : a(s) && s.hasValue ? i(yield s.value) : s;
233
+ } finally {
234
+ n.delete(m);
235
+ }
236
+ }
237
+ }
238
+ //#endregion
239
+ //#region src/copyObject.js
240
+ function b(r, i, s, u, p, m, h, g, _, b, w, T, ...E) {
241
+ return v(D());
242
+ function* D() {
243
+ let [v, D] = u, O = Object.keys(r), k = m.detectCycles ? {
244
+ data: r,
245
+ location: i,
246
+ parent: b,
247
+ depth: b ? b.depth + 1 : 0
248
+ } : void 0, A = !1;
249
+ w && w.set(r, k);
250
+ for (let u = 0; u < O.length && !A; u++) {
251
+ let b = O[u], j = r[b], M = e(j), N = m.copy && t(b, i), P = m.breadcrumbs && (M !== "simple" || !_ && v) ? `${p}/${b}` : void 0, F = !1;
252
+ if (M !== "simple" && D && !h.isFinished) {
253
+ let t = o(j, b, d, P, g, m);
254
+ t.PASS = c;
255
+ let n = yield y(D, t, T, "objectCallback", ...E);
256
+ if (a(n)) {
257
+ if (!n.hasValue || !v) return x(n, i, b, N, m, h), k;
258
+ s.length = 0, h.restart = !0, h.isFinished = !0, A = !0, j = n.value;
259
+ } else if (f(n)) continue;
260
+ else l(n) ? (F = !0, n.hasValue && (j = n.value)) : j = n;
261
+ M = e(j);
262
+ }
263
+ if (M === "simple") {
264
+ if (F || _ && !h.isFinished || !v) {
265
+ if (!m.copy) continue;
266
+ N ? i.push(j) : n(i, b, j);
267
+ continue;
268
+ }
269
+ let t = o(j, b, d, P, g, m);
270
+ t.isFinished = h.isFinished;
271
+ let r = yield y(v, t, T, "keyCallback", ...E);
272
+ if (a(r)) return x(r, i, b, N, m, h), k;
273
+ if (f(r)) continue;
274
+ let s = e(r);
275
+ if (s === "simple") {
276
+ if (!m.copy) continue;
277
+ N ? i.push(r) : n(i, b, r);
278
+ continue;
279
+ }
280
+ j = r, M = s;
281
+ }
282
+ let I = m.detectCycles ? C(j, k, w) : void 0;
283
+ if (I) {
284
+ if (!m.copy) continue;
285
+ N ? i.push(I.location) : n(i, b, I.location);
286
+ } else {
287
+ if (M === "object") {
288
+ let e = m.copy ? {} : void 0;
289
+ m.copy && (N ? i.push(e) : n(i, b, e)), s.push(S(j, e, P, g, b, F, k));
290
+ }
291
+ if (M === "array") {
292
+ let e = m.copy ? [] : void 0;
293
+ m.copy && (N ? i.push(e) : n(i, b, e)), s.push(S(j, e, P, g, b, F, k));
294
+ }
295
+ }
296
+ }
297
+ return k;
298
+ }
299
+ }
300
+ function x(e, t, r, i, a, o) {
301
+ o.finished = !0, a.copy && e.hasValue && (i ? t.push(e.value) : n(t, r, e.value));
302
+ }
303
+ function S(e, t, n, r, i, a, o) {
304
+ return {
305
+ data: e,
306
+ location: t,
307
+ breadcrumbs: n,
308
+ parentPath: r,
309
+ key: i,
310
+ pass: a,
311
+ parent: o
312
+ };
313
+ }
314
+ function C(e, t, n) {
315
+ if (n) return n.get(e);
316
+ for (let n = t; n; n = n.parent) if (n.data === e) return n;
317
+ }
318
+ //#endregion
319
+ //#region src/main.js
320
+ function w(e, ...t) {
321
+ return v(n());
322
+ function* n() {
323
+ let n = /* @__PURE__ */ new Set(), r = T(e, n, ...t);
324
+ if (e.timeout == null) return yield r;
325
+ let i = p(), a = setTimeout(() => {
326
+ let t = [...n].map((e) => `\n - ${e}`).join("");
327
+ i.cancel(/* @__PURE__ */ Error(`walk-async: timed out after ${e.timeout}ms; callbacks still pending:${t}`));
328
+ }, e.timeout);
329
+ r.then(i.done, i.cancel);
330
+ try {
331
+ return yield i.promise;
332
+ } finally {
333
+ clearTimeout(a);
334
+ }
335
+ }
336
+ }
337
+ function T(t, n, ...r) {
338
+ return v(i());
339
+ function* i() {
340
+ let { data: i, keyCallback: s, objectCallback: u, settings: p } = t, m = e(i), h, g = [], _, v, x = !!(s || u), S = {
341
+ copy: (p == null ? void 0 : p.copy) !== !1,
342
+ breadcrumbs: x && (p == null ? void 0 : p.breadcrumbs) !== !1,
343
+ parentPath: x && (p == null ? void 0 : p.parentPath) !== !1,
344
+ detectCycles: (p == null ? void 0 : p.detectCycles) !== !1
345
+ }, C = S.breadcrumbs ? "root" : void 0, w = S.parentPath && m !== "simple" ? Object.freeze(["root"]) : void 0, T = !1, D = {
346
+ finished: !1,
347
+ isFinished: !1,
348
+ restart: !1
349
+ }, O = [s, u];
350
+ if (m !== "simple" && u) {
351
+ let t = S.parentPath ? Object.freeze([]) : void 0, p = o(i, "root", d, C, t, S);
352
+ p.PASS = c;
353
+ let h = yield y(u, p, n, "objectCallback", ...r);
354
+ if (a(h)) {
355
+ if (!h.hasValue) return S.copy ? m === "array" ? [] : {} : void 0;
356
+ if (!s) return S.copy ? h.value : void 0;
357
+ D.isFinished = !0, i = h.value;
358
+ } else if (f(h)) return S.copy ? m === "array" ? [] : {} : void 0;
359
+ else l(h) ? (T = !0, h.hasValue && (i = h.value)) : i = h;
360
+ m = e(i);
361
+ }
362
+ switch (m) {
363
+ case "array":
364
+ h = S.copy ? [] : void 0, v = yield b(i, h, g, O, C, S, D, w, T, void 0, _, n, ...r);
365
+ break;
366
+ case "object":
367
+ h = S.copy ? {} : void 0, v = yield b(i, h, g, O, C, S, D, w, T, void 0, _, n, ...r);
368
+ break;
369
+ case "simple": return S.copy ? i : void 0;
370
+ }
371
+ for (let e = 0; e < g.length && !D.finished;) {
372
+ let t = g[e];
373
+ g[e] = void 0, D.restart = !1, S.detectCycles && (_ = E(v, t.parent, _));
374
+ let i = S.parentPath ? Object.freeze([...t.parentPath, t.key]) : void 0;
375
+ v = yield b(t.data, t.location, g, O, t.breadcrumbs, S, D, i, t.pass, t.parent, _, n, ...r), e = D.restart ? 0 : e + 1;
376
+ }
377
+ return h;
378
+ }
379
+ }
380
+ function E(e, t, n) {
381
+ if (!n) {
382
+ if (t.depth < 32) return;
383
+ n = /* @__PURE__ */ new WeakMap();
384
+ for (let e = t; e; e = e.parent) n.set(e.data, e);
385
+ return n;
386
+ }
387
+ let r = [];
388
+ for (; e !== t;) e.depth >= t.depth ? (n.delete(e.data), e = e.parent) : (r.push(t), t = t.parent);
389
+ for (let e = r.length - 1; e >= 0; e--) {
390
+ let t = r[e];
391
+ n.set(t.data, t);
392
+ }
393
+ return n;
394
+ }
395
+ //#endregion
396
+ export { w as default };
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).walkAsync=t()}(this,function(){"use strict";function e(e){return null==e||e.nodeType?"simple":Array.isArray(e)?"array":"object"==typeof e?e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)?"simple":"object":"simple"}function t(e,t){if(!Array.isArray(t))return!1;const n=Number(e);return Number.isInteger(n)&&n>=0&&n<4294967295&&String(n)===e}function n(e,t,n){"__proto__"===t?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}const a=new WeakSet;function r(e){const t=Object.freeze({value:e,hasValue:arguments.length>0});return a.add(t),t}function i(e){return a.has(e)}function o(e,t,n,a,i,o){return o.breadcrumbs&&o.parentPath?{value:e,key:t,breadcrumbs:a,parentPath:i,IGNORE:n,FINISH:r}:o.breadcrumbs?{value:e,key:t,breadcrumbs:a,IGNORE:n,FINISH:r}:o.parentPath?{value:e,key:t,parentPath:i,IGNORE:n,FINISH:r}:{value:e,key:t,IGNORE:n,FINISH:r}}const c=new WeakSet;function s(e){const t=Object.freeze({value:e,hasValue:arguments.length>0});return c.add(t),t}function u(e){return c.has(e)}const l=Symbol("ignore___");function f(){return l}function p(e){return e===l}async function d(e,t,n,a,...o){let c,l,p=`${a} at '${t.breadcrumbs??t.key}'`;function d(){c||(c=new Promise(e=>{l=e}),c.catch(()=>{}))}Object.defineProperties(t,{resolve:{enumerable:!0,get:()=>(d(),l)},reject:{enumerable:!0,get:()=>(d(),()=>l(f()))}}),n.add(p);try{const n=await e(t,...o),l=c?await c:n;return"objectCallback"===a&&u(l)&&l.hasValue?s(await l.value):i(l)&&l.hasValue?r(await l.value):l}finally{n.delete(p)}}async function y(a,r,c,l,y,v,k,w,j,g,P,S,...I){let[O,C]=l,F=Object.keys(a),V=v.detectCycles?{data:a,location:r,parent:g,depth:g?g.depth+1:0}:void 0,N=!1;P&&P.set(a,V);for(let l=0;l<F.length&&!N;l++){const g=F[l];let A=a[g],$=e(A),_=v.copy&&t(g,r),E=v.breadcrumbs&&("simple"!==$||!j&&O)?`${y}/${g}`:void 0,z=!1;if("simple"!==$&&C&&!k.isFinished){const t=o(A,g,f,E,w,v);t.PASS=s;const n=await d(C,t,S,"objectCallback",...I);if(i(n)){if(!n.hasValue||!O)return b(n,r,g,_,v,k),V;c.length=0,k.restart=!0,k.isFinished=!0,N=!0,A=n.value}else{if(p(n))continue;u(n)?(z=!0,n.hasValue&&(A=n.value)):A=n}$=e(A)}if("simple"===$){if(z||j&&!k.isFinished||!O){if(!v.copy)continue;_?r.push(A):n(r,g,A);continue}const t=o(A,g,f,E,w,v);t.isFinished=k.isFinished;let a=await d(O,t,S,"keyCallback",...I);if(i(a))return b(a,r,g,_,v,k),V;if(p(a))continue;const c=e(a);if("simple"===c){if(!v.copy)continue;_?r.push(a):n(r,g,a);continue}A=a,$=c}const R=v.detectCycles?m(A,V,P):void 0;if(R){if(!v.copy)continue;_?r.push(R.location):n(r,g,R.location)}else{if("object"===$){const e=v.copy?{}:void 0;v.copy&&(_?r.push(e):n(r,g,e)),c.push(h(A,e,E,w,g,z,V))}if("array"===$){const e=v.copy?[]:void 0;v.copy&&(_?r.push(e):n(r,g,e)),c.push(h(A,e,E,w,g,z,V))}}}return V}function b(e,t,a,r,i,o){o.finished=!0,i.copy&&e.hasValue&&(r?t.push(e.value):n(t,a,e.value))}function h(e,t,n,a,r,i,o){return{data:e,location:t,breadcrumbs:n,parentPath:a,key:r,pass:i,parent:o}}function m(e,t,n){if(n)return n.get(e);for(let n=t;n;n=n.parent)if(n.data===e)return n}function v(e,t,n){if(!n){if(t.depth<32)return;n=new WeakMap;for(let e=t;e;e=e.parent)n.set(e.data,e);return n}const a=[];for(;e!==t;)e.depth>=t.depth?(n.delete(e.data),e=e.parent):(a.push(t),t=t.parent);for(let e=a.length-1;e>=0;e--){const t=a[e];n.set(t.data,t)}return n}return async function(t,...n){const a=new Set,r=async function(t,n,...a){let r,c,l,{data:b,keyCallback:h,objectCallback:m,settings:k}=t,w=e(b),j=[],g=!(!h&&!m),P={copy:!1!==k?.copy,breadcrumbs:g&&!1!==k?.breadcrumbs,parentPath:g&&!1!==k?.parentPath,detectCycles:!1!==k?.detectCycles},S=P.breadcrumbs?"root":void 0,I=P.parentPath&&"simple"!==w?Object.freeze(["root"]):void 0,O=!1,C={finished:!1,isFinished:!1,restart:!1},F=[h,m];if("simple"!==w&&m){const t=o(b,"root",f,S,P.parentPath?Object.freeze([]):void 0,P);t.PASS=s;const r=await d(m,t,n,"objectCallback",...a);if(i(r)){if(!r.hasValue){if(!P.copy)return;return"array"===w?[]:{}}if(!h)return P.copy?r.value:void 0;C.isFinished=!0,b=r.value}else{if(p(r)){if(!P.copy)return;return"array"===w?[]:{}}u(r)?(O=!0,r.hasValue&&(b=r.value)):b=r}w=e(b)}switch(w){case"array":r=P.copy?[]:void 0,l=await y(b,r,j,F,S,P,C,I,O,void 0,c,n,...a);break;case"object":r=P.copy?{}:void 0,l=await y(b,r,j,F,S,P,C,I,O,void 0,c,n,...a);break;case"simple":return P.copy?b:void 0}for(let e=0;e<j.length&&!C.finished;){const t=j[e];j[e]=void 0,C.restart=!1,P.detectCycles&&(c=v(l,t.parent,c));const r=P.parentPath?Object.freeze([...t.parentPath,t.key]):void 0;l=await y(t.data,t.location,j,F,t.breadcrumbs,P,C,r,t.pass,t.parent,c,n,...a),e=C.restart?0:e+1}return r}(t,a,...n);if(null==t.timeout)return r;let c;const l=new Promise((e,n)=>{c=setTimeout(()=>{const e=[...a].map(e=>`\n - ${e}`).join("");n(new Error(`walk-async: timed out after ${t.timeout}ms; callbacks still pending:${e}`))},t.timeout)});try{return await Promise.race([r,l])}finally{clearTimeout(c)}}});
1
+ "use strict";(function(e,t){typeof exports==`object`&&typeof module<`u`?module.exports=t():typeof define==`function`&&define.amd?define([],t):(e=typeof globalThis<`u`?globalThis:e||self,e.walkAsync=t())})(this,function(){function e(e){return e==null||e.nodeType?`simple`:Array.isArray(e)?`array`:typeof e==`object`?e instanceof Date||e instanceof RegExp||e instanceof Map||e instanceof Set||e instanceof WeakMap||e instanceof WeakSet||e instanceof ArrayBuffer||e instanceof DataView||ArrayBuffer.isView(e)?`simple`:`object`:`simple`}function t(e,t){if(!Array.isArray(t))return!1;let n=Number(e);return Number.isInteger(n)&&n>=0&&n<4294967295&&String(n)===e}function n(e,t,n){t===`__proto__`?Object.defineProperty(e,t,{value:n,enumerable:!0,writable:!0,configurable:!0}):e[t]=n}var r=new WeakSet;function i(e){let t=Object.freeze({value:e,hasValue:arguments.length>0});return r.add(t),t}function a(e){return r.has(e)}function o(e,t,n,r,a,o){return o.breadcrumbs&&o.parentPath?{value:e,key:t,breadcrumbs:r,parentPath:a,IGNORE:n,FINISH:i}:o.breadcrumbs?{value:e,key:t,breadcrumbs:r,IGNORE:n,FINISH:i}:o.parentPath?{value:e,key:t,parentPath:a,IGNORE:n,FINISH:i}:{value:e,key:t,IGNORE:n,FINISH:i}}var s=new WeakSet;function c(e){let t=Object.freeze({value:e,hasValue:arguments.length>0});return s.add(t),t}function l(e){return s.has(e)}var u=Symbol(`ignore___`);function d(){return u}function f(e){return e===u}function p(e){return e?h(e):m()}p.sequence=function(e,...t){let n=p(),r=[];function*i(e){for(let t of e)yield t}let a=i(e);function o(e,...t){e.done?n.done(r):Promise.resolve().then(()=>e.value(...t)).then(e=>{r.push(e),o(a.next(),...t,e)},e=>{n.cancel(e)})}try{o(a.next(),...t)}catch(e){n.cancel(e)}return n},p.all=function(e,...t){let n=p(),r=[],i;try{i=e.map((e,n)=>Promise.resolve().then(()=>typeof e==`function`?e(...t):e).then(e=>r[n]=e,e=>{throw e}))}catch(e){return n.cancel(e),n}return Promise.all(i).then(()=>n.done(r),e=>n.cancel(e)),n};function m(){let e,t,n=new Promise((n,r)=>{e=n,t=r}),r={promise:n,promises:null,_activeTimer:null,done:()=>{},cancel:()=>{},each:()=>{},onComplete:g(n),timeout:_()};return r.done=function(t){r._activeTimer!==null&&(clearTimeout(r._activeTimer),r._activeTimer=null),e(t)},r.cancel=function(e){r._activeTimer!==null&&(clearTimeout(r._activeTimer),r._activeTimer=null),t(e)},r.each=function(e,...t){e({value:null,done:r.done,cancel:r.cancel,timeout:(e,t)=>this.timeout(e,t)},void 0,...t)},r}function h(e){let t=e.map(e=>m()),n=t.map(e=>e.promise),r=Promise.all(n),i={promise:r,promises:t,_list:e,_activeTimer:null,done:()=>{},cancel:()=>{},each:()=>{},onComplete:g(r),timeout:_()};return i.done=function(e){this._activeTimer!==null&&(clearTimeout(this._activeTimer),this._activeTimer=null),this.promises.forEach(t=>t.done(e))},i.cancel=function(e){this._activeTimer!==null&&(clearTimeout(this._activeTimer),this._activeTimer=null),this.promises.forEach(t=>t.cancel(e))},i.each=function(e,...t){this.promises.forEach((n,r)=>e({value:this._list[r],done:n.done,cancel:n.cancel,timeout:(e,t)=>n.timeout(e,t)},r,...t))},i}function g(e){return function(t,n=null){n===null?e.then(e=>t(e)):e.then(e=>t(e),e=>n(e))}}function _(){return function(e,t){let n=this;n._activeTimer!==null&&clearTimeout(n._activeTimer);let r=setTimeout(()=>n.done(t),e);n._activeTimer=r;let i=()=>{clearTimeout(r),n._activeTimer===r&&(n._activeTimer=null)};return n.promise.then(i,i),n}}function v(e){let t=p();function n(r,i){let a;try{a=e[r](i)}catch(e){t.cancel(e);return}if(a.done){t.done(a.value);return}let o=p();o.done(a.value),o.promise.then(e=>n(`next`,e),e=>n(`throw`,e))}return n(`next`),t.promise}function y(e,t,n,r,...o){return v(s());function*s(){var s;let u,f,m=`${r} at '${(s=t.breadcrumbs)==null?t.key:s}'`;function h(){u||(u=p(),f=u.done,u.promise.catch(()=>{}))}Object.defineProperties(t,{resolve:{enumerable:!0,get:()=>(h(),f)},reject:{enumerable:!0,get:()=>(h(),()=>f(d()))}}),n.add(m);try{let n=yield e(t,...o),s=u?yield u.promise:n;return r===`objectCallback`&&l(s)&&s.hasValue?c(yield s.value):a(s)&&s.hasValue?i(yield s.value):s}finally{n.delete(m)}}}function b(r,i,s,u,p,m,h,g,_,b,w,T,...E){return v(D());function*D(){let[v,D]=u,O=Object.keys(r),k=m.detectCycles?{data:r,location:i,parent:b,depth:b?b.depth+1:0}:void 0,A=!1;w&&w.set(r,k);for(let u=0;u<O.length&&!A;u++){let b=O[u],j=r[b],M=e(j),N=m.copy&&t(b,i),P=m.breadcrumbs&&(M!==`simple`||!_&&v)?`${p}/${b}`:void 0,F=!1;if(M!==`simple`&&D&&!h.isFinished){let t=o(j,b,d,P,g,m);t.PASS=c;let n=yield y(D,t,T,`objectCallback`,...E);if(a(n)){if(!n.hasValue||!v)return x(n,i,b,N,m,h),k;s.length=0,h.restart=!0,h.isFinished=!0,A=!0,j=n.value}else if(f(n))continue;else l(n)?(F=!0,n.hasValue&&(j=n.value)):j=n;M=e(j)}if(M===`simple`){if(F||_&&!h.isFinished||!v){if(!m.copy)continue;N?i.push(j):n(i,b,j);continue}let t=o(j,b,d,P,g,m);t.isFinished=h.isFinished;let r=yield y(v,t,T,`keyCallback`,...E);if(a(r))return x(r,i,b,N,m,h),k;if(f(r))continue;let s=e(r);if(s===`simple`){if(!m.copy)continue;N?i.push(r):n(i,b,r);continue}j=r,M=s}let I=m.detectCycles?C(j,k,w):void 0;if(I){if(!m.copy)continue;N?i.push(I.location):n(i,b,I.location)}else{if(M===`object`){let e=m.copy?{}:void 0;m.copy&&(N?i.push(e):n(i,b,e)),s.push(S(j,e,P,g,b,F,k))}if(M===`array`){let e=m.copy?[]:void 0;m.copy&&(N?i.push(e):n(i,b,e)),s.push(S(j,e,P,g,b,F,k))}}}return k}}function x(e,t,r,i,a,o){o.finished=!0,a.copy&&e.hasValue&&(i?t.push(e.value):n(t,r,e.value))}function S(e,t,n,r,i,a,o){return{data:e,location:t,breadcrumbs:n,parentPath:r,key:i,pass:a,parent:o}}function C(e,t,n){if(n)return n.get(e);for(let n=t;n;n=n.parent)if(n.data===e)return n}function w(e,...t){return v(n());function*n(){let n=new Set,r=T(e,n,...t);if(e.timeout==null)return yield r;let i=p(),a=setTimeout(()=>{let t=[...n].map(e=>`\n - ${e}`).join(``);i.cancel(Error(`walk-async: timed out after ${e.timeout}ms; callbacks still pending:${t}`))},e.timeout);r.then(i.done,i.cancel);try{return yield i.promise}finally{clearTimeout(a)}}}function T(t,n,...r){return v(i());function*i(){let{data:i,keyCallback:s,objectCallback:u,settings:p}=t,m=e(i),h,g=[],_,v,x=!!(s||u),S={copy:(p==null?void 0:p.copy)!==!1,breadcrumbs:x&&(p==null?void 0:p.breadcrumbs)!==!1,parentPath:x&&(p==null?void 0:p.parentPath)!==!1,detectCycles:(p==null?void 0:p.detectCycles)!==!1},C=S.breadcrumbs?`root`:void 0,w=S.parentPath&&m!==`simple`?Object.freeze([`root`]):void 0,T=!1,D={finished:!1,isFinished:!1,restart:!1},O=[s,u];if(m!==`simple`&&u){let t=S.parentPath?Object.freeze([]):void 0,p=o(i,`root`,d,C,t,S);p.PASS=c;let h=yield y(u,p,n,`objectCallback`,...r);if(a(h)){if(!h.hasValue)return S.copy?m===`array`?[]:{}:void 0;if(!s)return S.copy?h.value:void 0;D.isFinished=!0,i=h.value}else if(f(h))return S.copy?m===`array`?[]:{}:void 0;else l(h)?(T=!0,h.hasValue&&(i=h.value)):i=h;m=e(i)}switch(m){case`array`:h=S.copy?[]:void 0,v=yield b(i,h,g,O,C,S,D,w,T,void 0,_,n,...r);break;case`object`:h=S.copy?{}:void 0,v=yield b(i,h,g,O,C,S,D,w,T,void 0,_,n,...r);break;case`simple`:return S.copy?i:void 0}for(let e=0;e<g.length&&!D.finished;){let t=g[e];g[e]=void 0,D.restart=!1,S.detectCycles&&(_=E(v,t.parent,_));let i=S.parentPath?Object.freeze([...t.parentPath,t.key]):void 0;v=yield b(t.data,t.location,g,O,t.breadcrumbs,S,D,i,t.pass,t.parent,_,n,...r),e=D.restart?0:e+1}return h}}function E(e,t,n){if(!n){if(t.depth<32)return;n=new WeakMap;for(let e=t;e;e=e.parent)n.set(e.data,e);return n}let r=[];for(;e!==t;)e.depth>=t.depth?(n.delete(e.data),e=e.parent):(r.push(t),t=t.parent);for(let e=r.length-1;e>=0;e--){let t=r[e];n.set(t.data,t)}return n}return w});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@peter.naydenov/walk-async",
3
- "version": "7.0.1",
3
+ "version": "7.0.2",
4
4
  "description": "Deep copy with fine control during the process. Can be used also as a deep forEach function",
5
5
  "main": "./dist/walk-async.umd.js",
6
6
  "type": "module",
@@ -24,13 +24,13 @@
24
24
  "Changelog.md",
25
25
  "Migration.guide.md",
26
26
  "LICENSE",
27
- ".agents/skills"
27
+ "skills"
28
28
  ],
29
29
  "scripts": {
30
30
  "test": "vitest run",
31
31
  "test:watch": "vitest",
32
32
  "cover": "vitest run --coverage",
33
- "build": "rollup -c",
33
+ "build": "vite build",
34
34
  "postbuild": "tsc -p tsconfig.json"
35
35
  },
36
36
  "repository": {
@@ -40,16 +40,12 @@
40
40
  "author": "Peter Naydenov",
41
41
  "license": "MIT",
42
42
  "dependencies": {
43
- "ask-for-promise": "^3.2.1"
43
+ "ask-for-promise": "^3.2.2"
44
44
  },
45
45
  "devDependencies": {
46
- "@rollup/plugin-commonjs": "^29.0.3",
47
- "@rollup/plugin-node-resolve": "^16.0.3",
48
- "@rollup/plugin-terser": "^1.0.0",
49
46
  "@vitest/coverage-v8": "5.0.5",
50
- "rollup": "^4.64.0",
51
47
  "typescript": "^7.0.2",
52
- "vite": "^8.3.4",
48
+ "vite": "^8.3.5",
53
49
  "vitest": "5.0.5"
54
50
  },
55
51
  "vitest": {