ast-deep-contains 4.0.6 → 4.0.7

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.
@@ -1,7 +1,7 @@
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 4.0.6
4
+ * @version 4.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-deep-contains/}
@@ -11,7 +11,7 @@ import objectPath from 'object-path';
11
11
  import { traverse } from 'ast-monkey-traverse';
12
12
  import is from '@sindresorhus/is';
13
13
 
14
- var version$1 = "4.0.6";
14
+ var version$1 = "4.0.7";
15
15
 
16
16
  const version = version$1;
17
17
  function goUp(pathStr) {
@@ -1,7 +1,7 @@
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 4.0.6
4
+ * @version 4.0.7
5
5
  * @author Roy Revelt, Codsen Ltd
6
6
  * @license MIT
7
7
  * {@link https://codsen.com/os/ast-deep-contains/}
@@ -11,7 +11,7 @@
11
11
  /**
12
12
  * @name ast-monkey-util
13
13
  * @fileoverview Utility library of AST helper functions
14
- * @version 2.0.6
14
+ * @version 2.0.7
15
15
  * @author Roy Revelt, Codsen Ltd
16
16
  * @license MIT
17
17
  * {@link https://codsen.com/os/ast-monkey-util/}
@@ -19,8 +19,8 @@
19
19
  /**
20
20
  * @name ast-monkey-traverse
21
21
  * @fileoverview Utility library to traverse AST
22
- * @version 3.0.6
22
+ * @version 3.0.7
23
23
  * @author Roy Revelt, Codsen Ltd
24
24
  * @license MIT
25
25
  * {@link https://codsen.com/os/ast-monkey-traverse/}
26
- */var h={exports:{}};!function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];const n=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement",...r];const a=["null","undefined","string","number","bigint","boolean","symbol"];function o(t){return e=>typeof e===t}const{toString:i}=Object.prototype,u=t=>{const e=i.call(t).slice(8,-1);return/HTML\w+Element/.test(e)&&s.domElement(t)?"HTMLElement":n.includes(e)?e:void 0},c=t=>e=>u(e)===t;function s(t){if(null===t)return"null";switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol"}if(s.observable(t))return"Observable";if(s.array(t))return"Array";if(s.buffer(t))return"Buffer";const e=u(t);if(e)return e;if(t instanceof String||t instanceof Boolean||t instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}s.undefined=o("undefined"),s.string=o("string");const l=o("number");s.number=t=>l(t)&&!s.nan(t),s.bigint=o("bigint"),s.function_=o("function"),s.null_=t=>null===t,s.class_=t=>s.function_(t)&&t.toString().startsWith("class "),s.boolean=t=>!0===t||!1===t,s.symbol=o("symbol"),s.numericString=t=>s.string(t)&&!s.emptyStringOrWhitespace(t)&&!Number.isNaN(Number(t)),s.array=(t,e)=>!!Array.isArray(t)&&(!s.function_(e)||t.every(e)),s.buffer=t=>{var e,r,n,a;return null!==(a=null===(n=null===(r=null===(e=t)||void 0===e?void 0:e.constructor)||void 0===r?void 0:r.isBuffer)||void 0===n?void 0:n.call(r,t))&&void 0!==a&&a},s.nullOrUndefined=t=>s.null_(t)||s.undefined(t),s.object=t=>!s.null_(t)&&("object"==typeof t||s.function_(t)),s.iterable=t=>{var e;return s.function_(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])},s.asyncIterable=t=>{var e;return s.function_(null===(e=t)||void 0===e?void 0:e[Symbol.asyncIterator])},s.generator=t=>s.iterable(t)&&s.function_(t.next)&&s.function_(t.throw),s.asyncGenerator=t=>s.asyncIterable(t)&&s.function_(t.next)&&s.function_(t.throw),s.nativePromise=t=>c("Promise")(t);s.promise=t=>s.nativePromise(t)||(t=>{var e,r;return s.function_(null===(e=t)||void 0===e?void 0:e.then)&&s.function_(null===(r=t)||void 0===r?void 0:r.catch)})(t),s.generatorFunction=c("GeneratorFunction"),s.asyncGeneratorFunction=t=>"AsyncGeneratorFunction"===u(t),s.asyncFunction=t=>"AsyncFunction"===u(t),s.boundFunction=t=>s.function_(t)&&!t.hasOwnProperty("prototype"),s.regExp=c("RegExp"),s.date=c("Date"),s.error=c("Error"),s.map=t=>c("Map")(t),s.set=t=>c("Set")(t),s.weakMap=t=>c("WeakMap")(t),s.weakSet=t=>c("WeakSet")(t),s.int8Array=c("Int8Array"),s.uint8Array=c("Uint8Array"),s.uint8ClampedArray=c("Uint8ClampedArray"),s.int16Array=c("Int16Array"),s.uint16Array=c("Uint16Array"),s.int32Array=c("Int32Array"),s.uint32Array=c("Uint32Array"),s.float32Array=c("Float32Array"),s.float64Array=c("Float64Array"),s.bigInt64Array=c("BigInt64Array"),s.bigUint64Array=c("BigUint64Array"),s.arrayBuffer=c("ArrayBuffer"),s.sharedArrayBuffer=c("SharedArrayBuffer"),s.dataView=c("DataView"),s.directInstanceOf=(t,e)=>Object.getPrototypeOf(t)===e.prototype,s.urlInstance=t=>c("URL")(t),s.urlString=t=>{if(!s.string(t))return!1;try{return new URL(t),!0}catch(t){return!1}},s.truthy=t=>Boolean(t),s.falsy=t=>!t,s.nan=t=>Number.isNaN(t),s.primitive=t=>s.null_(t)||a.includes(typeof t),s.integer=t=>Number.isInteger(t),s.safeInteger=t=>Number.isSafeInteger(t),s.plainObject=t=>{if("[object Object]"!==i.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.getPrototypeOf({})},s.typedArray=t=>{return e=u(t),r.includes(e);var e};s.arrayLike=t=>!s.nullOrUndefined(t)&&!s.function_(t)&&(t=>s.safeInteger(t)&&t>=0)(t.length),s.inRange=(t,e)=>{if(s.number(e))return t>=Math.min(0,e)&&t<=Math.max(e,0);if(s.array(e)&&2===e.length)return t>=Math.min(...e)&&t<=Math.max(...e);throw new TypeError(`Invalid range: ${JSON.stringify(e)}`)};const f=["innerHTML","ownerDocument","style","attributes","nodeValue"];s.domElement=t=>s.object(t)&&1===t.nodeType&&s.string(t.nodeName)&&!s.plainObject(t)&&f.every((e=>e in t)),s.observable=t=>{var e,r,n,a;return!!t&&(t===(null===(r=(e=t)[Symbol.observable])||void 0===r?void 0:r.call(e))||t===(null===(a=(n=t)["@@observable"])||void 0===a?void 0:a.call(n)))},s.nodeStream=t=>s.object(t)&&s.function_(t.pipe)&&!s.observable(t),s.infinite=t=>t===1/0||t===-1/0;const y=t=>e=>s.integer(e)&&Math.abs(e%2)===t;s.evenInteger=y(0),s.oddInteger=y(1),s.emptyArray=t=>s.array(t)&&0===t.length,s.nonEmptyArray=t=>s.array(t)&&t.length>0,s.emptyString=t=>s.string(t)&&0===t.length,s.nonEmptyString=t=>s.string(t)&&t.length>0;s.emptyStringOrWhitespace=t=>s.emptyString(t)||(t=>s.string(t)&&!/\S/.test(t))(t),s.emptyObject=t=>s.object(t)&&!s.map(t)&&!s.set(t)&&0===Object.keys(t).length,s.nonEmptyObject=t=>s.object(t)&&!s.map(t)&&!s.set(t)&&Object.keys(t).length>0,s.emptySet=t=>s.set(t)&&0===t.size,s.nonEmptySet=t=>s.set(t)&&t.size>0,s.emptyMap=t=>s.map(t)&&0===t.size,s.nonEmptyMap=t=>s.map(t)&&t.size>0,s.propertyKey=t=>s.any([s.string,s.number,s.symbol],t),s.formData=t=>c("FormData")(t),s.urlSearchParams=t=>c("URLSearchParams")(t);const p=(t,e,r)=>{if(!s.function_(e))throw new TypeError(`Invalid predicate: ${JSON.stringify(e)}`);if(0===r.length)throw new TypeError("Invalid number of values");return t.call(r,e)};s.any=(t,...e)=>(s.array(t)?t:[t]).some((t=>p(Array.prototype.some,t,e))),s.all=(t,...e)=>p(Array.prototype.every,t,e);const b=(t,e,r,n={})=>{if(!t){const{multipleValues:t}=n,a=t?`received values of types ${[...new Set(r.map((t=>`\`${s(t)}\``)))].join(", ")}`:`received value of type \`${s(r)}\``;throw new TypeError(`Expected value which is \`${e}\`, ${a}.`)}};e.assert={undefined:t=>b(s.undefined(t),"undefined",t),string:t=>b(s.string(t),"string",t),number:t=>b(s.number(t),"number",t),bigint:t=>b(s.bigint(t),"bigint",t),function_:t=>b(s.function_(t),"Function",t),null_:t=>b(s.null_(t),"null",t),class_:t=>b(s.class_(t),"Class",t),boolean:t=>b(s.boolean(t),"boolean",t),symbol:t=>b(s.symbol(t),"symbol",t),numericString:t=>b(s.numericString(t),"string with a number",t),array:(t,e)=>{b(s.array(t),"Array",t),e&&t.forEach(e)},buffer:t=>b(s.buffer(t),"Buffer",t),nullOrUndefined:t=>b(s.nullOrUndefined(t),"null or undefined",t),object:t=>b(s.object(t),"Object",t),iterable:t=>b(s.iterable(t),"Iterable",t),asyncIterable:t=>b(s.asyncIterable(t),"AsyncIterable",t),generator:t=>b(s.generator(t),"Generator",t),asyncGenerator:t=>b(s.asyncGenerator(t),"AsyncGenerator",t),nativePromise:t=>b(s.nativePromise(t),"native Promise",t),promise:t=>b(s.promise(t),"Promise",t),generatorFunction:t=>b(s.generatorFunction(t),"GeneratorFunction",t),asyncGeneratorFunction:t=>b(s.asyncGeneratorFunction(t),"AsyncGeneratorFunction",t),asyncFunction:t=>b(s.asyncFunction(t),"AsyncFunction",t),boundFunction:t=>b(s.boundFunction(t),"Function",t),regExp:t=>b(s.regExp(t),"RegExp",t),date:t=>b(s.date(t),"Date",t),error:t=>b(s.error(t),"Error",t),map:t=>b(s.map(t),"Map",t),set:t=>b(s.set(t),"Set",t),weakMap:t=>b(s.weakMap(t),"WeakMap",t),weakSet:t=>b(s.weakSet(t),"WeakSet",t),int8Array:t=>b(s.int8Array(t),"Int8Array",t),uint8Array:t=>b(s.uint8Array(t),"Uint8Array",t),uint8ClampedArray:t=>b(s.uint8ClampedArray(t),"Uint8ClampedArray",t),int16Array:t=>b(s.int16Array(t),"Int16Array",t),uint16Array:t=>b(s.uint16Array(t),"Uint16Array",t),int32Array:t=>b(s.int32Array(t),"Int32Array",t),uint32Array:t=>b(s.uint32Array(t),"Uint32Array",t),float32Array:t=>b(s.float32Array(t),"Float32Array",t),float64Array:t=>b(s.float64Array(t),"Float64Array",t),bigInt64Array:t=>b(s.bigInt64Array(t),"BigInt64Array",t),bigUint64Array:t=>b(s.bigUint64Array(t),"BigUint64Array",t),arrayBuffer:t=>b(s.arrayBuffer(t),"ArrayBuffer",t),sharedArrayBuffer:t=>b(s.sharedArrayBuffer(t),"SharedArrayBuffer",t),dataView:t=>b(s.dataView(t),"DataView",t),urlInstance:t=>b(s.urlInstance(t),"URL",t),urlString:t=>b(s.urlString(t),"string with a URL",t),truthy:t=>b(s.truthy(t),"truthy",t),falsy:t=>b(s.falsy(t),"falsy",t),nan:t=>b(s.nan(t),"NaN",t),primitive:t=>b(s.primitive(t),"primitive",t),integer:t=>b(s.integer(t),"integer",t),safeInteger:t=>b(s.safeInteger(t),"integer",t),plainObject:t=>b(s.plainObject(t),"plain object",t),typedArray:t=>b(s.typedArray(t),"TypedArray",t),arrayLike:t=>b(s.arrayLike(t),"array-like",t),domElement:t=>b(s.domElement(t),"HTMLElement",t),observable:t=>b(s.observable(t),"Observable",t),nodeStream:t=>b(s.nodeStream(t),"Node.js Stream",t),infinite:t=>b(s.infinite(t),"infinite number",t),emptyArray:t=>b(s.emptyArray(t),"empty array",t),nonEmptyArray:t=>b(s.nonEmptyArray(t),"non-empty array",t),emptyString:t=>b(s.emptyString(t),"empty string",t),nonEmptyString:t=>b(s.nonEmptyString(t),"non-empty string",t),emptyStringOrWhitespace:t=>b(s.emptyStringOrWhitespace(t),"empty string or whitespace",t),emptyObject:t=>b(s.emptyObject(t),"empty object",t),nonEmptyObject:t=>b(s.nonEmptyObject(t),"non-empty object",t),emptySet:t=>b(s.emptySet(t),"empty set",t),nonEmptySet:t=>b(s.nonEmptySet(t),"non-empty set",t),emptyMap:t=>b(s.emptyMap(t),"empty map",t),nonEmptyMap:t=>b(s.nonEmptyMap(t),"non-empty map",t),propertyKey:t=>b(s.propertyKey(t),"PropertyKey",t),formData:t=>b(s.formData(t),"FormData",t),urlSearchParams:t=>b(s.urlSearchParams(t),"URLSearchParams",t),evenInteger:t=>b(s.evenInteger(t),"even integer",t),oddInteger:t=>b(s.oddInteger(t),"odd integer",t),directInstanceOf:(t,e)=>b(s.directInstanceOf(t,e),"T",t),inRange:(t,e)=>b(s.inRange(t,e),"in range",t),any:(t,...e)=>b(s.any(t,...e),"predicate returns truthy for any value",e,{multipleValues:!0}),all:(t,...e)=>b(s.all(t,...e),"predicate returns truthy for all values",e,{multipleValues:!0})},Object.defineProperties(s,{class:{value:s.class_},function:{value:s.function_},null:{value:s.null_}}),Object.defineProperties(e.assert,{class:{value:e.assert.class_},function:{value:e.assert.function_},null:{value:e.assert.null_}}),e.default=s,t.exports=s,t.exports.default=s,t.exports.assert=e.assert}(h,h.exports);var m=r(h.exports);function v(t,e){return Array.from(t).filter(((t,r)=>r!==e))}const _={skipContainers:!0,arrayStrictComparison:!1};t.deepContains=function t(e,r,n,o,u){const c={..._,...u};m(e)!==m(r)?o(`the first input arg is of a type ${m(e).toLowerCase()} but the second is ${m(r).toLowerCase()}. Values are - 1st:\n${JSON.stringify(e,null,4)}\n2nd:\n${JSON.stringify(r,null,4)}`):function(t,e){(function t(e,r,n,a){const o=i(e);let u;const c={depth:-1,path:"",...n};if(c.depth+=1,Array.isArray(o))for(let e=0,n=o.length;e<n&&!a.now;e++){const n=c.path?`${c.path}.${e}`:`${e}`;void 0!==o[e]?(c.parent=i(o),c.parentType="array",c.parentKey=g(n),u=t(r(o[e],void 0,{...c,path:n},a),r,{...c,path:n},a),Number.isNaN(u)&&e<o.length?(o.splice(e,1),e-=1):o[e]=u):o.splice(e,1)}else if(d(o))for(const e in o){if(a.now&&null!=e)break;const n=c.path?`${c.path}.${e}`:e;0===c.depth&&null!=e&&(c.topmostKey=e),c.parent=i(o),c.parentType="object",c.parentKey=g(n),u=t(r(e,o[e],{...c,path:n},a),r,{...c,path:n},a),Number.isNaN(u)?delete o[e]:o[e]=u}return o})(t,e,{},{now:!1})}(r,((r,i,u,s)=>{const l=void 0!==i?i:r,{path:f}=u;if(a.has(e,f))if(!c.arrayStrictComparison&&m.plainObject(l)&&"array"===u.parentType&&u.parent.length>1){s.now=!0;const r=Array.from(u.path.includes(".")?a.get(e,function(t){if(t.includes("."))for(let e=t.length;e--;)if("."===t[e])return t.slice(0,e);return t}(f)):e);if(r.length<u.parent.length)o(`the first array: ${JSON.stringify(r,null,4)}\nhas less objects than array we're matching against, ${JSON.stringify(u.parent,null,4)}`);else{const e=u.parent,a=r.map(((t,e)=>e));e.map(((t,e)=>e));const i=[];for(let t=0,e=a.length;t<e;t++){const e=[],r=a[t],n=v(a,t);e.push(r),n.forEach((t=>{i.push(Array.from(e).concat(t))}))}const s=i.map((t=>t.map(((t,e)=>[e,t]))));let l=0;for(let t=0,n=s.length;t<n;t++){let n=0;s[t].forEach((t=>{m.plainObject(e[t[0]])&&m.plainObject(r[t[1]])&&Object.keys(e[t[0]]).forEach((a=>{Object.keys(r[t[1]]).includes(a)&&(n+=1,r[t[1]][a]===e[t[0]][a]&&(n+=5))}))})),s[t].push(n),n>l&&(l=n)}for(let a=0,i=s.length;a<i;a++)if(s[a][2]===l){s[a].forEach(((i,u)=>{u<s[a].length-1&&t(r[i[1]],e[i[0]],n,o,c)}));break}}}else{const t=a.get(e,f);c.skipContainers&&(m.plainObject(t)||Array.isArray(t))||n(t,l,f)}else o(`the first input: ${JSON.stringify(e,null,4)}\ndoes not have the path "${f}", we were looking, would it contain a value ${JSON.stringify(l,null,0)}.`);return l}))},t.defaults=_,t.version="4.0.6",Object.defineProperty(t,"__esModule",{value:!0})}));
26
+ */var h={exports:{}};!function(t,e){Object.defineProperty(e,"__esModule",{value:!0});const r=["Int8Array","Uint8Array","Uint8ClampedArray","Int16Array","Uint16Array","Int32Array","Uint32Array","Float32Array","Float64Array","BigInt64Array","BigUint64Array"];const n=["Function","Generator","AsyncGenerator","GeneratorFunction","AsyncGeneratorFunction","AsyncFunction","Observable","Array","Buffer","Object","RegExp","Date","Error","Map","Set","WeakMap","WeakSet","ArrayBuffer","SharedArrayBuffer","DataView","Promise","URL","FormData","URLSearchParams","HTMLElement",...r];const a=["null","undefined","string","number","bigint","boolean","symbol"];function o(t){return e=>typeof e===t}const{toString:i}=Object.prototype,u=t=>{const e=i.call(t).slice(8,-1);return/HTML\w+Element/.test(e)&&s.domElement(t)?"HTMLElement":n.includes(e)?e:void 0},c=t=>e=>u(e)===t;function s(t){if(null===t)return"null";switch(typeof t){case"undefined":return"undefined";case"string":return"string";case"number":return"number";case"boolean":return"boolean";case"function":return"Function";case"bigint":return"bigint";case"symbol":return"symbol"}if(s.observable(t))return"Observable";if(s.array(t))return"Array";if(s.buffer(t))return"Buffer";const e=u(t);if(e)return e;if(t instanceof String||t instanceof Boolean||t instanceof Number)throw new TypeError("Please don't use object wrappers for primitive types");return"Object"}s.undefined=o("undefined"),s.string=o("string");const l=o("number");s.number=t=>l(t)&&!s.nan(t),s.bigint=o("bigint"),s.function_=o("function"),s.null_=t=>null===t,s.class_=t=>s.function_(t)&&t.toString().startsWith("class "),s.boolean=t=>!0===t||!1===t,s.symbol=o("symbol"),s.numericString=t=>s.string(t)&&!s.emptyStringOrWhitespace(t)&&!Number.isNaN(Number(t)),s.array=(t,e)=>!!Array.isArray(t)&&(!s.function_(e)||t.every(e)),s.buffer=t=>{var e,r,n,a;return null!==(a=null===(n=null===(r=null===(e=t)||void 0===e?void 0:e.constructor)||void 0===r?void 0:r.isBuffer)||void 0===n?void 0:n.call(r,t))&&void 0!==a&&a},s.nullOrUndefined=t=>s.null_(t)||s.undefined(t),s.object=t=>!s.null_(t)&&("object"==typeof t||s.function_(t)),s.iterable=t=>{var e;return s.function_(null===(e=t)||void 0===e?void 0:e[Symbol.iterator])},s.asyncIterable=t=>{var e;return s.function_(null===(e=t)||void 0===e?void 0:e[Symbol.asyncIterator])},s.generator=t=>s.iterable(t)&&s.function_(t.next)&&s.function_(t.throw),s.asyncGenerator=t=>s.asyncIterable(t)&&s.function_(t.next)&&s.function_(t.throw),s.nativePromise=t=>c("Promise")(t);s.promise=t=>s.nativePromise(t)||(t=>{var e,r;return s.function_(null===(e=t)||void 0===e?void 0:e.then)&&s.function_(null===(r=t)||void 0===r?void 0:r.catch)})(t),s.generatorFunction=c("GeneratorFunction"),s.asyncGeneratorFunction=t=>"AsyncGeneratorFunction"===u(t),s.asyncFunction=t=>"AsyncFunction"===u(t),s.boundFunction=t=>s.function_(t)&&!t.hasOwnProperty("prototype"),s.regExp=c("RegExp"),s.date=c("Date"),s.error=c("Error"),s.map=t=>c("Map")(t),s.set=t=>c("Set")(t),s.weakMap=t=>c("WeakMap")(t),s.weakSet=t=>c("WeakSet")(t),s.int8Array=c("Int8Array"),s.uint8Array=c("Uint8Array"),s.uint8ClampedArray=c("Uint8ClampedArray"),s.int16Array=c("Int16Array"),s.uint16Array=c("Uint16Array"),s.int32Array=c("Int32Array"),s.uint32Array=c("Uint32Array"),s.float32Array=c("Float32Array"),s.float64Array=c("Float64Array"),s.bigInt64Array=c("BigInt64Array"),s.bigUint64Array=c("BigUint64Array"),s.arrayBuffer=c("ArrayBuffer"),s.sharedArrayBuffer=c("SharedArrayBuffer"),s.dataView=c("DataView"),s.directInstanceOf=(t,e)=>Object.getPrototypeOf(t)===e.prototype,s.urlInstance=t=>c("URL")(t),s.urlString=t=>{if(!s.string(t))return!1;try{return new URL(t),!0}catch(t){return!1}},s.truthy=t=>Boolean(t),s.falsy=t=>!t,s.nan=t=>Number.isNaN(t),s.primitive=t=>s.null_(t)||a.includes(typeof t),s.integer=t=>Number.isInteger(t),s.safeInteger=t=>Number.isSafeInteger(t),s.plainObject=t=>{if("[object Object]"!==i.call(t))return!1;const e=Object.getPrototypeOf(t);return null===e||e===Object.getPrototypeOf({})},s.typedArray=t=>{return e=u(t),r.includes(e);var e};s.arrayLike=t=>!s.nullOrUndefined(t)&&!s.function_(t)&&(t=>s.safeInteger(t)&&t>=0)(t.length),s.inRange=(t,e)=>{if(s.number(e))return t>=Math.min(0,e)&&t<=Math.max(e,0);if(s.array(e)&&2===e.length)return t>=Math.min(...e)&&t<=Math.max(...e);throw new TypeError(`Invalid range: ${JSON.stringify(e)}`)};const f=["innerHTML","ownerDocument","style","attributes","nodeValue"];s.domElement=t=>s.object(t)&&1===t.nodeType&&s.string(t.nodeName)&&!s.plainObject(t)&&f.every((e=>e in t)),s.observable=t=>{var e,r,n,a;return!!t&&(t===(null===(r=(e=t)[Symbol.observable])||void 0===r?void 0:r.call(e))||t===(null===(a=(n=t)["@@observable"])||void 0===a?void 0:a.call(n)))},s.nodeStream=t=>s.object(t)&&s.function_(t.pipe)&&!s.observable(t),s.infinite=t=>t===1/0||t===-1/0;const y=t=>e=>s.integer(e)&&Math.abs(e%2)===t;s.evenInteger=y(0),s.oddInteger=y(1),s.emptyArray=t=>s.array(t)&&0===t.length,s.nonEmptyArray=t=>s.array(t)&&t.length>0,s.emptyString=t=>s.string(t)&&0===t.length,s.nonEmptyString=t=>s.string(t)&&t.length>0;s.emptyStringOrWhitespace=t=>s.emptyString(t)||(t=>s.string(t)&&!/\S/.test(t))(t),s.emptyObject=t=>s.object(t)&&!s.map(t)&&!s.set(t)&&0===Object.keys(t).length,s.nonEmptyObject=t=>s.object(t)&&!s.map(t)&&!s.set(t)&&Object.keys(t).length>0,s.emptySet=t=>s.set(t)&&0===t.size,s.nonEmptySet=t=>s.set(t)&&t.size>0,s.emptyMap=t=>s.map(t)&&0===t.size,s.nonEmptyMap=t=>s.map(t)&&t.size>0,s.propertyKey=t=>s.any([s.string,s.number,s.symbol],t),s.formData=t=>c("FormData")(t),s.urlSearchParams=t=>c("URLSearchParams")(t);const p=(t,e,r)=>{if(!s.function_(e))throw new TypeError(`Invalid predicate: ${JSON.stringify(e)}`);if(0===r.length)throw new TypeError("Invalid number of values");return t.call(r,e)};s.any=(t,...e)=>(s.array(t)?t:[t]).some((t=>p(Array.prototype.some,t,e))),s.all=(t,...e)=>p(Array.prototype.every,t,e);const b=(t,e,r,n={})=>{if(!t){const{multipleValues:t}=n,a=t?`received values of types ${[...new Set(r.map((t=>`\`${s(t)}\``)))].join(", ")}`:`received value of type \`${s(r)}\``;throw new TypeError(`Expected value which is \`${e}\`, ${a}.`)}};e.assert={undefined:t=>b(s.undefined(t),"undefined",t),string:t=>b(s.string(t),"string",t),number:t=>b(s.number(t),"number",t),bigint:t=>b(s.bigint(t),"bigint",t),function_:t=>b(s.function_(t),"Function",t),null_:t=>b(s.null_(t),"null",t),class_:t=>b(s.class_(t),"Class",t),boolean:t=>b(s.boolean(t),"boolean",t),symbol:t=>b(s.symbol(t),"symbol",t),numericString:t=>b(s.numericString(t),"string with a number",t),array:(t,e)=>{b(s.array(t),"Array",t),e&&t.forEach(e)},buffer:t=>b(s.buffer(t),"Buffer",t),nullOrUndefined:t=>b(s.nullOrUndefined(t),"null or undefined",t),object:t=>b(s.object(t),"Object",t),iterable:t=>b(s.iterable(t),"Iterable",t),asyncIterable:t=>b(s.asyncIterable(t),"AsyncIterable",t),generator:t=>b(s.generator(t),"Generator",t),asyncGenerator:t=>b(s.asyncGenerator(t),"AsyncGenerator",t),nativePromise:t=>b(s.nativePromise(t),"native Promise",t),promise:t=>b(s.promise(t),"Promise",t),generatorFunction:t=>b(s.generatorFunction(t),"GeneratorFunction",t),asyncGeneratorFunction:t=>b(s.asyncGeneratorFunction(t),"AsyncGeneratorFunction",t),asyncFunction:t=>b(s.asyncFunction(t),"AsyncFunction",t),boundFunction:t=>b(s.boundFunction(t),"Function",t),regExp:t=>b(s.regExp(t),"RegExp",t),date:t=>b(s.date(t),"Date",t),error:t=>b(s.error(t),"Error",t),map:t=>b(s.map(t),"Map",t),set:t=>b(s.set(t),"Set",t),weakMap:t=>b(s.weakMap(t),"WeakMap",t),weakSet:t=>b(s.weakSet(t),"WeakSet",t),int8Array:t=>b(s.int8Array(t),"Int8Array",t),uint8Array:t=>b(s.uint8Array(t),"Uint8Array",t),uint8ClampedArray:t=>b(s.uint8ClampedArray(t),"Uint8ClampedArray",t),int16Array:t=>b(s.int16Array(t),"Int16Array",t),uint16Array:t=>b(s.uint16Array(t),"Uint16Array",t),int32Array:t=>b(s.int32Array(t),"Int32Array",t),uint32Array:t=>b(s.uint32Array(t),"Uint32Array",t),float32Array:t=>b(s.float32Array(t),"Float32Array",t),float64Array:t=>b(s.float64Array(t),"Float64Array",t),bigInt64Array:t=>b(s.bigInt64Array(t),"BigInt64Array",t),bigUint64Array:t=>b(s.bigUint64Array(t),"BigUint64Array",t),arrayBuffer:t=>b(s.arrayBuffer(t),"ArrayBuffer",t),sharedArrayBuffer:t=>b(s.sharedArrayBuffer(t),"SharedArrayBuffer",t),dataView:t=>b(s.dataView(t),"DataView",t),urlInstance:t=>b(s.urlInstance(t),"URL",t),urlString:t=>b(s.urlString(t),"string with a URL",t),truthy:t=>b(s.truthy(t),"truthy",t),falsy:t=>b(s.falsy(t),"falsy",t),nan:t=>b(s.nan(t),"NaN",t),primitive:t=>b(s.primitive(t),"primitive",t),integer:t=>b(s.integer(t),"integer",t),safeInteger:t=>b(s.safeInteger(t),"integer",t),plainObject:t=>b(s.plainObject(t),"plain object",t),typedArray:t=>b(s.typedArray(t),"TypedArray",t),arrayLike:t=>b(s.arrayLike(t),"array-like",t),domElement:t=>b(s.domElement(t),"HTMLElement",t),observable:t=>b(s.observable(t),"Observable",t),nodeStream:t=>b(s.nodeStream(t),"Node.js Stream",t),infinite:t=>b(s.infinite(t),"infinite number",t),emptyArray:t=>b(s.emptyArray(t),"empty array",t),nonEmptyArray:t=>b(s.nonEmptyArray(t),"non-empty array",t),emptyString:t=>b(s.emptyString(t),"empty string",t),nonEmptyString:t=>b(s.nonEmptyString(t),"non-empty string",t),emptyStringOrWhitespace:t=>b(s.emptyStringOrWhitespace(t),"empty string or whitespace",t),emptyObject:t=>b(s.emptyObject(t),"empty object",t),nonEmptyObject:t=>b(s.nonEmptyObject(t),"non-empty object",t),emptySet:t=>b(s.emptySet(t),"empty set",t),nonEmptySet:t=>b(s.nonEmptySet(t),"non-empty set",t),emptyMap:t=>b(s.emptyMap(t),"empty map",t),nonEmptyMap:t=>b(s.nonEmptyMap(t),"non-empty map",t),propertyKey:t=>b(s.propertyKey(t),"PropertyKey",t),formData:t=>b(s.formData(t),"FormData",t),urlSearchParams:t=>b(s.urlSearchParams(t),"URLSearchParams",t),evenInteger:t=>b(s.evenInteger(t),"even integer",t),oddInteger:t=>b(s.oddInteger(t),"odd integer",t),directInstanceOf:(t,e)=>b(s.directInstanceOf(t,e),"T",t),inRange:(t,e)=>b(s.inRange(t,e),"in range",t),any:(t,...e)=>b(s.any(t,...e),"predicate returns truthy for any value",e,{multipleValues:!0}),all:(t,...e)=>b(s.all(t,...e),"predicate returns truthy for all values",e,{multipleValues:!0})},Object.defineProperties(s,{class:{value:s.class_},function:{value:s.function_},null:{value:s.null_}}),Object.defineProperties(e.assert,{class:{value:e.assert.class_},function:{value:e.assert.function_},null:{value:e.assert.null_}}),e.default=s,t.exports=s,t.exports.default=s,t.exports.assert=e.assert}(h,h.exports);var m=r(h.exports);function v(t,e){return Array.from(t).filter(((t,r)=>r!==e))}const _={skipContainers:!0,arrayStrictComparison:!1};t.deepContains=function t(e,r,n,o,u){const c={..._,...u};m(e)!==m(r)?o(`the first input arg is of a type ${m(e).toLowerCase()} but the second is ${m(r).toLowerCase()}. Values are - 1st:\n${JSON.stringify(e,null,4)}\n2nd:\n${JSON.stringify(r,null,4)}`):function(t,e){(function t(e,r,n,a){const o=i(e);let u;const c={depth:-1,path:"",...n};if(c.depth+=1,Array.isArray(o))for(let e=0,n=o.length;e<n&&!a.now;e++){const n=c.path?`${c.path}.${e}`:`${e}`;void 0!==o[e]?(c.parent=i(o),c.parentType="array",c.parentKey=g(n),u=t(r(o[e],void 0,{...c,path:n},a),r,{...c,path:n},a),Number.isNaN(u)&&e<o.length?(o.splice(e,1),e-=1):o[e]=u):o.splice(e,1)}else if(d(o))for(const e in o){if(a.now&&null!=e)break;const n=c.path?`${c.path}.${e}`:e;0===c.depth&&null!=e&&(c.topmostKey=e),c.parent=i(o),c.parentType="object",c.parentKey=g(n),u=t(r(e,o[e],{...c,path:n},a),r,{...c,path:n},a),Number.isNaN(u)?delete o[e]:o[e]=u}return o})(t,e,{},{now:!1})}(r,((r,i,u,s)=>{const l=void 0!==i?i:r,{path:f}=u;if(a.has(e,f))if(!c.arrayStrictComparison&&m.plainObject(l)&&"array"===u.parentType&&u.parent.length>1){s.now=!0;const r=Array.from(u.path.includes(".")?a.get(e,function(t){if(t.includes("."))for(let e=t.length;e--;)if("."===t[e])return t.slice(0,e);return t}(f)):e);if(r.length<u.parent.length)o(`the first array: ${JSON.stringify(r,null,4)}\nhas less objects than array we're matching against, ${JSON.stringify(u.parent,null,4)}`);else{const e=u.parent,a=r.map(((t,e)=>e));e.map(((t,e)=>e));const i=[];for(let t=0,e=a.length;t<e;t++){const e=[],r=a[t],n=v(a,t);e.push(r),n.forEach((t=>{i.push(Array.from(e).concat(t))}))}const s=i.map((t=>t.map(((t,e)=>[e,t]))));let l=0;for(let t=0,n=s.length;t<n;t++){let n=0;s[t].forEach((t=>{m.plainObject(e[t[0]])&&m.plainObject(r[t[1]])&&Object.keys(e[t[0]]).forEach((a=>{Object.keys(r[t[1]]).includes(a)&&(n+=1,r[t[1]][a]===e[t[0]][a]&&(n+=5))}))})),s[t].push(n),n>l&&(l=n)}for(let a=0,i=s.length;a<i;a++)if(s[a][2]===l){s[a].forEach(((i,u)=>{u<s[a].length-1&&t(r[i[1]],e[i[0]],n,o,c)}));break}}}else{const t=a.get(e,f);c.skipContainers&&(m.plainObject(t)||Array.isArray(t))||n(t,l,f)}else o(`the first input: ${JSON.stringify(e,null,4)}\ndoes not have the path "${f}", we were looking, would it contain a value ${JSON.stringify(l,null,0)}.`);return l}))},t.defaults=_,t.version="4.0.7",Object.defineProperty(t,"__esModule",{value:!0})}));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ast-deep-contains",
3
- "version": "4.0.6",
3
+ "version": "4.0.7",
4
4
  "description": "Like t.same assert on array of objects, where element order doesn't matter.",
