ast-monkey-traverse
Advanced tools
Comparing version 1.3.3 to 1.4.0
@@ -8,2 +8,6 @@ # Change Log | ||
## [1.4.0] - 2018-10-13 | ||
- ✨ Updated all dependencies and restored coverage tracking both via terminal when testing and through coveralls.io | ||
## [1.3.0] - 2018-06-11 | ||
@@ -31,4 +35,5 @@ | ||
[1.1.0]: https://bitbucket.org/codsen/ast-monkey-traverse/branches/compare/v1.1.0%0Dv1.0.4#diff | ||
[1.2.0]: https://bitbucket.org/codsen/ast-monkey-traverse/branches/compare/v1.2.0%0Dv1.1.3#diff | ||
[1.3.0]: https://bitbucket.org/codsen/ast-monkey-traverse/branches/compare/v1.3.0%0Dv1.2.1#diff | ||
[1.2.0]: https://bitbucket.org/codsen/ast-monkey-traverse/branches/compare/v1.2.0%0Dv1.1.3#diff | ||
[1.1.0]: https://bitbucket.org/codsen/ast-monkey-traverse/branches/compare/v1.1.0%0Dv1.0.4#diff | ||
[1.4.0]: https://bitbucket.org/codsen/ast-monkey-traverse/branches/compare/v1.4.0%0Dv1.3.3#diff |
@@ -8,6 +8,3 @@ 'use strict'; | ||
/* eslint no-param-reassign:0 */ | ||
var isArr = Array.isArray; | ||
function trimFirstDot(str) { | ||
@@ -23,22 +20,24 @@ if (typeof str === "string" && str.length > 0 && str[0] === ".") { | ||
function astMonkeyTraverse(tree1, cb1) { | ||
// | ||
// traverseInner() needs a wrapper to shield the internal last argument and simplify external API. | ||
// | ||
function traverseInner(treeOriginal, callback, innerObj) { | ||
var tree = clone(treeOriginal); | ||
var i = void 0; | ||
var len = void 0; | ||
var res = void 0; | ||
var allKeys = void 0; | ||
var key = void 0; | ||
innerObj = Object.assign({ depth: -1, path: "" }, innerObj); | ||
var i; | ||
var len; | ||
var res; | ||
var allKeys; | ||
var key; | ||
innerObj = Object.assign({ | ||
depth: -1, | ||
path: "" | ||
}, innerObj); | ||
innerObj.depth += 1; | ||
if (isArr(tree)) { | ||
for (i = 0, len = tree.length; i < len; i++) { | ||
var path = innerObj.path + "." + i; | ||
var path = "".concat(innerObj.path, ".").concat(i); | ||
if (tree[i] !== undefined) { | ||
innerObj.parent = clone(tree); | ||
// innerObj.path = `${innerObj.path}[${i}]` | ||
res = traverseInner(callback(tree[i], undefined, Object.assign({}, innerObj, { path: trimFirstDot(path) })), callback, Object.assign({}, innerObj, { path: trimFirstDot(path) })); | ||
res = traverseInner(callback(tree[i], undefined, Object.assign({}, innerObj, { | ||
path: trimFirstDot(path) | ||
})), callback, Object.assign({}, innerObj, { | ||
path: trimFirstDot(path) | ||
})); | ||
if (Number.isNaN(res) && i < tree.length) { | ||
@@ -58,3 +57,3 @@ tree.splice(i, 1); | ||
key = allKeys[i]; | ||
var _path = innerObj.path + "." + key; | ||
var _path = "".concat(innerObj.path, ".").concat(key); | ||
if (innerObj.depth === 0 && existy(key)) { | ||
@@ -64,3 +63,7 @@ innerObj.topmostKey = key; | ||
innerObj.parent = clone(tree); | ||
res = traverseInner(callback(key, tree[key], Object.assign({}, innerObj, { path: trimFirstDot(_path) })), callback, Object.assign({}, innerObj, { path: trimFirstDot(_path) })); | ||
res = traverseInner(callback(key, tree[key], Object.assign({}, innerObj, { | ||
path: trimFirstDot(_path) | ||
})), callback, Object.assign({}, innerObj, { | ||
path: trimFirstDot(_path) | ||
})); | ||
if (Number.isNaN(res)) { | ||
@@ -67,0 +70,0 @@ delete tree[key]; |
import clone from 'lodash.clonedeep'; | ||
import isObj from 'lodash.isplainobject'; | ||
/* eslint no-param-reassign:0 */ | ||
const isArr = Array.isArray; | ||
function trimFirstDot(str) { | ||
@@ -18,8 +15,4 @@ if (typeof str === "string" && str.length > 0 && str[0] === ".") { | ||
function astMonkeyTraverse(tree1, cb1) { | ||
// | ||
// traverseInner() needs a wrapper to shield the internal last argument and simplify external API. | ||
// | ||
function traverseInner(treeOriginal, callback, innerObj) { | ||
const tree = clone(treeOriginal); | ||
let i; | ||
@@ -37,3 +30,2 @@ let len; | ||
innerObj.parent = clone(tree); | ||
// innerObj.path = `${innerObj.path}[${i}]` | ||
res = traverseInner( | ||
@@ -40,0 +32,0 @@ callback( |
@@ -1,1 +0,1 @@ | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.astMonkeyTraverse=e()}(this,function(){"use strict";var St="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var t,xt="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t},p=(function(t,e){var r="__lodash_hash_undefined__",n=9007199254740991,m="[object Arguments]",w="[object Function]",S="[object GeneratorFunction]",o="[object Map]",x="[object Object]",i="[object Promise]",u="[object Set]",c="[object WeakMap]",a="[object DataView]",f=/^\[object .+?Constructor\]$/,s=/^(?:0|[1-9]\d*)$/,l="object"==xt(St)&&St&&St.Object===Object&&St,p="object"==("undefined"==typeof self?"undefined":xt(self))&&self&&self.Object===Object&&self,y=l||p||Function("return this")(),_=e&&!e.nodeType&&e,d=_&&t&&!t.nodeType&&t,h=d&&d.exports===_;function A(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}function v(e,n){return function(t){return e(n(t))}}var b,g=Array.prototype,j=Function.prototype,O=Object.prototype,P=y["__core-js_shared__"],k=(b=/[^.]+$/.exec(P&&P.keys&&P.keys.IE_PROTO||""))?"Symbol(src)_1."+b:"",$=j.toString,N=O.hasOwnProperty,F=O.toString,M=RegExp("^"+$.call(N).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),T=h?y.Buffer:void 0,B=y.Symbol,E=(y.Uint8Array,v(Object.getPrototypeOf,Object)),D=Object.create,I=O.propertyIsEnumerable,R=g.splice,V=Object.getOwnPropertySymbols,W=T?T.isBuffer:void 0,C=v(Object.keys,Object),G=lt(y,"DataView"),K=lt(y,"Map"),U=lt(y,"Promise"),q=lt(y,"Set"),z=lt(y,"WeakMap"),H=lt(Object,"create"),J=ht(G),L=ht(K),Q=ht(U),X=ht(q),Y=ht(z),Z=B?B.prototype:void 0;Z&&Z.valueOf;function tt(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 et(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 nt(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 rt(t){this.__data__=new et(t)}function ot(t,e){var n,r,o,i=bt(t)||(o=r=n=t)&&"object"==(void 0===o?"undefined":xt(o))&>(r)&&N.call(n,"callee")&&(!I.call(n,"callee")||F.call(n)==m)?function(t,e){for(var n=-1,r=Array(t);++n<t;)r[n]=e(n);return r}(t.length,String):[],u=i.length,c=!!u;for(var a in t)!e&&!N.call(t,a)||c&&("length"==a||_t(a,u))||i.push(a);return i}function it(t,e,n){var r=t[e];N.call(t,e)&&vt(r,n)&&(void 0!==n||e in t)||(t[e]=n)}function ut(t,e){for(var n=t.length;n--;)if(vt(t[n][0],e))return n;return-1}function ct(n,r,o,i,t,e,u){var c;if(i&&(c=e?i(n,t,e,u):i(n)),void 0!==c)return c;if(!mt(n))return n;var a,f,s,l,p,y,_=bt(n);if(_){if(c=function(t){var e=t.length,n=t.constructor(e);e&&"string"==typeof t[0]&&N.call(t,"index")&&(n.index=t.index,n.input=t.input);return n}(n),!r)return function(t,e){var n=-1,r=t.length;e||(e=Array(r));for(;++n<r;)e[n]=t[n];return e}(n,c)}else{var d=yt(n),h=d==w||d==S;if(jt(n))return function(t,e){if(e)return t.slice();var n=new t.constructor(t.length);return t.copy(n),n}(n,r);if(d!=x&&d!=m&&(!h||e))return e?n:{};if(A(n))return e?n:{};if(c="function"!=typeof(p=h?{}:n).constructor||dt(p)?{}:mt(y=E(p))?D(y):{},!r)return l=a=n,f=(s=c)&&ft(l,wt(l),s),ft(a,pt(a),f)}u||(u=new rt);var v,b,g,j=u.get(n);if(j)return j;if(u.set(n,c),!_)var O=o?(b=pt,g=wt(v=n),bt(v)?g:function(t,e){for(var n=-1,r=e.length,o=t.length;++n<r;)t[o+n]=e[n];return t}(g,b(v))):wt(n);return function(t,e){for(var n=-1,r=t?t.length:0;++n<r&&!1!==e(t[n],n,t););}(O||n,function(t,e){O&&(t=n[e=t]),it(c,e,ct(t,r,o,i,e,n,u))}),c}function at(t){return!(!mt(t)||(e=t,k&&k in e))&&(Ot(t)||A(t)?M:f).test(ht(t));var e}function ft(t,e,n,r){n||(n={});for(var o=-1,i=e.length;++o<i;){var u=e[o],c=r?r(n[u],t[u],u,n,t):void 0;it(n,u,void 0===c?t[u]:c)}return n}function st(t,e){var n,r,o=t.__data__;return("string"==(r=void 0===(n=e)?"undefined":xt(n))||"number"==r||"symbol"==r||"boolean"==r?"__proto__"!==n:null===n)?o["string"==typeof e?"string":"hash"]:o.map}function lt(t,e){var n,r,o=(r=e,null==(n=t)?void 0:n[r]);return at(o)?o:void 0}tt.prototype.clear=function(){this.__data__=H?H(null):{}},tt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},tt.prototype.get=function(t){var e=this.__data__;if(H){var n=e[t];return n===r?void 0:n}return N.call(e,t)?e[t]:void 0},tt.prototype.has=function(t){var e=this.__data__;return H?void 0!==e[t]:N.call(e,t)},tt.prototype.set=function(t,e){return this.__data__[t]=H&&void 0===e?r:e,this},et.prototype.clear=function(){this.__data__=[]},et.prototype.delete=function(t){var e=this.__data__,n=ut(e,t);return!(n<0||(n==e.length-1?e.pop():R.call(e,n,1),0))},et.prototype.get=function(t){var e=this.__data__,n=ut(e,t);return n<0?void 0:e[n][1]},et.prototype.has=function(t){return-1<ut(this.__data__,t)},et.prototype.set=function(t,e){var n=this.__data__,r=ut(n,t);return r<0?n.push([t,e]):n[r][1]=e,this},nt.prototype.clear=function(){this.__data__={hash:new tt,map:new(K||et),string:new tt}},nt.prototype.delete=function(t){return st(this,t).delete(t)},nt.prototype.get=function(t){return st(this,t).get(t)},nt.prototype.has=function(t){return st(this,t).has(t)},nt.prototype.set=function(t,e){return st(this,t).set(t,e),this},rt.prototype.clear=function(){this.__data__=new et},rt.prototype.delete=function(t){return this.__data__.delete(t)},rt.prototype.get=function(t){return this.__data__.get(t)},rt.prototype.has=function(t){return this.__data__.has(t)},rt.prototype.set=function(t,e){var n=this.__data__;if(n instanceof et){var r=n.__data__;if(!K||r.length<199)return r.push([t,e]),this;n=this.__data__=new nt(r)}return n.set(t,e),this};var pt=V?v(V,Object):function(){return[]},yt=function(t){return F.call(t)};function _t(t,e){return!!(e=null==e?n:e)&&("number"==typeof t||s.test(t))&&-1<t&&t%1==0&&t<e}function dt(t){var e=t&&t.constructor;return t===("function"==typeof e&&e.prototype||O)}function ht(t){if(null!=t){try{return $.call(t)}catch(t){}try{return t+""}catch(t){}}return""}function vt(t,e){return t===e||t!=t&&e!=e}(G&&yt(new G(new ArrayBuffer(1)))!=a||K&&yt(new K)!=o||U&&yt(U.resolve())!=i||q&&yt(new q)!=u||z&&yt(new z)!=c)&&(yt=function(t){var e=F.call(t),n=e==x?t.constructor:void 0,r=n?ht(n):void 0;if(r)switch(r){case J:return a;case L:return o;case Q:return i;case X:return u;case Y:return c}return e});var bt=Array.isArray;function gt(t){return null!=t&&("number"==typeof(e=t.length)&&-1<e&&e%1==0&&e<=n)&&!Ot(t);var e}var jt=W||function(){return!1};function Ot(t){var e=mt(t)?F.call(t):"";return e==w||e==S}function mt(t){var e=void 0===t?"undefined":xt(t);return!!t&&("object"==e||"function"==e)}function wt(t){return gt(t)?ot(t):function(t){if(!dt(t))return C(t);var e=[];for(var n in Object(t))N.call(t,n)&&"constructor"!=n&&e.push(n);return e}(t)}t.exports=function(t){return ct(t,!0,!0)}}(t={exports:{}},t.exports),t.exports),o="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&"function"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?"symbol":typeof t};var e,n,r=Function.prototype,i=Object.prototype,u=r.toString,c=i.hasOwnProperty,a=u.call(Object),f=i.toString,s=(e=Object.getPrototypeOf,n=Object,function(t){return e(n(t))});var y=function(t){if(!(e=t)||"object"!=(void 0===e?"undefined":o(e))||"[object Object]"!=f.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,n=s(t);if(null===n)return!0;var r=c.call(n,"constructor")&&n.constructor;return"function"==typeof r&&r instanceof r&&u.call(r)==a},_=Array.isArray;function d(t){return"string"==typeof t&&0<t.length&&"."===t[0]?t.slice(1):t}return function(t,e){return function t(e,n,r){var o=p(e),i=void 0,u=void 0,c=void 0,a=void 0,f=void 0;if((r=Object.assign({depth:-1,path:""},r)).depth+=1,_(o))for(i=0,u=o.length;i<u;i++){var s=r.path+"."+i;void 0!==o[i]?(r.parent=p(o),c=t(n(o[i],void 0,Object.assign({},r,{path:d(s)})),n,Object.assign({},r,{path:d(s)})),Number.isNaN(c)&&i<o.length?(o.splice(i,1),i-=1):o[i]=c):o.splice(i,1)}else if(y(o))for(i=0,u=(a=Object.keys(o)).length;i<u;i++){f=a[i];var l=r.path+"."+f;0===r.depth&&null!=f&&(r.topmostKey=f),r.parent=p(o),c=t(n(f,o[f],Object.assign({},r,{path:d(l)})),n,Object.assign({},r,{path:d(l)})),Number.isNaN(c)?delete o[f]:o[f]=c}return o}(t,e,{})}}); | ||
!function(t,e){"object"==typeof exports&&"undefined"!=typeof module?module.exports=e():"function"==typeof define&&define.amd?define(e):t.astMonkeyTraverse=e()}(this,function(){"use strict";var t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};var e,r=(function(e,r){var n=200,o="__lodash_hash_undefined__",c=9007199254740991,u="[object Arguments]",a="[object Boolean]",i="[object Date]",f="[object Function]",s="[object GeneratorFunction]",l="[object Map]",p="[object Number]",h="[object Object]",y="[object RegExp]",_="[object Set]",v="[object String]",b="[object Symbol]",d="[object ArrayBuffer]",j="[object DataView]",g="[object Float32Array]",O="[object Float64Array]",w="[object Int8Array]",m="[object Int16Array]",A="[object Int32Array]",x="[object Uint8Array]",S="[object Uint8ClampedArray]",P="[object Uint16Array]",k="[object Uint32Array]",$=/\w*$/,E=/^\[object .+?Constructor\]$/,F=/^(?:0|[1-9]\d*)$/,I={};I[u]=I["[object Array]"]=I[d]=I[j]=I[a]=I[i]=I[g]=I[O]=I[w]=I[m]=I[A]=I[l]=I[p]=I[h]=I[y]=I[_]=I[v]=I[b]=I[x]=I[S]=I[P]=I[k]=!0,I["[object Error]"]=I[f]=I["[object WeakMap]"]=!1;var M="object"==typeof t&&t&&t.Object===Object&&t,N="object"==typeof self&&self&&self.Object===Object&&self,B=M||N||Function("return this")(),U=r&&!r.nodeType&&r,T=U&&e&&!e.nodeType&&e,W=T&&T.exports===U;function D(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 G(t){var e=-1,r=Array(t.size);return t.forEach(function(t){r[++e]=t}),r}var K,q=Array.prototype,H=Function.prototype,J=Object.prototype,Q=B["__core-js_shared__"],X=(K=/[^.]+$/.exec(Q&&Q.keys&&Q.keys.IE_PROTO||""))?"Symbol(src)_1."+K:"",Y=H.toString,Z=J.hasOwnProperty,tt=J.toString,et=RegExp("^"+Y.call(Z).replace(/[\\^$.*+?()[\]{}|]/g,"\\$&").replace(/hasOwnProperty|(function).*?(?=\\\()| for .+?(?=\\\])/g,"$1.*?")+"$"),rt=W?B.Buffer:void 0,nt=B.Symbol,ot=B.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=Tt(B,"DataView"),ht=Tt(B,"Map"),yt=Tt(B,"Promise"),_t=Tt(B,"Set"),vt=Tt(B,"WeakMap"),bt=Tt(Object,"create"),dt=Ct(pt),jt=Ct(ht),gt=Ct(yt),Ot=Ct(_t),wt=Ct(vt),mt=nt?nt.prototype:void 0,At=mt?mt.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 Pt(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 kt(t){this.__data__=new St(t)}function $t(t,e){var r=Vt(t)||function(t){return function(t){return function(t){return!!t&&"object"==typeof t}(t)&&Gt(t)}(t)&&Z.call(t,"callee")&&(!at.call(t,"callee")||tt.call(t)==u)}(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 c in t)!e&&!Z.call(t,c)||o&&("length"==c||Rt(c,n))||r.push(c);return r}function Et(t,e,r){var n=t[e];Z.call(t,e)&&Lt(n,r)&&(void 0!==r||e in t)||(t[e]=r)}function Ft(t,e){for(var r=t.length;r--;)if(Lt(t[r][0],e))return r;return-1}function It(t,e,r,n,o,c,E){var F;if(n&&(F=c?n(t,o,c,E):n(t)),void 0!==F)return F;if(!Ht(t))return t;var M=Vt(t);if(M){if(F=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,F)}else{var N=Dt(t),B=N==f||N==s;if(Kt(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==h||N==u||B&&!c){if(C(t))return c?t:{};if(F=function(t){return"function"!=typeof t.constructor||zt(t)?{}:(e=ct(t),Ht(e)?ut(e):{});var e}(B?{}:t),!e)return function(t,e){return Bt(t,Wt(t),e)}(t,function(t,e){return t&&Bt(e,Jt(e),t)}(F,t))}else{if(!I[N])return c?t:{};F=function(t,e,r,n){var o=t.constructor;switch(e){case d:return Nt(t);case a:case i:return new o(+t);case j:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.byteLength)}(t,n);case g:case O:case w:case m:case A:case x:case S:case P:case k:return function(t,e){var r=e?Nt(t.buffer):t.buffer;return new t.constructor(r,t.byteOffset,t.length)}(t,n);case l:return function(t,e,r){return z(e?r(L(t),!0):L(t),D,new t.constructor)}(t,n,r);case p:case v:return new o(t);case y:return(f=new(u=t).constructor(u.source,$.exec(u))).lastIndex=u.lastIndex,f;case _:return function(t,e,r){return z(e?r(G(t),!0):G(t),R,new t.constructor)}(t,n,r);case b:return c=t,At?Object(At.call(c)):{}}var c;var u,f}(t,N,It,e)}}E||(E=new kt);var U=E.get(t);if(U)return U;if(E.set(t,F),!M)var T=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,Wt)}(t):Jt(t);return function(t,e){for(var r=-1,n=t?t.length:0;++r<n&&!1!==e(t[r],r,t););}(T||t,function(o,c){T&&(o=t[c=o]),Et(F,c,It(o,e,r,n,c,t,E))}),F}function Mt(t){return!(!Ht(t)||(e=t,X&&X in e))&&(qt(t)||C(t)?et:E).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 Bt(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;Et(r,u,void 0===a?t[u]:a)}return r}function Ut(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 Tt(t,e){var r=function(t,e){return null==t?void 0:t[e]}(t,e);return Mt(r)?r:void 0}xt.prototype.clear=function(){this.__data__=bt?bt(null):{}},xt.prototype.delete=function(t){return this.has(t)&&delete this.__data__[t]},xt.prototype.get=function(t){var e=this.__data__;if(bt){var r=e[t];return r===o?void 0:r}return Z.call(e,t)?e[t]:void 0},xt.prototype.has=function(t){var e=this.__data__;return bt?void 0!==e[t]:Z.call(e,t)},xt.prototype.set=function(t,e){return this.__data__[t]=bt&&void 0===e?o:e,this},St.prototype.clear=function(){this.__data__=[]},St.prototype.delete=function(t){var e=this.__data__,r=Ft(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=Ft(e,t);return r<0?void 0:e[r][1]},St.prototype.has=function(t){return Ft(this.__data__,t)>-1},St.prototype.set=function(t,e){var r=this.__data__,n=Ft(r,t);return n<0?r.push([t,e]):r[n][1]=e,this},Pt.prototype.clear=function(){this.__data__={hash:new xt,map:new(ht||St),string:new xt}},Pt.prototype.delete=function(t){return Ut(this,t).delete(t)},Pt.prototype.get=function(t){return Ut(this,t).get(t)},Pt.prototype.has=function(t){return Ut(this,t).has(t)},Pt.prototype.set=function(t,e){return Ut(this,t).set(t,e),this},kt.prototype.clear=function(){this.__data__=new St},kt.prototype.delete=function(t){return this.__data__.delete(t)},kt.prototype.get=function(t){return this.__data__.get(t)},kt.prototype.has=function(t){return this.__data__.has(t)},kt.prototype.set=function(t,e){var r=this.__data__;if(r instanceof St){var o=r.__data__;if(!ht||o.length<n-1)return o.push([t,e]),this;r=this.__data__=new Pt(o)}return r.set(t,e),this};var Wt=ft?V(ft,Object):function(){return[]},Dt=function(t){return tt.call(t)};function Rt(t,e){return!!(e=null==e?c:e)&&("number"==typeof t||F.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&&Dt(new pt(new ArrayBuffer(1)))!=j||ht&&Dt(new ht)!=l||yt&&"[object Promise]"!=Dt(yt.resolve())||_t&&Dt(new _t)!=_||vt&&"[object WeakMap]"!=Dt(new vt))&&(Dt=function(t){var e=tt.call(t),r=e==h?t.constructor:void 0,n=r?Ct(r):void 0;if(n)switch(n){case dt:return j;case jt:return l;case gt:return"[object Promise]";case Ot:return _;case wt:return"[object WeakMap]"}return e});var Vt=Array.isArray;function Gt(t){return null!=t&&function(t){return"number"==typeof t&&t>-1&&t%1==0&&t<=c}(t.length)&&!qt(t)}var Kt=st||function(){return!1};function qt(t){var e=Ht(t)?tt.call(t):"";return e==f||e==s}function Ht(t){var e=typeof t;return!!t&&("object"==e||"function"==e)}function Jt(t){return Gt(t)?$t(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)}e.exports=function(t){return It(t,!0,!0)}}(e={exports:{}},e.exports),e.exports),n="[object Object]";var o,c,u=Function.prototype,a=Object.prototype,i=u.toString,f=a.hasOwnProperty,s=i.call(Object),l=a.toString,p=(o=Object.getPrototypeOf,c=Object,function(t){return o(c(t))});var h=function(t){if(!function(t){return!!t&&"object"==typeof t}(t)||l.call(t)!=n||function(t){var e=!1;if(null!=t&&"function"!=typeof t.toString)try{e=!!(t+"")}catch(t){}return e}(t))return!1;var e=p(t);if(null===e)return!0;var r=f.call(e,"constructor")&&e.constructor;return"function"==typeof r&&r instanceof r&&i.call(r)==s},y=Array.isArray;function _(t){return"string"==typeof t&&t.length>0&&"."===t[0]?t.slice(1):t}return function(t,e){return function t(e,n,o){var c,u,a,i,f,s=r(e);if((o=Object.assign({depth:-1,path:""},o)).depth+=1,y(s))for(c=0,u=s.length;c<u;c++){var l="".concat(o.path,".").concat(c);void 0!==s[c]?(o.parent=r(s),a=t(n(s[c],void 0,Object.assign({},o,{path:_(l)})),n,Object.assign({},o,{path:_(l)})),Number.isNaN(a)&&c<s.length?(s.splice(c,1),c-=1):s[c]=a):s.splice(c,1)}else if(h(s))for(c=0,u=(i=Object.keys(s)).length;c<u;c++){f=i[c];var p="".concat(o.path,".").concat(f);0===o.depth&&null!=f&&(o.topmostKey=f),o.parent=r(s),a=t(n(f,s[f],Object.assign({},o,{path:_(p)})),n,Object.assign({},o,{path:_(p)})),Number.isNaN(a)?delete s[f]:s[f]=a}return s}(t,e,{})}}); |
{ | ||
"name": "ast-monkey-traverse", | ||
"version": "1.3.3", | ||
"version": "1.4.0", | ||
"description": "Utility library to traverse parsed HTML (AST's) or anything nested (plain objects within arrays within plain objects)", | ||
@@ -29,6 +29,5 @@ "license": "MIT", | ||
"format": "prettier '*.{js,ts,css,less,scss,vue,gql,md}' --write && ./node_modules/.bin/eslint src/*.js test/*.js --fix", | ||
"precommit": "npm run format && npm test", | ||
"prepare": "npm run build", | ||
"pretest": "npm run build", | ||
"test": "./node_modules/.bin/eslint src/*.js test/*.js && nyc --require esm --reporter=html --reporter=text ava" | ||
"test": "./node_modules/.bin/eslint src/*.js test/*.js && nyc ava" | ||
}, | ||
@@ -144,3 +143,5 @@ "ava": { | ||
"licence": { | ||
"extras": [] | ||
"extras": [ | ||
"" | ||
] | ||
}, | ||
@@ -165,2 +166,9 @@ "npmignore": { | ||
}, | ||
"nyc": { | ||
"instrument": false, | ||
"require": [ | ||
"@babel/register" | ||
], | ||
"sourceMap": false | ||
}, | ||
"dependencies": { | ||
@@ -171,5 +179,7 @@ "lodash.clonedeep": "*", | ||
"devDependencies": { | ||
"ava": "latest", | ||
"babel-preset-env": "latest", | ||
"codacy-coverage": "latest", | ||
"@babel/core": "^7.1.2", | ||
"@babel/preset-env": "^7.1.0", | ||
"@babel/register": "^7.0.0", | ||
"ava": "1.0.0-beta.8", | ||
"babel-plugin-istanbul": "^5.0.1", | ||
"coveralls": "latest", | ||
@@ -184,3 +194,2 @@ "eslint": "latest", | ||
"eslint-plugin-scanjs-rules": "latest", | ||
"esm": "latest", | ||
"husky": "latest", | ||
@@ -192,8 +201,9 @@ "lodash.isequal": "latest", | ||
"rollup": "latest", | ||
"rollup-plugin-babel": "^3.0.5", | ||
"rollup-plugin-commonjs": "^9.1.3", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-strip": "^1.1.1", | ||
"rollup-plugin-uglify": "^4.0.0" | ||
"rollup-plugin-babel": "^4.0.3", | ||
"rollup-plugin-cleanup": "^3.0.0", | ||
"rollup-plugin-commonjs": "^9.2.0", | ||
"rollup-plugin-node-resolve": "^3.4.0", | ||
"rollup-plugin-strip": "^1.2.0", | ||
"rollup-plugin-terser": "^3.0.0" | ||
} | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
30584
188
26