ast-monkey-traverse 3.0.7 → 3.0.10

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/README.md CHANGED
@@ -38,6 +38,7 @@ If you need a legacy version which works with `require`, use version 2.1.0
38
38
 
39
39
  ```js
40
40
  import { strict as assert } from "assert";
41
+
41
42
  import { traverse } from "ast-monkey-traverse";
42
43
 
43
44
  const paths = [];
@@ -61,7 +62,7 @@ const source = {
61
62
  traverse(source, (key, val, innerObj) => {
62
63
  // if currently an object is traversed, you get both "key" and "val"
63
64
  // if it's array, only "key" is present, "val" is undefined
64
- const current = val !== undefined ? val : key;
65
+ let current = val !== undefined ? val : key;
65
66
  if (
66
67
  // it's object (not array)
67
68
  val !== undefined &&
@@ -80,7 +81,7 @@ assert.deepEqual(paths, ["a.foo", "a.foo.bar.0.foo", "a.foo.d.e.foo"]);
80
81
 
81
82
  ## Documentation
82
83
 
83
- Please [visit codsen.com](https://codsen.com/os/ast-monkey-traverse/) for a full description of the API and examples.
84
+ Please [visit codsen.com](https://codsen.com/os/ast-monkey-traverse/) for a full description of the API.
84
85
 
85
86
  ## Contributing
86
87
 
@@ -92,4 +93,6 @@ MIT License
92
93
 
93
94
  Copyright (c) 2010-2021 Roy Revelt and other contributors
94
95
 
96
+
95
97
  <img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
98
+
@@ -1,74 +1,10 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse
3
3
  * @fileoverview Utility library to traverse AST
4
- * @version 3.0.7
4
+ * @version 3.0.10
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse/}
8
8
  */
9
9
 
10
- import clone from 'lodash.clonedeep';
11
- import isObj from 'lodash.isplainobject';
12
- import { parent } from 'ast-monkey-util';
13
-
14
- var version$1 = "3.0.7";
15
-
16
- const version = version$1;
17
- function traverse(tree1, cb1) {
18
- const stop2 = { now: false };
19
- function traverseInner(treeOriginal, callback, originalInnerObj, stop) {
20
- const tree = clone(treeOriginal);
21
- let res;
22
- const innerObj = { depth: -1, path: "", ...originalInnerObj };
23
- innerObj.depth += 1;
24
- if (Array.isArray(tree)) {
25
- for (let i = 0, len = tree.length; i < len; i++) {
26
- if (stop.now) {
27
- break;
28
- }
29
- const path = innerObj.path ? `${innerObj.path}.${i}` : `${i}`;
30
- if (tree[i] !== undefined) {
31
- innerObj.parent = clone(tree);
32
- innerObj.parentType = "array";
33
- innerObj.parentKey = parent(path);
34
- res = traverseInner(callback(tree[i], undefined, { ...innerObj, path }, stop), callback, { ...innerObj, path }, stop);
35
- if (Number.isNaN(res) && i < tree.length) {
36
- tree.splice(i, 1);
37
- i -= 1;
38
- }
39
- else {
40
- tree[i] = res;
41
- }
42
- }
43
- else {
44
- tree.splice(i, 1);
45
- }
46
- }
47
- }
48
- else if (isObj(tree)) {
49
- for (const key in tree) {
50
- if (stop.now && key != null) {
51
- break;
52
- }
53
- const path = innerObj.path ? `${innerObj.path}.${key}` : key;
54
- if (innerObj.depth === 0 && key != null) {
55
- innerObj.topmostKey = key;
56
- }
57
- innerObj.parent = clone(tree);
58
- innerObj.parentType = "object";
59
- innerObj.parentKey = parent(path);
60
- res = traverseInner(callback(key, tree[key], { ...innerObj, path }, stop), callback, { ...innerObj, path }, stop);
61
- if (Number.isNaN(res)) {
62
- delete tree[key];
63
- }
64
- else {
65
- tree[key] = res;
66
- }
67
- }
68
- }
69
- return tree;
70
- }
71
- return traverseInner(tree1, cb1, {}, stop2);
72
- }
73
-
74
- export { traverse, version };
10
+ import p from"lodash.clonedeep";import g from"lodash.isplainobject";import{parent as m}from"ast-monkey-util";var u="3.0.10";var k=u;function D(y,c){let $={now:!1};function a(b,l,d,r){let n=p(b),s,t={depth:-1,path:"",...d};if(t.depth+=1,Array.isArray(n))for(let e=0,o=n.length;e<o&&!r.now;e++){let i=t.path?`${t.path}.${e}`:`${e}`;n[e]!==void 0?(t.parent=p(n),t.parentType="array",t.parentKey=m(i),s=a(l(n[e],void 0,{...t,path:i},r),l,{...t,path:i},r),Number.isNaN(s)&&e<n.length?(n.splice(e,1),e-=1):n[e]=s):n.splice(e,1)}else if(g(n))for(let e in n){if(r.now&&e!=null)break;let o=t.path?`${t.path}.${e}`:e;t.depth===0&&e!=null&&(t.topmostKey=e),t.parent=p(n),t.parentType="object",t.parentKey=m(o),s=a(l(e,n[e],{...t,path:o},r),l,{...t,path:o},r),Number.isNaN(s)?delete n[e]:n[e]=s}return n}return a(y,c,{},$)}export{D as traverse,k as version};
@@ -1,18 +1,18 @@
1
1
  /**
2
2
  * @name ast-monkey-traverse
3
3
  * @fileoverview Utility library to traverse AST
4
- * @version 3.0.7
4
+ * @version 3.0.10
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-monkey-traverse/}
8
8
  */
9
9
 
10
- !function(t,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((t="undefined"!=typeof globalThis?globalThis:t||self).astMonkeyTraverse={})}(this,(function(t){"use strict";var e="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{},r={exports:{}};!function(t,r){var n="__lodash_hash_undefined__",o=9007199254740991,c="[object Arguments]",u="[object Boolean]",a="[object Date]",i="[object Function]",f="[object GeneratorFunction]",s="[object Map]",l="[object Number]",p="[object Object]",y="[object Promise]",h="[object RegExp]",_="[object Set]",v="[object String]",d="[object Symbol]",b="[object WeakMap]",j="[object ArrayBuffer]",g="[object DataView]",w="[object Float32Array]",O="[object Float64Array]",A="[object Int8Array]",m="[object Int16Array]",x="[object Int32Array]",S="[object Uint8Array]",$="[object Uint8ClampedArray]",P="[object Uint16Array]",T="[object Uint32Array]",I=/\w*$/,k=/^\[object .+?Constructor\]$/,E=/^(?:0|[1-9]\d*)$/,F={};F[c]=F["[object Array]"]=F[j]=F[g]=F[u]=F[a]=F[w]=F[O]=F[A]=F[m]=F[x]=F[s]=F[l]=F[p]=F[h]=F[_]=F[v]=F[d]=F[S]=F[$]=F[P]=F[T]=!0,F["[object Error]"]=F[i]=F[b]=!1;var N="object"==typeof self&&self&&self.Object===Object&&self,M="object"==typeof e&&e&&e.Object===Object&&e||N||Function("return this")(),B=r&&!r.nodeType&&r,U=B&&t&&!t.nodeType&&t,D=U&&U.exports===B;function K(t,e){return t.set(e[0],e[1]),t}function R(t,e){return t.add(e),t}function z(t,e,r,n){var o=-1,c=t?t.length:0;for(n&&c&&(r=t[++o]);++o<c;)r=e(r,t[o],o,t);return r}function C(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function L(t){var e=-1,r=Array(t.size);return t.forEach((function(t,n){r[++e]=[n,t]})),r}function V(t,e){return function(r){return t(e(r))}}function W(t){var e=-1,r=Array(t.size);return t.forEach((function(t){r[++e]=t})),r}var G,q=Array.prototype,H=Function.prototype,J=Object.prototype,Q=M["__core-js_shared__"],X=(G=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+G:"",Y=H.toString,Z=J.hasOwnProperty,tt=J.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=D?M.Buffer:void 0,nt=M.Symbol,ot=M.Uint8Array,ct=V(Object.getPrototypeOf,Object),ut=Object.create,at=J.propertyIsEnumerable,it=q.splice,ft=Object.getOwnPropertySymbols,st=rt?rt.isBuffer:void 0,lt=V(Object.keys,Object),pt=Ut(M,"DataView"),yt=Ut(M,"Map"),ht=Ut(M,"Promise"),_t=Ut(M,"Set"),vt=Ut(M,"WeakMap"),dt=Ut(Object,"create"),bt=Ct(pt),jt=Ct(yt),gt=Ct(ht),wt=Ct(_t),Ot=Ct(vt),At=nt?nt.prototype:void 0,mt=At?At.valueOf:void 0;function xt(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function St(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function $t(t){var e=-1,r=t?t.length:0;for(this.clear();++e<r;){var n=t[e];this.set(n[0],n[1])}}function Pt(t){this.__data__=new St(t)}function Tt(t,e){var r=Vt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Wt(t)}(t)&&Z.call(t,"callee")&&(!at.call(t,"callee")||tt.call(t)==c)}(t)?function(t,e){for(var r=-1,n=Array(t);++r<t;)n[r]=e(r);return n}(t.length,String):[],n=r.length,o=!!n;for(var u in t)!e&&!Z.call(t,u)||o&&("length"==u||Rt(u,n))||r.push(u);return r}function It(t,e,r){var n=t[e];Z.call(t,e)&&Lt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function kt(t,e){for(var r=t.length;r--;)if(Lt(t[r][0],e))return r;return-1}function Et(t,e,r,n,o,y,b){var k;if(n&&(k=y?n(t,o,y,b):n(t)),void 0!==k)return k;if(!Ht(t))return t;var E=Vt(t);if(E){if(k=function(t){var e=t.length,r=t.constructor(e);e&&"string"==typeof t[0]&&Z.call(t,"index")&&(r.index=t.index,r.input=t.input);return r}(t),!e)return function(t,e){var r=-1,n=t.length;e||(e=Array(n));for(;++r<n;)e[r]=t[r];return e}(t,k)}else{var N=Kt(t),M=N==i||N==f;if(Gt(t))return function(t,e){if(e)return t.slice();var r=new t.constructor(t.length);return t.copy(r),r}(t,e);if(N==p||N==c||M&&!y){if(C(t))return y?t:{};if(k=function(t){return"function"!=typeof t.constructor||zt(t)?{}:(e=ct(t),Ht(e)?ut(e):{});var e}(M?{}:t),!e)return function(t,e){return Mt(t,Dt(t),e)}(t,function(t,e){return t&&Mt(e,Jt(e),t)}(k,t))}else{if(!F[N])return y?t:{};k=function(t,e,r,n){var o=t.constructor;switch(e){case j:return Nt(t);case u:case a:return new o(+t);case g:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case w:case O:case A:case m:case x:case S:case $:case P:case T:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case s:return function(t,e,r){return z(e?r(L(t),!0):L(t),K,new t.constructor)}(t,n,r);case l:case v:return new o(t);case h:return function(t){var e=new t.constructor(t.source,I.exec(t));return e.lastIndex=t.lastIndex,e}(t);case _:return function(t,e,r){return z(e?r(W(t),!0):W(t),R,new t.constructor)}(t,n,r);case d:return c=t,mt?Object(mt.call(c)):{}}var c}(t,N,Et,e)}}b||(b=new Pt);var B=b.get(t);if(B)return B;if(b.set(t,k),!E)var U=r?function(t){return function(t,e,r){var n=e(t);return Vt(t)?n:function(t,e){for(var r=-1,n=e.length,o=t.length;++r<n;)t[o+r]=e[r];return t}(n,r(t))}(t,Jt,Dt)}(t):Jt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(U||t,(function(o,c){U&&(o=t[c=o]),It(k,c,Et(o,e,r,n,c,t,b))})),k}function Ft(t){return!(!Ht(t)||(e=t,X&&X in e))&&(qt(t)||C(t)?et:k).test(Ct(t));var e}function Nt(t){var e=new t.constructor(t.byteLength);return new ot(e).set(new ot(t)),e}function Mt(t,e,r,n){r||(r={});for(var o=-1,c=e.length;++o<c;){var u=e[o],a=n?n(r[u],t[u],u,r,t):void 0;It(r,u,void 0===a?t[u]:a)}return r}function Bt(t,e){var r,n,o=t.__data__;return("string"==(n=typeof(r=e))||"number"==n||"symbol"==n||"boolean"==n?"__proto__"!==r:null===r)?o["string"==typeof e?"string":"hash"]:o.map}function Ut(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Ft(r)?r:void 0}xt.prototype.clear=function(){this.__data__=dt?dt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(dt){var r=e[t];return r===n?void 0:r}return Z.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return dt?void 0!==e[t]:Z.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=dt&&void 0===e?n:e,this},St.prototype.clear=function(){this.__data__=[]},St.prototype.delete=function(t){var e=this.__data__,r=kt(e,t);return!(r<0)&&(r==e.length-1?e.pop():it.call(e,r,1),!0)},St.prototype.get=function(t){var e=this.__data__,r=kt(e,t);return r<0?void 0:e[r][1]},St.prototype.has=function(t){return kt(this.__data__,t)>-1},St.prototype.set=function(t,e){var r=this.__data__,n=kt(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},$t.prototype.clear=function(){this.__data__={hash:new xt,map:new(yt||St),string:new xt}},$t.prototype.delete=function(t){return Bt(this,t).delete(t)},$t.prototype.get=function(t){return Bt(this,t).get(t)},$t.prototype.has=function(t){return Bt(this,t).has(t)},$t.prototype.set=function(t,e){return Bt(this,t).set(t,e),this},Pt.prototype.clear=function(){this.__data__=new St},Pt.prototype.delete=function(t){return this.__data__.delete(t)},Pt.prototype.get=function(t){return this.__data__.get(t)},Pt.prototype.has=function(t){return this.__data__.has(t)},Pt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof St){var n=r.__data__;if(!yt||n.length<199)return n.push([t,e]),this;r=this.__data__=new $t(n)}return r.set(t,e),this};var Dt=ft?V(ft,Object):function(){return[]},Kt=function(t){return tt.call(t)};function Rt(t,e){return!!(e=null==e?o:e)&&("number"==typeof t||E.test(t))&&t>-1&&t%1==0&&t<e}function zt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||J)}function Ct(t){if(null!=t){try{return Y.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function Lt(t,e){return t===e||t!=t&&e!=e}(pt&&Kt(new pt(new ArrayBuffer(1)))!=g||yt&&Kt(new yt)!=s||ht&&Kt(ht.resolve())!=y||_t&&Kt(new _t)!=_||vt&&Kt(new vt)!=b)&&(Kt=function(t){var e=tt.call(t),r=e==p?t.constructor:void 0,n=r?Ct(r):void 0;if(n)switch(n){case bt:return g;case jt:return s;case gt:return y;case wt:return _;case Ot:return b}return e});var Vt=Array.isArray;function Wt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=o}(t.length)&&!qt(t)}var Gt=st||function(){return!1};function qt(t){var e=Ht(t)?tt.call(t):"";return e==i||e==f}function Ht(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return Wt(t)?Tt(t):function(t){if(!zt(t))return lt(t);var e=[];for(var r in Object(t))Z.call(t,r)&&"constructor"!=r&&e.push(r);return e}(t)}t.exports=function(t){return Et(t,!0,!0)}}(r,r.exports);var n=r.exports;var o,c,u=Object.prototype,a=Function.prototype.toString,i=u.hasOwnProperty,f=a.call(Object),s=u.toString,l=(o=Object.getPrototypeOf,c=Object,function(t){return o(c(t))});var p=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||"[object Object]"!=s.call(t)||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=l(t);if(null===e)return!0;var r=i.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&a.call(r)==f};
10
+ var astMonkeyTraverse=(()=>{var re=Object.create;var x=Object.defineProperty,oe=Object.defineProperties,ae=Object.getOwnPropertyDescriptor,ie=Object.getOwnPropertyDescriptors,se=Object.getOwnPropertyNames,nt=Object.getOwnPropertySymbols,ce=Object.getPrototypeOf,rt=Object.prototype.hasOwnProperty,ue=Object.prototype.propertyIsEnumerable;var ot=(t,e,n)=>e in t?x(t,e,{enumerable:!0,configurable:!0,writable:!0,value:n}):t[e]=n,v=(t,e)=>{for(var n in e||(e={}))rt.call(e,n)&&ot(t,n,e[n]);if(nt)for(var n of nt(e))ue.call(e,n)&&ot(t,n,e[n]);return t},w=(t,e)=>oe(t,ie(e)),at=t=>x(t,"__esModule",{value:!0});var it=(t,e)=>()=>(e||t((e={exports:{}}).exports,e),e.exports),le=(t,e)=>{for(var n in e)x(t,n,{get:e[n],enumerable:!0})},st=(t,e,n,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let o of se(e))!rt.call(t,o)&&(n||o!=="default")&&x(t,o,{get:()=>e[o],enumerable:!(r=ae(e,o))||r.enumerable});return t},ct=(t,e)=>st(at(x(t!=null?re(ce(t)):{},"default",!e&&t&&t.__esModule?{get:()=>t.default,enumerable:!0}:{value:t,enumerable:!0})),t),fe=(t=>(e,n)=>t&&t.get(e)||(n=st(at({}),e,1),t&&t.set(e,n),n))(typeof WeakMap!="undefined"?new WeakMap:0);var Xt=it((C,T)=>{var pe=200,ut="__lodash_hash_undefined__",lt=9007199254740991,k="[object Arguments]",de="[object Array]",ft="[object Boolean]",pt="[object Date]",he="[object Error]",F="[object Function]",dt="[object GeneratorFunction]",P="[object Map]",ht="[object Number]",H="[object Object]",gt="[object Promise]",bt="[object RegExp]",D="[object Set]",yt="[object String]",_t="[object Symbol]",L="[object WeakMap]",mt="[object ArrayBuffer]",N="[object DataView]",$t="[object Float32Array]",vt="[object Float64Array]",Ot="[object Int8Array]",jt="[object Int16Array]",St="[object Int32Array]",Tt="[object Uint8Array]",xt="[object Uint8ClampedArray]",wt="[object Uint16Array]",At="[object Uint32Array]",ge=/[\\^$.*+?()[\]{}|]/g,be=/\w*$/,ye=/^\[object .+?Constructor\]$/,_e=/^(?:0|[1-9]\d*)$/,a={};a[k]=a[de]=a[mt]=a[N]=a[ft]=a[pt]=a[$t]=a[vt]=a[Ot]=a[jt]=a[St]=a[P]=a[ht]=a[H]=a[bt]=a[D]=a[yt]=a[_t]=a[Tt]=a[xt]=a[wt]=a[At]=!0;a[he]=a[F]=a[L]=!1;var me=typeof global=="object"&&global&&global.Object===Object&&global,$e=typeof self=="object"&&self&&self.Object===Object&&self,d=me||$e||Function("return this")(),Et=typeof C=="object"&&C&&!C.nodeType&&C,Ct=Et&&typeof T=="object"&&T&&!T.nodeType&&T,ve=Ct&&Ct.exports===Et;function Oe(t,e){return t.set(e[0],e[1]),t}function je(t,e){return t.add(e),t}function Se(t,e){for(var n=-1,r=t?t.length:0;++n<r&&e(t[n],n,t)!==!1;);return t}function Te(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}function It(t,e,n,r){var o=-1,c=t?t.length:0;for(r&&c&&(n=t[++o]);++o<c;)n=e(n,t[o],o,t);return n}function xe(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}function we(t,e){return t==null?void 0:t[e]}function Pt(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(n){}return e}function Dt(t){var e=-1,n=Array(t.size);return t.forEach(function(r,o){n[++e]=[o,r]}),n}function U(t,e){return function(n){return t(e(n))}}function Nt(t){var e=-1,n=Array(t.size);return t.forEach(function(r){n[++e]=r}),n}var Ae=Array.prototype,Ee=Function.prototype,K=Object.prototype,J=d["__core-js_shared__"],Kt=function(){var t=/[^.]+$/.exec(J&&J.keys&&J.keys.IE_PROTO||"");return t?"Symbol(src)_1."+t:""}(),Vt=Ee.toString,b=K.hasOwnProperty,V=K.toString,Ce=RegExp("^"+Vt.call(b).replace(ge,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),Mt=ve?d.Buffer:void 0,Rt=d.Symbol,Bt=d.Uint8Array,Ie=U(Object.getPrototypeOf,Object),Pe=Object.create,De=K.propertyIsEnumerable,Ne=Ae.splice,Gt=Object.getOwnPropertySymbols,Ke=Mt?Mt.isBuffer:void 0,Ve=U(Object.keys,Object),W=S(d,"DataView"),A=S(d,"Map"),q=S(d,"Promise"),Y=S(d,"Set"),X=S(d,"WeakMap"),E=S(Object,"create"),Me=$(W),Re=$(A),Be=$(q),Ge=$(Y),ke=$(X),kt=Rt?Rt.prototype:void 0,Ft=kt?kt.valueOf:void 0;function _(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Fe(){this.__data__=E?E(null):{}}function He(t){return this.has(t)&&delete this.__data__[t]}function Le(t){var e=this.__data__;if(E){var n=e[t];return n===ut?void 0:n}return b.call(e,t)?e[t]:void 0}function Ue(t){var e=this.__data__;return E?e[t]!==void 0:b.call(e,t)}function Je(t,e){var n=this.__data__;return n[t]=E&&e===void 0?ut:e,this}_.prototype.clear=Fe;_.prototype.delete=He;_.prototype.get=Le;_.prototype.has=Ue;_.prototype.set=Je;function h(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function We(){this.__data__=[]}function qe(t){var e=this.__data__,n=M(e,t);if(n<0)return!1;var r=e.length-1;return n==r?e.pop():Ne.call(e,n,1),!0}function Ye(t){var e=this.__data__,n=M(e,t);return n<0?void 0:e[n][1]}function Xe(t){return M(this.__data__,t)>-1}function Ze(t,e){var n=this.__data__,r=M(n,t);return r<0?n.push([t,e]):n[r][1]=e,this}h.prototype.clear=We;h.prototype.delete=qe;h.prototype.get=Ye;h.prototype.has=Xe;h.prototype.set=Ze;function O(t){var e=-1,n=t?t.length:0;for(this.clear();++e<n;){var r=t[e];this.set(r[0],r[1])}}function Qe(){this.__data__={hash:new _,map:new(A||h),string:new _}}function ze(t){return R(this,t).delete(t)}function tn(t){return R(this,t).get(t)}function en(t){return R(this,t).has(t)}function nn(t,e){return R(this,t).set(t,e),this}O.prototype.clear=Qe;O.prototype.delete=ze;O.prototype.get=tn;O.prototype.has=en;O.prototype.set=nn;function j(t){this.__data__=new h(t)}function rn(){this.__data__=new h}function on(t){return this.__data__.delete(t)}function an(t){return this.__data__.get(t)}function sn(t){return this.__data__.has(t)}function cn(t,e){var n=this.__data__;if(n instanceof h){var r=n.__data__;if(!A||r.length<pe-1)return r.push([t,e]),this;n=this.__data__=new O(r)}return n.set(t,e),this}j.prototype.clear=rn;j.prototype.delete=on;j.prototype.get=an;j.prototype.has=sn;j.prototype.set=cn;function un(t,e){var n=z(t)||Dn(t)?xe(t.length,String):[],r=n.length,o=!!r;for(var c in t)(e||b.call(t,c))&&!(o&&(c=="length"||En(c,r)))&&n.push(c);return n}function Ht(t,e,n){var r=t[e];(!(b.call(t,e)&&Wt(r,n))||n===void 0&&!(e in t))&&(t[e]=n)}function M(t,e){for(var n=t.length;n--;)if(Wt(t[n][0],e))return n;return-1}function ln(t,e){return t&&Lt(e,tt(e),t)}function Z(t,e,n,r,o,c,f){var s;if(r&&(s=c?r(t,o,c,f):r(t)),s!==void 0)return s;if(!B(t))return t;var l=z(t);if(l){if(s=xn(t),!e)return jn(t,s)}else{var p=m(t),u=p==F||p==dt;if(Kn(t))return bn(t,e);if(p==H||p==k||u&&!c){if(Pt(t))return c?t:{};if(s=wn(u?{}:t),!e)return Sn(t,ln(s,t))}else{if(!a[p])return c?t:{};s=An(t,p,Z,e)}}f||(f=new j);var i=f.get(t);if(i)return i;if(f.set(t,s),!l)var g=n?Tn(t):tt(t);return Se(g||t,function(y,I){g&&(I=y,y=t[I]),Ht(s,I,Z(y,e,n,r,I,t,f))}),s}function fn(t){return B(t)?Pe(t):{}}function pn(t,e,n){var r=e(t);return z(t)?r:Te(r,n(t))}function dn(t){return V.call(t)}function hn(t){if(!B(t)||In(t))return!1;var e=Yt(t)||Pt(t)?Ce:ye;return e.test($(t))}function gn(t){if(!Jt(t))return Ve(t);var e=[];for(var n in Object(t))b.call(t,n)&&n!="constructor"&&e.push(n);return e}function bn(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}function Q(t){var e=new t.constructor(t.byteLength);return new Bt(e).set(new Bt(t)),e}function yn(t,e){var n=e?Q(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.byteLength)}function _n(t,e,n){var r=e?n(Dt(t),!0):Dt(t);return It(r,Oe,new t.constructor)}function mn(t){var e=new t.constructor(t.source,be.exec(t));return e.lastIndex=t.lastIndex,e}function $n(t,e,n){var r=e?n(Nt(t),!0):Nt(t);return It(r,je,new t.constructor)}function vn(t){return Ft?Object(Ft.call(t)):{}}function On(t,e){var n=e?Q(t.buffer):t.buffer;return new t.constructor(n,t.byteOffset,t.length)}function jn(t,e){var n=-1,r=t.length;for(e||(e=Array(r));++n<r;)e[n]=t[n];return e}function Lt(t,e,n,r){n||(n={});for(var o=-1,c=e.length;++o<c;){var f=e[o],s=r?r(n[f],t[f],f,n,t):void 0;Ht(n,f,s===void 0?t[f]:s)}return n}function Sn(t,e){return Lt(t,Ut(t),e)}function Tn(t){return pn(t,tt,Ut)}function R(t,e){var n=t.__data__;return Cn(e)?n[typeof e=="string"?"string":"hash"]:n.map}function S(t,e){var n=we(t,e);return hn(n)?n:void 0}var Ut=Gt?U(Gt,Object):Rn,m=dn;(W&&m(new W(new ArrayBuffer(1)))!=N||A&&m(new A)!=P||q&&m(q.resolve())!=gt||Y&&m(new Y)!=D||X&&m(new X)!=L)&&(m=function(t){var e=V.call(t),n=e==H?t.constructor:void 0,r=n?$(n):void 0;if(r)switch(r){case Me:return N;case Re:return P;case Be:return gt;case Ge:return D;case ke:return L}return e});function xn(t){var e=t.length,n=t.constructor(e);return e&&typeof t[0]=="string"&&b.call(t,"index")&&(n.index=t.index,n.input=t.input),n}function wn(t){return typeof t.constructor=="function"&&!Jt(t)?fn(Ie(t)):{}}function An(t,e,n,r){var o=t.constructor;switch(e){case mt:return Q(t);case ft:case pt:return new o(+t);case N:return yn(t,r);case $t:case vt:case Ot:case jt:case St:case Tt:case xt:case wt:case At:return On(t,r);case P:return _n(t,r,n);case ht:case yt:return new o(t);case bt:return mn(t);case D:return $n(t,r,n);case _t:return vn(t)}}function En(t,e){return e=e==null?lt:e,!!e&&(typeof t=="number"||_e.test(t))&&t>-1&&t%1==0&&t<e}function Cn(t){var e=typeof t;return e=="string"||e=="number"||e=="symbol"||e=="boolean"?t!=="__proto__":t===null}function In(t){return!!Kt&&Kt in t}function Jt(t){var e=t&&t.constructor,n=typeof e=="function"&&e.prototype||K;return t===n}function $(t){if(t!=null){try{return Vt.call(t)}catch(e){}try{return t+""}catch(e){}}return""}function Pn(t){return Z(t,!0,!0)}function Wt(t,e){return t===e||t!==t&&e!==e}function Dn(t){return Nn(t)&&b.call(t,"callee")&&(!De.call(t,"callee")||V.call(t)==k)}var z=Array.isArray;function qt(t){return t!=null&&Vn(t.length)&&!Yt(t)}function Nn(t){return Mn(t)&&qt(t)}var Kn=Ke||Bn;function Yt(t){var e=B(t)?V.call(t):"";return e==F||e==dt}function Vn(t){return typeof t=="number"&&t>-1&&t%1==0&&t<=lt}function B(t){var e=typeof t;return!!t&&(e=="object"||e=="function")}function Mn(t){return!!t&&typeof t=="object"}function tt(t){return qt(t)?un(t):gn(t)}function Rn(){return[]}function Bn(){return!1}T.exports=Pn});var te=it((nr,zt)=>{var Gn="[object Object]";function kn(t){var e=!1;if(t!=null&&typeof t.toString!="function")try{e=!!(t+"")}catch(n){}return e}function Fn(t,e){return function(n){return t(e(n))}}var Hn=Function.prototype,Zt=Object.prototype,Qt=Hn.toString,Ln=Zt.hasOwnProperty,Un=Qt.call(Object),Jn=Zt.toString,Wn=Fn(Object.getPrototypeOf,Object);function qn(t){return!!t&&typeof t=="object"}function Yn(t){if(!qn(t)||Jn.call(t)!=Gn||kn(t))return!1;var e=Wn(t);if(e===null)return!0;var n=Ln.call(e,"constructor")&&e.constructor;return typeof n=="function"&&n instanceof n&&Qt.call(n)==Un}zt.exports=Yn});var tr={};le(tr,{traverse:()=>zn,version:()=>Qn});var G=ct(Xt(),1),ne=ct(te(),1);function Xn(t){if(t.includes(".")){let e=t.lastIndexOf(".");if(!t.slice(0,e).includes("."))return t.slice(0,e);for(let n=e-1;n--;)if(t[n]===".")return t.slice(n+1,e)}return null}var et=Xn;var ee="3.0.10";var Qn=ee;function zn(t,e){let n={now:!1};function r(o,c,f,s){let l=(0,G.default)(o),p,u=v({depth:-1,path:""},f);if(u.depth+=1,Array.isArray(l))for(let i=0,g=l.length;i<g&&!s.now;i++){let y=u.path?`${u.path}.${i}`:`${i}`;l[i]!==void 0?(u.parent=(0,G.default)(l),u.parentType="array",u.parentKey=et(y),p=r(c(l[i],void 0,w(v({},u),{path:y}),s),c,w(v({},u),{path:y}),s),Number.isNaN(p)&&i<l.length?(l.splice(i,1),i-=1):l[i]=p):l.splice(i,1)}else if((0,ne.default)(l))for(let i in l){if(s.now&&i!=null)break;let g=u.path?`${u.path}.${i}`:i;u.depth===0&&i!=null&&(u.topmostKey=i),u.parent=(0,G.default)(l),u.parentType="object",u.parentKey=et(g),p=r(c(i,l[i],w(v({},u),{path:g}),s),c,w(v({},u),{path:g}),s),Number.isNaN(p)?delete l[i]:l[i]=p}return l}return r(t,e,{},n)}return fe(tr);})();
11
11
  /**
12
12
  * @name ast-monkey-util
13
13
  * @fileoverview Utility library of AST helper functions
14
- * @version 2.0.7
14
+ * @version 2.0.10
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ast-monkey-util/}
18
- */function y(t){if(t.includes(".")){const e=t.lastIndexOf(".");if(!t.slice(0,e).includes("."))return t.slice(0,e);for(let r=e-1;r--;)if("."===t[r])return t.slice(r+1,e)}return null}t.traverse=function(t,e){return function t(e,r,o,c){const u=n(e);let a;const i={depth:-1,path:"",...o};if(i.depth+=1,Array.isArray(u))for(let e=0,o=u.length;e<o&&!c.now;e++){const o=i.path?`${i.path}.${e}`:`${e}`;void 0!==u[e]?(i.parent=n(u),i.parentType="array",i.parentKey=y(o),a=t(r(u[e],void 0,{...i,path:o},c),r,{...i,path:o},c),Number.isNaN(a)&&e<u.length?(u.splice(e,1),e-=1):u[e]=a):u.splice(e,1)}else if(p(u))for(const e in u){if(c.now&&null!=e)break;const o=i.path?`${i.path}.${e}`:e;0===i.depth&&null!=e&&(i.topmostKey=e),i.parent=n(u),i.parentType="object",i.parentKey=y(o),a=t(r(e,u[e],{...i,path:o},c),r,{...i,path:o},c),Number.isNaN(a)?delete u[e]:u[e]=a}return u}(t,e,{},{now:!1})},t.version="3.0.7",Object.defineProperty(t,"__esModule",{value:!0})}));
18
+ */
@@ -1,6 +1,7 @@
1
1
  // Quick Take
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { traverse } from "../dist/ast-monkey-traverse.esm.js";
5
6
 
6
7
  const paths = [];
@@ -24,7 +25,7 @@ const source = {
24
25
  traverse(source, (key, val, innerObj) => {
25
26
  // if currently an object is traversed, you get both "key" and "val"
26
27
  // if it's array, only "key" is present, "val" is undefined
27
- const current = val !== undefined ? val : key;
28
+ let current = val !== undefined ? val : key;
28
29
  if (
29
30
  // it's object (not array)
30
31
  val !== undefined &&
@@ -2,6 +2,7 @@
2
2
 
3
3
  import { strict as assert } from "assert";
4
4
  import op from "object-path";
5
+
5
6
  import { traverse } from "../dist/ast-monkey-traverse.esm.js";
6
7
 
7
8
  const input = { a: "1", b: [{ c: "2" }] };
@@ -10,7 +11,7 @@ const result1 = [];
10
11
 
11
12
  // the full traversal would look like this:
12
13
  traverse(input, (key1, val1, innerObj) => {
13
- const current = val1 !== undefined ? val1 : key1;
14
+ let current = val1 !== undefined ? val1 : key1;
14
15
  result1.push(innerObj.path);
15
16
  return current;
16
17
  });
@@ -1,6 +1,7 @@
1
1
  // Stop
2
2
 
3
3
  import { strict as assert } from "assert";
4
+
4
5
  import { traverse } from "../dist/ast-monkey-traverse.esm.js";
5
6
 
6
7
  const input = { a: "1", b: { c: "2" } };
@@ -8,7 +9,7 @@ const result1 = [];
8
9
 
9
10
  // the full traversal would look like this:
10
11
  traverse(input, (key1, val1, innerObj) => {
11
- const current = val1 !== undefined ? val1 : key1;
12
+ let current = val1 !== undefined ? val1 : key1;
12
13
  result1.push(innerObj.path);
13
14
  return current;
14
15
  });
@@ -18,7 +19,7 @@ assert.deepEqual(result1, ["a", "b", "b.c"]);
18
19
  // path, how object-path would reference it)
19
20
  const result2 = [];
20
21
  traverse(input, (key1, val1, innerObj, stop) => {
21
- const current = val1 !== undefined ? val1 : key1;
22
+ let current = val1 !== undefined ? val1 : key1;
22
23
  result2.push(innerObj.path);
23
24
  if (innerObj.path === "b") {
24
25
  stop.now = true; // <---------------- !!!!!!!!!!
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-monkey-traverse",
3
- "version": "3.0.7",
3
+ "version": "3.0.10",
4
4
  "description": "Utility library to traverse AST",
5
5
  "keywords": [
6
6
  "ast",
@@ -44,100 +44,44 @@
44
44
  },
45
45
  "types": "types/index.d.ts",
46
46
  "scripts": {
47
- "build": "rollup -c",
48
- "build:esbuild": "node '../../scripts/esbuild.js'",
49
- "build:esbuild:dev": "cross-env MODE=dev node '../../scripts/esbuild.js'",
50
- "ci_test": "npm run build && npm run format && tap --no-only --reporter=silent",
51
- "clean_types": "../../scripts/cleanTypes.js",
52
- "dev": "rollup -c --dev",
53
- "devunittest": "npm run dev && tap --only -R 'base'",
54
- "format": "npm run lect && npm run prettier && npm run lint",
55
- "lect": "lect",
56
- "lint": "../../node_modules/eslint/bin/eslint.js . --ext .js --ext .ts --fix --config \"../../.eslintrc.json\" --quiet",
57
- "perf": "node perf/check",
58
- "prettier": "../../node_modules/prettier/bin-prettier.js '*.{js,css,scss,vue,md,ts}' --write --loglevel silent",
59
- "republish": "npm publish || :",
60
- "tap": "tap",
61
- "pretest": "npm run build",
62
- "test": "npm run test:ci && npm run perf",
63
- "test:ci": "npm run unittest && npm run test:examples && npm run format",
64
- "test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
65
- "tsc": "tsc",
66
- "unittest": "tap --no-only --reporter=terse && tsc -p tsconfig.json --noEmit"
47
+ "build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
48
+ "dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
49
+ "dts": "rollup -c",
50
+ "examples": "node '../../ops/scripts/run-examples.js'",
51
+ "lect": "node '../../ops/lect/lect.js'",
52
+ "letspublish": "yarn publish || :",
53
+ "lint": "eslint . --fix",
54
+ "perf": "node perf/check.js",
55
+ "prepare": "echo 'ready'",
56
+ "pretest": "yarn run lect && yarn run build",
57
+ "test": "c8 yarn run unit && yarn run examples && yarn run lint",
58
+ "unit": "uvu test"
67
59
  },
68
- "tap": {
69
- "check-coverage": false,
70
- "node-arg": [
71
- "--no-warnings",
72
- "--experimental-loader",
73
- "@istanbuljs/esm-loader-hook"
60
+ "engines": {
61
+ "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
62
+ },
63
+ "c8": {
64
+ "check-coverage": true,
65
+ "exclude": [
66
+ "**/test/**/*.*"
74
67
  ],
75
- "timeout": 0
68
+ "lines": 100
76
69
  },
77
70
  "lect": {
78
71
  "licence": {
79
72
  "extras": [
80
73
  ""
81
74
  ]
82
- },
83
- "req": "{ traverse }",
84
- "various": {
85
- "devDependencies": [
86
- "@types/lodash.isplainobject",
87
- "lodash.isequal",
88
- "object-path"
89
- ]
90
75
  }
91
76
  },
92
77
  "dependencies": {
93
- "@babel/runtime": "^7.16.3",
94
- "ast-monkey-util": "^2.0.7",
78
+ "ast-monkey-util": "^2.0.10",
95
79
  "lodash.clonedeep": "^4.5.0",
96
80
  "lodash.isplainobject": "^4.0.6"
97
81
  },
98
82
  "devDependencies": {
99
- "@babel/cli": "^7.16.0",
100
- "@babel/core": "^7.16.0",
101
- "@babel/node": "^7.16.0",
102
- "@babel/plugin-external-helpers": "^7.16.0",
103
- "@babel/plugin-proposal-class-properties": "^7.16.0",
104
- "@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
105
- "@babel/plugin-proposal-object-rest-spread": "^7.16.0",
106
- "@babel/plugin-proposal-optional-chaining": "^7.16.0",
107
- "@babel/plugin-transform-runtime": "^7.16.4",
108
- "@babel/preset-env": "^7.16.4",
109
- "@babel/preset-typescript": "^7.16.0",
110
- "@babel/register": "^7.16.0",
111
- "@istanbuljs/esm-loader-hook": "^0.1.2",
112
- "@rollup/plugin-babel": "^5.3.0",
113
- "@rollup/plugin-commonjs": "^21.0.1",
114
- "@rollup/plugin-json": "^4.1.0",
115
- "@rollup/plugin-node-resolve": "^13.0.6",
116
- "@rollup/plugin-strip": "^2.1.0",
117
- "@rollup/plugin-typescript": "^8.3.0",
118
83
  "@types/lodash.clonedeep": "^4.5.6",
119
84
  "@types/lodash.isplainobject": "^4.0.6",
120
- "@types/node": "^16.11.10",
121
- "@types/tap": "^15.0.5",
122
- "@typescript-eslint/eslint-plugin": "^5.5.0",
123
- "@typescript-eslint/parser": "^5.5.0",
124
- "core-js": "^3.19.2",
125
- "cross-env": "^7.0.3",
126
- "eslint": "^8.3.0",
127
- "lect": "^0.18.7",
128
- "lodash.isequal": "^4.5.0",
129
- "object-path": "^0.11.8",
130
- "rollup": "^2.60.1",
131
- "rollup-plugin-ascii": "^0.0.3",
132
- "rollup-plugin-banner": "^0.2.1",
133
- "rollup-plugin-cleanup": "^3.2.1",
134
- "rollup-plugin-dts": "^4.0.1",
135
- "rollup-plugin-terser": "^7.0.2",
136
- "tap": "^15.1.5",
137
- "tslib": "^2.3.1",
138
- "typescript": "^4.5.2"
139
- },
140
- "engines": {
141
- "node": "^12.20.0 || ^14.13.1 || >=16.0.0"
85
+ "lodash.isequal": "^4.5.0"
142
86
  }
143
87
  }
package/types/index.d.ts CHANGED
File without changes
package/examples/api.json DELETED
@@ -1 +0,0 @@
1
- {"_quickTake.js":{"title":"Quick Take","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; traverse &#x7D; from \"ast-monkey-traverse\";\n\nconst paths = [];\nconst source = &#x7B;\n a: &#x7B;\n foo: &#x7B;\n bar: [\n &#x7B;\n foo: \"c\",\n &#x7D;,\n ],\n d: &#x7B;\n e: &#x7B;\n foo: \"f\",\n &#x7D;,\n &#x7D;,\n &#x7D;,\n &#x7D;,\n&#x7D;;\n\ntraverse(source, (key, val, innerObj) => &#x7B;\n // if currently an object is traversed, you get both \"key\" and \"val\"\n // if it's array, only \"key\" is present, \"val\" is undefined\n const current = val !== undefined ? val : key;\n if (\n // it's object (not array)\n val !== undefined &&\n // and has the key we need\n key === \"foo\"\n ) &#x7B;\n // push the path to array in the outer scope\n paths.push(innerObj.path);\n &#x7D;\n return current;\n&#x7D;);\n\n// notice object-path notation \"a.foo.bar.0.foo\" - array segments use dots too:\nassert.deepEqual(paths, [\"a.foo\", \"a.foo.bar.0.foo\", \"a.foo.d.e.foo\"]);"},"compatible-with-object-path.js":{"title":"Compatible With `object-path`","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport op from \"object-path\";\nimport &#x7B; traverse &#x7D; from \"ast-monkey-traverse\";\n\nconst input = &#x7B; a: \"1\", b: [&#x7B; c: \"2\" &#x7D;] &#x7D;;\nObject.freeze(input); // let's freeze it, just for fun\nconst result1 = [];\n\n// the full traversal would look like this:\ntraverse(input, (key1, val1, innerObj) => &#x7B;\n const current = val1 !== undefined ? val1 : key1;\n result1.push(innerObj.path);\n return current;\n&#x7D;);\n\n// notice the object-path notation is \"b.0.c\" not \"b[0].c\"\nassert.deepEqual(result1, [\"a\", \"b\", \"b.0\", \"b.0.c\"]);\n\n// each reported path is fully compatible with `object-path` get() method\nassert.deepEqual(op.get(input, \"a\"), \"1\");\nassert.deepEqual(op.get(input, \"b\"), [&#x7B; c: \"2\" &#x7D;]);\nassert.deepEqual(op.get(input, \"b.0\"), &#x7B; c: \"2\" &#x7D;);\nassert.deepEqual(op.get(input, \"b.0.c\"), \"2\");"},"stopping.js":{"title":"Stop","content":"import &#x7B; strict as assert &#x7D; from \"assert\";\nimport &#x7B; traverse &#x7D; from \"ast-monkey-traverse\";\n\nconst input = &#x7B; a: \"1\", b: &#x7B; c: \"2\" &#x7D; &#x7D;;\nconst result1 = [];\n\n// the full traversal would look like this:\ntraverse(input, (key1, val1, innerObj) => &#x7B;\n const current = val1 !== undefined ? val1 : key1;\n result1.push(innerObj.path);\n return current;\n&#x7D;);\nassert.deepEqual(result1, [\"a\", \"b\", \"b.c\"]);\n\n// now let's stop the traversal at path \"b\" (that's real\n// path, how object-path would reference it)\nconst result2 = [];\ntraverse(input, (key1, val1, innerObj, stop) => &#x7B;\n const current = val1 !== undefined ? val1 : key1;\n result2.push(innerObj.path);\n if (innerObj.path === \"b\") &#x7B;\n stop.now = true; // <---------------- !!!!!!!!!!\n &#x7D;\n return current;\n&#x7D;);\nassert.deepEqual(result2, [\"a\", \"b\"]);"}}