ast-deep-contains 5.2.3 → 5.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md
CHANGED
|
@@ -21,6 +21,8 @@
|
|
|
21
21
|
<img src="https://img.shields.io/badge/licence-MIT-brightgreen.svg?style=flat-square" alt="MIT Licence">
|
|
22
22
|
</p>
|
|
23
23
|
|
|
24
|
+
**Powered by object-path.** No other dependencies.
|
|
25
|
+
|
|
24
26
|
## Install
|
|
25
27
|
|
|
26
28
|
This package is [pure ESM](https://gist.github.com/sindresorhus/a39789f98801d908bbc7ff3ecc99d99c). If you're not ready yet, install an older version of this program, 3.1.0 (`npm i ast-deep-contains@3.1.0`).
|
|
@@ -60,7 +62,7 @@ assert.equal(errors.length, 0);
|
|
|
60
62
|
|
|
61
63
|
## Documentation
|
|
62
64
|
|
|
63
|
-
Please [visit codsen.com](https://codsen.com/os/ast-deep-contains/) for a full description of the API.
|
|
65
|
+
Please [visit codsen.com](https://codsen.com/os/ast-deep-contains/) for a full description of the API. For **Changelog**, see [raw md on GitHub](https://github.com/codsen/codsen/blob/main/packages/ast-deep-contains/CHANGELOG.md) or [the website](https://codsen.com/os/ast-deep-contains/changelog).
|
|
64
66
|
|
|
65
67
|
## Contributing
|
|
66
68
|
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-deep-contains
|
|
3
3
|
* @fileoverview Like t.same assert on array of objects, where element order doesn't matter.
|
|
4
|
-
* @version 5.2.
|
|
4
|
+
* @version 5.2.4
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-deep-contains/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import{traverse as E}from"ast-monkey-traverse";import w from"object-path";var k="5.2.
|
|
10
|
+
import{traverse as E}from"ast-monkey-traverse";import w from"object-path";var k="5.2.4";var P=k;function N(e){if(e.includes(".")){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function g(e){if(e===null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r===null||r===Object.prototype}function j(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="number"&&Number.isNaN(e)?"nan":typeof e!="object"?typeof e:Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var x={skipContainers:!0,arrayStrictComparison:!1};function S(e,r,u,o,h){let m={...x,...h},f=j(e),l=j(r);f!==l?o(`the first input arg is of a type ${f} but the second is ${l}. Values are - 1st:
|
|
11
11
|
${JSON.stringify(e,null,4)}
|
|
12
12
|
2nd:
|
|
13
13
|
${JSON.stringify(r,null,4)}`):E(r,(y,b,t,s)=>{let c=t.parentType==="object"?b:y,p=t.parentType==="array"&&Array.isArray(t.parent)?t.parent:void 0,{path:a}=t;if(w.has(e,a))if(!m.arrayStrictComparison&&g(c)&&p&&p.length>1){s.now=!0;let i=Array.from(t.path.includes(".")?w.get(e,N(a)):e);if(i.length<p.length)o(`the first array: ${JSON.stringify(i,null,4)}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-deep-contains
|
|
3
3
|
* @fileoverview Like t.same assert on array of objects, where element order doesn't matter.
|
|
4
|
-
* @version 5.2.
|
|
4
|
+
* @version 5.2.4
|
|
5
5
|
* @author Roy Revelt
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-deep-contains/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
"use strict";var astDeepContains=(()=>{var ne=Object.create;var I=Object.defineProperty,oe=Object.defineProperties,ie=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var M=(e,r,o)=>r in e?I(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,w=(e,r)=>{for(var o in r||(r={}))B.call(r,o)&&M(e,o,r[o]);if(R)for(var o of R(r))ae.call(r,o)&&M(e,o,r[o]);return e},W=(e,r)=>oe(e,se(r));var ce=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(o){throw r=0,o}},fe=(e,r)=>{for(var o in r)I(e,o,{get:r[o],enumerable:!0})},F=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of le(r))!B.call(e,c)&&c!==o&&I(e,c,{get:()=>r[c],enumerable:!(a=ie(r,c))||a.enumerable});return e};var pe=(e,r,o)=>(o=e!=null?ne(ue(e)):{},F(r||!e||!e.__esModule?I(o,"default",{value:e,enumerable:!0}):o,e)),ye=e=>F(I({},"__esModule",{value:!0}),e);var X=ce((z,T)=>{(function(e,r){"use strict";typeof T=="object"&&typeof T.exports=="object"?T.exports=r():typeof define=="function"&&define.amd?define([],r):e.objectPath=r()})(z,function(){"use strict";var e=Object.prototype.toString;function r(n,s){return n==null?!1:Object.prototype.hasOwnProperty.call(n,s)}function o(n){if(!n||m(n)&&n.length===0)return!0;if(typeof n!="string"){for(var s in n)if(r(n,s))return!1;return!0}return!1}function a(n){return e.call(n)}function c(n){return typeof n=="object"&&a(n)==="[object Object]"}var m=Array.isArray||function(n){return e.call(n)==="[object Array]"};function l(n){return typeof n=="boolean"||a(n)==="[object Boolean]"}function p(n){var s=parseInt(n);return s.toString()===n?s:n}function b(n){n=n||{};var s=function(u){return Object.keys(s).reduce(function(t,i){return i==="create"||typeof s[i]=="function"&&(t[i]=s[i].bind(s,u)),t},{})},y;n.includeInheritedProps?y=function(){return!0}:y=function(u,t){return typeof t=="number"&&Array.isArray(u)||r(u,t)};function h(u,t){if(y(u,t))return u[t]}var $;n.includeInheritedProps?$=function(u,t){typeof t!="string"&&typeof t!="number"&&(t=String(t));var i=h(u,t);if(t==="__proto__"||t==="prototype"||t==="constructor"&&typeof i=="function")throw new Error("For security reasons, object's magic properties cannot be set");return i}:$=function(u,t){return h(u,t)};function g(u,t,i,d){if(typeof t=="number"&&(t=[t]),!t||t.length===0)return u;if(typeof t=="string")return g(u,t.split(".").map(p),i,d);var v=t[0],A=$(u,v);return t.length===1?((A===void 0||!d)&&(u[v]=i),A):(A===void 0&&(typeof t[1]=="number"?u[v]=[]:u[v]={}),g(u[v],t.slice(1),i,d))}return s.has=function(u,t){if(typeof t=="number"?t=[t]:typeof t=="string"&&(t=t.split(".")),!t||t.length===0)return!!u;for(var i=0;i<t.length;i++){var d=p(t[i]);if(typeof d=="number"&&m(u)&&d<u.length||(n.includeInheritedProps?d in Object(u):r(u,d)))u=u[d];else return!1}return!0},s.ensureExists=function(u,t,i){return g(u,t,i,!0)},s.set=function(u,t,i,d){return g(u,t,i,d)},s.insert=function(u,t,i,d){var v=s.get(u,t);d=~~d,m(v)||(v=[],s.set(u,t,v)),v.splice(d,0,i)},s.empty=function(u,t){if(!o(t)&&u!=null){var i,d;if(i=s.get(u,t)){if(typeof i=="string")return s.set(u,t,"");if(l(i))return s.set(u,t,!1);if(typeof i=="number")return s.set(u,t,0);if(m(i))i.length=0;else if(c(i))for(d in i)y(i,d)&&delete i[d];else return s.set(u,t,null)}}},s.push=function(u,t){var i=s.get(u,t);m(i)||(i=[],s.set(u,t,i)),i.push.apply(i,Array.prototype.slice.call(arguments,2))},s.coalesce=function(u,t,i){for(var d,v=0,A=t.length;v<A;v++)if((d=s.get(u,t[v]))!==void 0)return d;return i},s.get=function(u,t,i){if(typeof t=="number"&&(t=[t]),!t||t.length===0)return u;if(u==null)return i;if(typeof t=="string")return s.get(u,t.split("."),i);var d=p(t[0]),v=$(u,d);return v===void 0?i:t.length===1?v:s.get(u[d],t.slice(1),i)},s.del=function(t,i){if(typeof i=="number"&&(i=[i]),t==null||o(i))return t;if(typeof i=="string")return s.del(t,i.split("."));var d=p(i[0]);if($(t,d),!y(t,d))return t;if(i.length===1)m(t)?t.splice(d,1):delete t[d];else return s.del(t[d],i.slice(1));return t},s}var f=b();return f.create=b,f.withInheritedProps=b({includeInheritedProps:!0}),f})});var Ae={};fe(Ae,{deepContains:()=>re,defaults:()=>te,version:()=>ve});var L=Symbol.for("ast-monkey-traverse.delete"),de=Object.prototype.hasOwnProperty;function k(e){throw new TypeError("ast-monkey-traverse/traverse(): [THROW_ID_02] The first argument must be an acyclic, unaliased tree of arrays, plain objects, and supported primitive values; ".concat(e,"."))}function me(e,r){let o=Number(e);return Number.isInteger(o)&&o>=0&&o<r&&"".concat(o)===e}function H(e){return Array.isArray(e)?new Array(e.length):{}}function K(e,r,o){r==="__proto__"?Object.defineProperty(e,r,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[r]=o}function V(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function U(e,r=!1){if(V(e))return e;typeof e!="object"&&k("encountered an unsupported ".concat(typeof e," value"));let o=e,a=H(o),c=[{source:o,target:a}],m=new WeakSet([o]);for(;c.length;){let l=c.pop(),{source:p,target:b}=l,f=Array.isArray(p);Object.getPrototypeOf(p)!==(f?Array.prototype:Object.prototype)&&k(f?"encountered an array with a custom prototype":"encountered a non-plain or custom-prototype object");for(let n of Reflect.ownKeys(p)){if(f&&n==="length")continue;typeof n!="string"&&k(f?"encountered a symbol-keyed array property":"encountered a symbol-keyed object property"),f&&!me(n,p.length)&&k("encountered the non-index array property ".concat(JSON.stringify(n)));let s=Object.getOwnPropertyDescriptor(p,n);s.enumerable||k(f?"encountered a non-enumerable array index ".concat(n):"encountered a non-enumerable property ".concat(JSON.stringify(n))),!("value"in s)&&!r&&k(f?"encountered an accessor array index ".concat(n):"encountered an accessor property ".concat(JSON.stringify(n)));let y="value"in s?s.value:p[n];if(V(y))K(b,n,y);else if(typeof y=="object"){m.has(y)&&k("encountered a cycle or repeated object reference"),m.add(y);let h=H(y);K(b,n,h),c.push({source:y,target:h})}else k("encountered an unsupported ".concat(typeof y," value"))}}return a}var S=Symbol("deleted snapshot entry");function J(e){let r=w({array:Array.isArray(e),entries:new Map},Array.isArray(e)?{lengths:[{value:e.length,version:0}]}:{}),o=[{source:e,target:r}];for(;o.length;){let a=o.pop(),{source:c,target:m}=a;for(let l of Object.keys(c)){let p=c[l];if(typeof p=="object"&&p!==null){let b=w({array:Array.isArray(p),entries:new Map},Array.isArray(p)?{lengths:[{value:p.length,version:0}]}:{});m.entries.set(l,[{value:b,version:0}]),o.push({source:p,target:b})}else m.entries.set(l,[{value:p,version:0}])}}return r}function Q(e,r){let o=0,a=e.length-1;for(;o<a;){let c=Math.ceil((o+a)/2);e[c].version<=r?o=c:a=c-1}return e[o]}function N(e,r,o){let a=e.entries.get(r);return a?Q(a,o).value:S}function _(e,r){return Q(e.lengths,r).value}function j(e,r,o,a){let c=e.entries.get(r);c?c.push({value:o,version:a}):e.entries.set(r,[{value:S,version:a-1},{value:o,version:a}])}function ge(e,r,o){let a=o-1,c=_(e,a);for(let m=r;m<c-1;m+=1)j(e,"".concat(m),N(e,"".concat(m+1),a),o);c&&j(e,"".concat(c-1),S,o),e.lengths.push({value:Math.max(0,c-1),version:o})}function G(e,r){let o=new WeakMap;function a(c){let m=o.get(c);if(m)return m;let l=c.array?new Array(_(c,r)):{},p={defineProperty:()=>!0,deleteProperty:()=>!0,get:(f,n,s)=>{if(c.array&&n==="length")return _(c,r);if(typeof n=="string"){let y=N(c,n,r);if(y!==S)return typeof y=="object"&&y!==null?a(y):y}return Reflect.get(f,n,s)},getOwnPropertyDescriptor:(f,n)=>{if(c.array&&n==="length")return Reflect.getOwnPropertyDescriptor(f,n);if(typeof n=="string"){let s=N(c,n,r);return s===S?void 0:{configurable:!0,enumerable:!0,value:typeof s=="object"&&s!==null?a(s):s,writable:!0}}},has:(f,n)=>typeof n=="string"&&N(c,n,r)!==S||Reflect.has(f,n),ownKeys:()=>{let f=[...c.entries].filter(([n])=>N(c,n,r)!==S).map(([n])=>n);return c.array?[...f,"length"]:f},set:()=>!0,setPrototypeOf:()=>!0},b=new Proxy(l,p);return o.set(c,b),b}return a(e)}function Y(e){let r=[],o=e;for(;o;)r.push(o.segment),o=o.parent;return r.reverse()}function be(e){let r="";for(let o of e)r=r?"".concat(r,".").concat(o):o;return r}function q(e,r){if(typeof r!="function")throw new TypeError("ast-monkey-traverse/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ".concat(typeof r,"."));let o=U(e);if(typeof o!="object"||o===null)return o;let a=0,c={now:!1},m=[{container:o,depth:0,index:0,keys:Array.isArray(o)?[]:Object.keys(o),parentKey:null}];for(;m.length&&!c.now;){let l=m[m.length-1],p=Array.isArray(l.container)?l.container:void 0,b=!!p,f;if(p){if(l.index>=p.length){m.pop();continue}if(!de.call(p,l.index)){l.index+=1;continue}f="".concat(l.index)}else{if(l.index>=l.keys.length){m.pop();continue}f=l.keys[l.index]}let n=l.container[f],s={parent:l.pathNode,segment:f},y=l.depth===0&&!b?f:l.topmostKey,h,$=a,g,u,t;if(l.depth<100)g=l.path?"".concat(l.path,".").concat(f):f,u=l.pathSegments?[...l.pathSegments,f]:[f],t=w({depth:l.depth,path:g,pathSegments:u,get parent(){return l.snapshot||(l.snapshot=J(l.container)),h||(h=G(l.snapshot,$)),h},parentType:b?"array":"object",parentKey:l.parentKey},y===void 0?{}:{topmostKey:y});else{let x,E;t=w({depth:l.depth,get path(){return x||(x=Y(s)),E!=null||(E=be(x)),E},get pathSegments(){return x||(x=Y(s)),x},get parent(){return l.snapshot||(l.snapshot=J(l.container)),h||(h=G(l.snapshot,$)),h},parentType:b?"array":"object",parentKey:l.parentKey},y===void 0?{}:{topmostKey:y})}let i=r(b?n:f,b?void 0:n,t,c),d=i===L,v=typeof i=="object"&&i!==null,A=v&&typeof n=="object"&&n!==null&&i===n&&!!l.snapshot,O=i===L?n:i,P;!d&&!v&&!V(i)&&k("encountered an unsupported ".concat(typeof i," value")),!d&&v&&(i!==n||A)&&(O=U(i,!0),l.snapshot&&(P=J(O))),d?p?(p.splice(l.index,1),a+=1,l.snapshot&&ge(l.snapshot,l.index,a)):(delete l.container[f],a+=1,l.snapshot&&j(l.snapshot,f,S,a),l.index+=1):((!Object.is(O,n)||A)&&(K(l.container,f,O),a+=1,l.snapshot&&j(l.snapshot,f,P===void 0?O:P,a)),l.index+=1,!c.now&&typeof O=="object"&&O!==null&&m.push(w(w(w(W(w({container:O,depth:l.depth+1,index:0,keys:Array.isArray(O)?[]:Object.keys(O),parentKey:f},g===void 0?{}:{path:g}),{pathNode:s}),u===void 0?{}:{pathSegments:u}),P?{snapshot:P}:{}),y===void 0?{}:{topmostKey:y})))}return o}var D=pe(X(),1);var Z="5.2.3";var ve=Z;function $e(e){if(e.includes(".")){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function C(e){if(e===null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r===null||r===Object.prototype}function ee(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="number"&&Number.isNaN(e)?"nan":typeof e!="object"?typeof e:Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var te={skipContainers:!0,arrayStrictComparison:!1};function re(e,r,o,a,c){let m=w(w({},te),c),l=ee(e),p=ee(r);l!==p?a("the first input arg is of a type ".concat(l," but the second is ").concat(p,". Values are - 1st:\n").concat(JSON.stringify(e,null,4),"\n2nd:\n").concat(JSON.stringify(r,null,4))):q(r,(b,f,n,s)=>{let y=n.parentType==="object"?f:b,h=n.parentType==="array"&&Array.isArray(n.parent)?n.parent:void 0,{path:$}=n;if(D.default.has(e,$))if(!m.arrayStrictComparison&&C(y)&&h&&h.length>1){s.now=!0;let g=Array.from(n.path.includes(".")?D.default.get(e,$e($)):e);if(g.length<h.length)a("the first array: ".concat(JSON.stringify(g,null,4),"\nhas less objects than array we're matching against, ").concat(JSON.stringify(h,null,4)));else{let u=Array.from(h),t=ke(u,g);for(let[i,d]of t)re(g[d],u[i],o,a,m)}}else{let g=D.default.get(e,$);(!m.skipContainers||!C(g)&&!Array.isArray(g))&&o(g,y,$)}else a("the first input: ".concat(JSON.stringify(e,null,4),'\ndoes not have the path "').concat($,'", we were looking, would it contain a value ').concat(JSON.stringify(y,null,0),"."));return y})}var we=Object.prototype.hasOwnProperty;function Oe(e,r){if(!C(e)||!C(r))return 0;let o=0;for(let a of Object.keys(e))we.call(r,a)&&(o+=r[a]===e[a]?6:1);return o}function ke(e,r){let o=e.length,a=r.length,c=e.map(n=>r.map(s=>Oe(n,s))),m=new Array(o+1).fill(0),l=new Array(a+1).fill(0),p=new Array(a+1).fill(0),b=new Array(a+1).fill(0);for(let n=1;n<=o;n++){p[0]=n;let s=0,y=new Array(a+1).fill(Number.POSITIVE_INFINITY),h=new Array(a+1).fill(!1);do{h[s]=!0;let $=p[s],g=Number.POSITIVE_INFINITY,u=0;for(let t=1;t<=a;t++){if(h[t])continue;let i=-c[$-1][t-1]-m[$]-l[t];i<y[t]&&(y[t]=i,b[t]=s),y[t]<g&&(g=y[t],u=t)}for(let t=0;t<=a;t++)h[t]?(m[p[t]]+=g,l[t]-=g):y[t]-=g;s=u}while(p[s]!==0);do{let $=b[s];p[s]=p[$],s=$}while(s!==0)}let f=new Array(o);for(let n=1;n<=a;n++)p[n]>0&&(f[p[n]-1]=n-1);return f.map((n,s)=>[s,n])}return ye(Ae);})();
|
|
10
|
+
"use strict";var astDeepContains=(()=>{var ne=Object.create;var I=Object.defineProperty,oe=Object.defineProperties,ie=Object.getOwnPropertyDescriptor,se=Object.getOwnPropertyDescriptors,le=Object.getOwnPropertyNames,R=Object.getOwnPropertySymbols,ue=Object.getPrototypeOf,B=Object.prototype.hasOwnProperty,ae=Object.prototype.propertyIsEnumerable;var M=(e,r,o)=>r in e?I(e,r,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[r]=o,w=(e,r)=>{for(var o in r||(r={}))B.call(r,o)&&M(e,o,r[o]);if(R)for(var o of R(r))ae.call(r,o)&&M(e,o,r[o]);return e},W=(e,r)=>oe(e,se(r));var ce=(e,r)=>()=>{try{return r||e((r={exports:{}}).exports,r),r.exports}catch(o){throw r=0,o}},fe=(e,r)=>{for(var o in r)I(e,o,{get:r[o],enumerable:!0})},F=(e,r,o,a)=>{if(r&&typeof r=="object"||typeof r=="function")for(let c of le(r))!B.call(e,c)&&c!==o&&I(e,c,{get:()=>r[c],enumerable:!(a=ie(r,c))||a.enumerable});return e};var pe=(e,r,o)=>(o=e!=null?ne(ue(e)):{},F(r||!e||!e.__esModule?I(o,"default",{value:e,enumerable:!0}):o,e)),ye=e=>F(I({},"__esModule",{value:!0}),e);var X=ce((z,T)=>{(function(e,r){"use strict";typeof T=="object"&&typeof T.exports=="object"?T.exports=r():typeof define=="function"&&define.amd?define([],r):e.objectPath=r()})(z,function(){"use strict";var e=Object.prototype.toString;function r(n,s){return n==null?!1:Object.prototype.hasOwnProperty.call(n,s)}function o(n){if(!n||m(n)&&n.length===0)return!0;if(typeof n!="string"){for(var s in n)if(r(n,s))return!1;return!0}return!1}function a(n){return e.call(n)}function c(n){return typeof n=="object"&&a(n)==="[object Object]"}var m=Array.isArray||function(n){return e.call(n)==="[object Array]"};function l(n){return typeof n=="boolean"||a(n)==="[object Boolean]"}function p(n){var s=parseInt(n);return s.toString()===n?s:n}function b(n){n=n||{};var s=function(u){return Object.keys(s).reduce(function(t,i){return i==="create"||typeof s[i]=="function"&&(t[i]=s[i].bind(s,u)),t},{})},y;n.includeInheritedProps?y=function(){return!0}:y=function(u,t){return typeof t=="number"&&Array.isArray(u)||r(u,t)};function h(u,t){if(y(u,t))return u[t]}var $;n.includeInheritedProps?$=function(u,t){typeof t!="string"&&typeof t!="number"&&(t=String(t));var i=h(u,t);if(t==="__proto__"||t==="prototype"||t==="constructor"&&typeof i=="function")throw new Error("For security reasons, object's magic properties cannot be set");return i}:$=function(u,t){return h(u,t)};function g(u,t,i,d){if(typeof t=="number"&&(t=[t]),!t||t.length===0)return u;if(typeof t=="string")return g(u,t.split(".").map(p),i,d);var v=t[0],A=$(u,v);return t.length===1?((A===void 0||!d)&&(u[v]=i),A):(A===void 0&&(typeof t[1]=="number"?u[v]=[]:u[v]={}),g(u[v],t.slice(1),i,d))}return s.has=function(u,t){if(typeof t=="number"?t=[t]:typeof t=="string"&&(t=t.split(".")),!t||t.length===0)return!!u;for(var i=0;i<t.length;i++){var d=p(t[i]);if(typeof d=="number"&&m(u)&&d<u.length||(n.includeInheritedProps?d in Object(u):r(u,d)))u=u[d];else return!1}return!0},s.ensureExists=function(u,t,i){return g(u,t,i,!0)},s.set=function(u,t,i,d){return g(u,t,i,d)},s.insert=function(u,t,i,d){var v=s.get(u,t);d=~~d,m(v)||(v=[],s.set(u,t,v)),v.splice(d,0,i)},s.empty=function(u,t){if(!o(t)&&u!=null){var i,d;if(i=s.get(u,t)){if(typeof i=="string")return s.set(u,t,"");if(l(i))return s.set(u,t,!1);if(typeof i=="number")return s.set(u,t,0);if(m(i))i.length=0;else if(c(i))for(d in i)y(i,d)&&delete i[d];else return s.set(u,t,null)}}},s.push=function(u,t){var i=s.get(u,t);m(i)||(i=[],s.set(u,t,i)),i.push.apply(i,Array.prototype.slice.call(arguments,2))},s.coalesce=function(u,t,i){for(var d,v=0,A=t.length;v<A;v++)if((d=s.get(u,t[v]))!==void 0)return d;return i},s.get=function(u,t,i){if(typeof t=="number"&&(t=[t]),!t||t.length===0)return u;if(u==null)return i;if(typeof t=="string")return s.get(u,t.split("."),i);var d=p(t[0]),v=$(u,d);return v===void 0?i:t.length===1?v:s.get(u[d],t.slice(1),i)},s.del=function(t,i){if(typeof i=="number"&&(i=[i]),t==null||o(i))return t;if(typeof i=="string")return s.del(t,i.split("."));var d=p(i[0]);if($(t,d),!y(t,d))return t;if(i.length===1)m(t)?t.splice(d,1):delete t[d];else return s.del(t[d],i.slice(1));return t},s}var f=b();return f.create=b,f.withInheritedProps=b({includeInheritedProps:!0}),f})});var Ae={};fe(Ae,{deepContains:()=>re,defaults:()=>te,version:()=>ve});var L=Symbol.for("ast-monkey-traverse.delete"),de=Object.prototype.hasOwnProperty;function k(e){throw new TypeError("ast-monkey-traverse/traverse(): [THROW_ID_02] The first argument must be an acyclic, unaliased tree of arrays, plain objects, and supported primitive values; ".concat(e,"."))}function me(e,r){let o=Number(e);return Number.isInteger(o)&&o>=0&&o<r&&"".concat(o)===e}function H(e){return Array.isArray(e)?new Array(e.length):{}}function K(e,r,o){r==="__proto__"?Object.defineProperty(e,r,{configurable:!0,enumerable:!0,value:o,writable:!0}):e[r]=o}function V(e){return e==null||typeof e=="string"||typeof e=="number"||typeof e=="boolean"}function U(e,r=!1){if(V(e))return e;typeof e!="object"&&k("encountered an unsupported ".concat(typeof e," value"));let o=e,a=H(o),c=[{source:o,target:a}],m=new WeakSet([o]);for(;c.length;){let l=c.pop(),{source:p,target:b}=l,f=Array.isArray(p);Object.getPrototypeOf(p)!==(f?Array.prototype:Object.prototype)&&k(f?"encountered an array with a custom prototype":"encountered a non-plain or custom-prototype object");for(let n of Reflect.ownKeys(p)){if(f&&n==="length")continue;typeof n!="string"&&k(f?"encountered a symbol-keyed array property":"encountered a symbol-keyed object property"),f&&!me(n,p.length)&&k("encountered the non-index array property ".concat(JSON.stringify(n)));let s=Object.getOwnPropertyDescriptor(p,n);s.enumerable||k(f?"encountered a non-enumerable array index ".concat(n):"encountered a non-enumerable property ".concat(JSON.stringify(n))),!("value"in s)&&!r&&k(f?"encountered an accessor array index ".concat(n):"encountered an accessor property ".concat(JSON.stringify(n)));let y="value"in s?s.value:p[n];if(V(y))K(b,n,y);else if(typeof y=="object"){m.has(y)&&k("encountered a cycle or repeated object reference"),m.add(y);let h=H(y);K(b,n,h),c.push({source:y,target:h})}else k("encountered an unsupported ".concat(typeof y," value"))}}return a}var S=Symbol("deleted snapshot entry");function J(e){let r=w({array:Array.isArray(e),entries:new Map},Array.isArray(e)?{lengths:[{value:e.length,version:0}]}:{}),o=[{source:e,target:r}];for(;o.length;){let a=o.pop(),{source:c,target:m}=a;for(let l of Object.keys(c)){let p=c[l];if(typeof p=="object"&&p!==null){let b=w({array:Array.isArray(p),entries:new Map},Array.isArray(p)?{lengths:[{value:p.length,version:0}]}:{});m.entries.set(l,[{value:b,version:0}]),o.push({source:p,target:b})}else m.entries.set(l,[{value:p,version:0}])}}return r}function Q(e,r){let o=0,a=e.length-1;for(;o<a;){let c=Math.ceil((o+a)/2);e[c].version<=r?o=c:a=c-1}return e[o]}function N(e,r,o){let a=e.entries.get(r);return a?Q(a,o).value:S}function _(e,r){return Q(e.lengths,r).value}function j(e,r,o,a){let c=e.entries.get(r);c?c.push({value:o,version:a}):e.entries.set(r,[{value:S,version:a-1},{value:o,version:a}])}function ge(e,r,o){let a=o-1,c=_(e,a);for(let m=r;m<c-1;m+=1)j(e,"".concat(m),N(e,"".concat(m+1),a),o);c&&j(e,"".concat(c-1),S,o),e.lengths.push({value:Math.max(0,c-1),version:o})}function G(e,r){let o=new WeakMap;function a(c){let m=o.get(c);if(m)return m;let l=c.array?new Array(_(c,r)):{},p={defineProperty:()=>!0,deleteProperty:()=>!0,get:(f,n,s)=>{if(c.array&&n==="length")return _(c,r);if(typeof n=="string"){let y=N(c,n,r);if(y!==S)return typeof y=="object"&&y!==null?a(y):y}return Reflect.get(f,n,s)},getOwnPropertyDescriptor:(f,n)=>{if(c.array&&n==="length")return Reflect.getOwnPropertyDescriptor(f,n);if(typeof n=="string"){let s=N(c,n,r);return s===S?void 0:{configurable:!0,enumerable:!0,value:typeof s=="object"&&s!==null?a(s):s,writable:!0}}},has:(f,n)=>typeof n=="string"&&N(c,n,r)!==S||Reflect.has(f,n),ownKeys:()=>{let f=[...c.entries].filter(([n])=>N(c,n,r)!==S).map(([n])=>n);return c.array?[...f,"length"]:f},set:()=>!0,setPrototypeOf:()=>!0},b=new Proxy(l,p);return o.set(c,b),b}return a(e)}function Y(e){let r=[],o=e;for(;o;)r.push(o.segment),o=o.parent;return r.reverse()}function be(e){let r="";for(let o of e)r=r?"".concat(r,".").concat(o):o;return r}function q(e,r){if(typeof r!="function")throw new TypeError("ast-monkey-traverse/traverse(): [THROW_ID_01] The second argument must be a callback function. It was ".concat(typeof r,"."));let o=U(e);if(typeof o!="object"||o===null)return o;let a=0,c={now:!1},m=[{container:o,depth:0,index:0,keys:Array.isArray(o)?[]:Object.keys(o),parentKey:null}];for(;m.length&&!c.now;){let l=m[m.length-1],p=Array.isArray(l.container)?l.container:void 0,b=!!p,f;if(p){if(l.index>=p.length){m.pop();continue}if(!de.call(p,l.index)){l.index+=1;continue}f="".concat(l.index)}else{if(l.index>=l.keys.length){m.pop();continue}f=l.keys[l.index]}let n=l.container[f],s={parent:l.pathNode,segment:f},y=l.depth===0&&!b?f:l.topmostKey,h,$=a,g,u,t;if(l.depth<100)g=l.path?"".concat(l.path,".").concat(f):f,u=l.pathSegments?[...l.pathSegments,f]:[f],t=w({depth:l.depth,path:g,pathSegments:u,get parent(){return l.snapshot||(l.snapshot=J(l.container)),h||(h=G(l.snapshot,$)),h},parentType:b?"array":"object",parentKey:l.parentKey},y===void 0?{}:{topmostKey:y});else{let x,E;t=w({depth:l.depth,get path(){return x||(x=Y(s)),E!=null||(E=be(x)),E},get pathSegments(){return x||(x=Y(s)),x},get parent(){return l.snapshot||(l.snapshot=J(l.container)),h||(h=G(l.snapshot,$)),h},parentType:b?"array":"object",parentKey:l.parentKey},y===void 0?{}:{topmostKey:y})}let i=r(b?n:f,b?void 0:n,t,c),d=i===L,v=typeof i=="object"&&i!==null,A=v&&typeof n=="object"&&n!==null&&i===n&&!!l.snapshot,O=i===L?n:i,P;!d&&!v&&!V(i)&&k("encountered an unsupported ".concat(typeof i," value")),!d&&v&&(i!==n||A)&&(O=U(i,!0),l.snapshot&&(P=J(O))),d?p?(p.splice(l.index,1),a+=1,l.snapshot&&ge(l.snapshot,l.index,a)):(delete l.container[f],a+=1,l.snapshot&&j(l.snapshot,f,S,a),l.index+=1):((!Object.is(O,n)||A)&&(K(l.container,f,O),a+=1,l.snapshot&&j(l.snapshot,f,P===void 0?O:P,a)),l.index+=1,!c.now&&typeof O=="object"&&O!==null&&m.push(w(w(w(W(w({container:O,depth:l.depth+1,index:0,keys:Array.isArray(O)?[]:Object.keys(O),parentKey:f},g===void 0?{}:{path:g}),{pathNode:s}),u===void 0?{}:{pathSegments:u}),P?{snapshot:P}:{}),y===void 0?{}:{topmostKey:y})))}return o}var D=pe(X(),1);var Z="5.2.4";var ve=Z;function $e(e){if(e.includes(".")){for(let r=e.length;r--;)if(e[r]===".")return e.slice(0,r)}return e}function C(e){if(e===null||typeof e!="object")return!1;let r=Object.getPrototypeOf(e);return r===null||r===Object.prototype}function ee(e){return e===null?"null":Array.isArray(e)?"array":typeof e=="number"&&Number.isNaN(e)?"nan":typeof e!="object"?typeof e:Object.prototype.toString.call(e).slice(8,-1).toLowerCase()}var te={skipContainers:!0,arrayStrictComparison:!1};function re(e,r,o,a,c){let m=w(w({},te),c),l=ee(e),p=ee(r);l!==p?a("the first input arg is of a type ".concat(l," but the second is ").concat(p,". Values are - 1st:\n").concat(JSON.stringify(e,null,4),"\n2nd:\n").concat(JSON.stringify(r,null,4))):q(r,(b,f,n,s)=>{let y=n.parentType==="object"?f:b,h=n.parentType==="array"&&Array.isArray(n.parent)?n.parent:void 0,{path:$}=n;if(D.default.has(e,$))if(!m.arrayStrictComparison&&C(y)&&h&&h.length>1){s.now=!0;let g=Array.from(n.path.includes(".")?D.default.get(e,$e($)):e);if(g.length<h.length)a("the first array: ".concat(JSON.stringify(g,null,4),"\nhas less objects than array we're matching against, ").concat(JSON.stringify(h,null,4)));else{let u=Array.from(h),t=ke(u,g);for(let[i,d]of t)re(g[d],u[i],o,a,m)}}else{let g=D.default.get(e,$);(!m.skipContainers||!C(g)&&!Array.isArray(g))&&o(g,y,$)}else a("the first input: ".concat(JSON.stringify(e,null,4),'\ndoes not have the path "').concat($,'", we were looking, would it contain a value ').concat(JSON.stringify(y,null,0),"."));return y})}var we=Object.prototype.hasOwnProperty;function Oe(e,r){if(!C(e)||!C(r))return 0;let o=0;for(let a of Object.keys(e))we.call(r,a)&&(o+=r[a]===e[a]?6:1);return o}function ke(e,r){let o=e.length,a=r.length,c=e.map(n=>r.map(s=>Oe(n,s))),m=new Array(o+1).fill(0),l=new Array(a+1).fill(0),p=new Array(a+1).fill(0),b=new Array(a+1).fill(0);for(let n=1;n<=o;n++){p[0]=n;let s=0,y=new Array(a+1).fill(Number.POSITIVE_INFINITY),h=new Array(a+1).fill(!1);do{h[s]=!0;let $=p[s],g=Number.POSITIVE_INFINITY,u=0;for(let t=1;t<=a;t++){if(h[t])continue;let i=-c[$-1][t-1]-m[$]-l[t];i<y[t]&&(y[t]=i,b[t]=s),y[t]<g&&(g=y[t],u=t)}for(let t=0;t<=a;t++)h[t]?(m[p[t]]+=g,l[t]-=g):y[t]-=g;s=u}while(p[s]!==0);do{let $=b[s];p[s]=p[$],s=$}while(s!==0)}let f=new Array(o);for(let n=1;n<=a;n++)p[n]>0&&(f[p[n]-1]=n-1);return f.map((n,s)=>[s,n])}return ye(Ae);})();
|
|
11
11
|
/**
|
|
12
12
|
* @name ast-monkey-traverse
|
|
13
13
|
* @fileoverview Utility library to traverse AST
|
|
14
|
-
* @version 4.3.
|
|
14
|
+
* @version 4.3.1
|
|
15
15
|
* @author Roy Revelt
|
|
16
16
|
* @license MIT
|
|
17
17
|
* {@link https://codsen.com/os/ast-monkey-traverse/}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-deep-contains",
|
|
3
|
-
"version": "5.2.
|
|
3
|
+
"version": "5.2.4",
|
|
4
4
|
"description": "Like t.same assert on array of objects, where element order doesn't matter.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -82,7 +82,7 @@
|
|
|
82
82
|
"various": {}
|
|
83
83
|
},
|
|
84
84
|
"dependencies": {
|
|
85
|
-
"ast-monkey-traverse": "^4.3.
|
|
85
|
+
"ast-monkey-traverse": "^4.3.1",
|
|
86
86
|
"object-path": "^0.11.8"
|
|
87
87
|
},
|
|
88
88
|
"engines": {
|