5
5
  "keywords": [
6
6
  "array",
@@ -95,7 +95,7 @@
95
95
  "dependencies": {
96
96
  "@babel/runtime": "^7.16.3",
97
97
  "@sindresorhus/is": "^4.2.0",
98
- "ast-monkey-traverse": "^3.0.6",
98
+ "ast-monkey-traverse": "^3.0.7",
99
99
  "object-path": "^0.11.8"
100
100
  },
101
101
  "devDependencies": {
@@ -119,22 +119,22 @@
119
119
  "@rollup/plugin-strip": "^2.1.0",
120
120
  "@rollup/plugin-typescript": "^8.3.0",
121
121
  "@types/lodash.isplainobject": "^4.0.6",
122
- "@types/node": "^16.11.9",
122
+ "@types/node": "^16.11.10",
123
123
  "@types/object-path": "^0.11.1",
124
124
  "@types/tap": "^15.0.5",
125
- "@typescript-eslint/eslint-plugin": "^5.4.0",
126
- "@typescript-eslint/parser": "^5.4.0",
127
- "core-js": "^3.19.1",
125
+ "@typescript-eslint/eslint-plugin": "^5.5.0",
126
+ "@typescript-eslint/parser": "^5.5.0",
127
+ "core-js": "^3.19.2",
128
128
  "cross-env": "^7.0.3",
129
129
  "eslint": "^8.3.0",
130
- "lect": "^0.18.6",
131
- "rollup": "^2.60.0",
130
+ "lect": "^0.18.7",
131
+ "rollup": "^2.60.1",
132
132
  "rollup-plugin-ascii": "^0.0.3",
133
133
  "rollup-plugin-banner": "^0.2.1",
134
134
  "rollup-plugin-cleanup": "^3.2.1",
135
135
  "rollup-plugin-dts": "^4.0.1",
136
136
  "rollup-plugin-terser": "^7.0.2",
137
- "tap": "^15.1.2",
137
+ "tap": "^15.1.5",
138
138
  "tslib": "^2.3.1",
139
139
  "typescript": "^4.5.2"
140
140
  },