Comparing version 6.4.6 to 7.0.0
@@ -49,4 +49,4 @@ "use strict"; | ||
this.idMap = this.parent ? this.parent.idMap : new Map(); | ||
const style = this.parent | ||
? this.parent.style | ||
const style = this.parent ? | ||
this.parent.style | ||
: styles_js_1.styles[options.style || 'pretty']; | ||
@@ -58,4 +58,4 @@ if (!style) { | ||
this.bufferChunkSize = | ||
this.style.bufferChunkSize === Infinity | ||
? Infinity | ||
this.style.bufferChunkSize === Infinity ? | ||
Infinity | ||
: options.bufferChunkSize || this.style.bufferChunkSize; | ||
@@ -70,7 +70,6 @@ // for printing child values of pojos and maps | ||
this.level = this.parent ? this.parent.level + 1 : 0; | ||
this.indent = this.parent | ||
? this.parent.indent | ||
: typeof options.indent === 'string' | ||
? options.indent | ||
: ' '; | ||
this.indent = | ||
this.parent ? this.parent.indent | ||
: typeof options.indent === 'string' ? options.indent | ||
: ' '; | ||
this.match = true; | ||
@@ -141,9 +140,8 @@ this.object = obj; | ||
isReactElementChildren(children) { | ||
return !children || typeof children === 'string' | ||
? true | ||
: typeof children === 'object' | ||
? children instanceof Set || Array.isArray(children) | ||
? ![...children].some(c => !this.isReactElementChildren(c)) | ||
return (!children || typeof children === 'string' ? true | ||
: typeof children === 'object' ? | ||
children instanceof Set || Array.isArray(children) ? | ||
![...children].some(c => !this.isReactElementChildren(c)) | ||
: Format.prototype.isReactElement.call(this, children) | ||
: false; | ||
: false); | ||
} | ||
@@ -192,17 +190,14 @@ // technically this means "is an iterable we don't have another fit for" | ||
const ts = objToString(this.object).slice(8, -1); | ||
return this.object.constructor !== Object && | ||
return ((this.object.constructor !== Object && | ||
this.object.constructor && | ||
this.object.constructor.name && | ||
this.object.constructor.name !== ts | ||
? this.object.constructor.name | ||
: !Object.getPrototypeOf(this.object) | ||
? 'Null Object' | ||
: ts; | ||
this.object.constructor.name !== ts) ? | ||
this.object.constructor.name | ||
: !Object.getPrototypeOf(this.object) ? 'Null Object' | ||
: ts); | ||
} | ||
get objectAsArray() { | ||
// return the object as an actual array, if we can | ||
const value = Array.isArray(this.object) | ||
? this.object | ||
: this.isArray() | ||
? arrayFrom(this.object) | ||
const value = Array.isArray(this.object) ? this.object | ||
: this.isArray() ? arrayFrom(this.object) | ||
: null; | ||
@@ -343,6 +338,4 @@ if (value === null) { | ||
const key = this.isKeyless() ? '' : this.getKey(); | ||
const sep = !key | ||
? '' | ||
: this.parent && this.parent.isMap() | ||
? this.style.mapKeyValSep() | ||
const sep = !key ? '' | ||
: this.parent && this.parent.isMap() ? this.style.mapKeyValSep() | ||
: this.style.pojoKeyValSep(); | ||
@@ -357,23 +350,16 @@ this.memo = | ||
this.memo += | ||
this.isKey || !this.parent | ||
? '' | ||
: this.parent.isMap() | ||
? this.style.mapEntrySep() | ||
: this.parent.isBuffer() | ||
? '' | ||
: this.parent.isArray() | ||
? this.style.arrayEntrySep() | ||
: this.parent.isSet() | ||
? this.style.setEntrySep() | ||
: this.parent.isString() | ||
? '' | ||
this.isKey || !this.parent ? '' | ||
: this.parent.isMap() ? this.style.mapEntrySep() | ||
: this.parent.isBuffer() ? '' | ||
: this.parent.isArray() ? this.style.arrayEntrySep() | ||
: this.parent.isSet() ? this.style.setEntrySep() | ||
: this.parent.isString() ? '' | ||
: this.style.pojoEntrySep(); | ||
} | ||
getKey() { | ||
return this.parent && this.parent.isMap() | ||
? this.style.mapKeyStart() + | ||
return (this.parent && this.parent.isMap() ? | ||
this.style.mapKeyStart() + | ||
this.parent.child(this.key, { isKey: true }, Format).print() | ||
: typeof this.key === 'string' | ||
? JSON.stringify(this.key) | ||
: `[${this.#printSymbol(this.key)}]`; | ||
: typeof this.key === 'string' ? JSON.stringify(this.key) | ||
: `[${this.#printSymbol(this.key)}]`); | ||
} | ||
@@ -387,16 +373,10 @@ printCircular(seen) { | ||
printCollection() { | ||
return this.isError() | ||
? this.printError() | ||
: this.isSet() | ||
? this.printSet() | ||
: this.isMap() | ||
? this.printMap() | ||
: this.isBuffer() | ||
? this.printBuffer() | ||
: this.isArray() && this.objectAsArray | ||
? this.printArray() | ||
: this.isReactElement() | ||
? this.printReactElement() | ||
: // TODO streams, JSX | ||
this.printPojo(); | ||
return (this.isError() ? this.printError() | ||
: this.isSet() ? this.printSet() | ||
: this.isMap() ? this.printMap() | ||
: this.isBuffer() ? this.printBuffer() | ||
: this.isArray() && this.objectAsArray ? this.printArray() | ||
: this.isReactElement() ? this.printReactElement() | ||
// TODO streams, JSX | ||
: this.printPojo()); | ||
} | ||
@@ -728,4 +708,4 @@ nodeId() { | ||
}); | ||
return this.sort | ||
? ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
return this.sort ? | ||
ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
: ent; | ||
@@ -732,0 +712,0 @@ } |
@@ -39,4 +39,4 @@ "use strict"; | ||
.map(k => [k, obj[k]]); | ||
return this.sort | ||
? ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
return this.sort ? | ||
ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
: ent; | ||
@@ -43,0 +43,0 @@ } |
@@ -27,67 +27,47 @@ "use strict"; | ||
const pattern = this.expect; | ||
return super.test() === true | ||
? true | ||
: // failures that would also fail in the super class | ||
// but if they didn't pass, then should fail here, too | ||
pattern == null || obj == null | ||
? false | ||
: pattern instanceof RegExp && obj instanceof RegExp | ||
? false | ||
: Buffer.isBuffer(obj) && Buffer.isBuffer(pattern) | ||
? false | ||
: typeof pattern === 'symbol' | ||
? false | ||
: // ok, Match-specific stuff | ||
pattern instanceof RegExp | ||
? pattern.test('' + obj) | ||
: typeof obj === 'string' && | ||
typeof pattern === 'string' && | ||
pattern | ||
? obj.indexOf(pattern) !== -1 | ||
: obj instanceof Date && typeof pattern === 'string' | ||
? obj.getTime() === new Date(pattern).getTime() | ||
: pattern === BigInt | ||
? typeof obj === 'bigint' | ||
: pattern === Buffer | ||
? Buffer.isBuffer(obj) | ||
: pattern === Function | ||
? typeof obj === 'function' | ||
: pattern === Number | ||
? typeof obj === 'number' && obj === obj && isFinite(obj) | ||
: pattern === String | ||
? typeof obj === 'string' | ||
: pattern === Symbol | ||
? typeof obj === 'symbol' | ||
: pattern === Boolean | ||
? typeof obj === 'boolean' | ||
: pattern === Map | ||
? this.isMap() | ||
: pattern === Set | ||
? this.isSet() | ||
: pattern === Object | ||
? obj && typeof obj === 'object' | ||
: pattern === Array | ||
? new format_js_1.Format(obj).isArray() | ||
: !this.isError() && pattern instanceof Error | ||
? false | ||
: this.isError() && | ||
((pattern.message && | ||
!new Match(obj.message, { | ||
expect: pattern.message, | ||
}).test()) || | ||
(pattern.name && | ||
!new Match(obj.name, { | ||
expect: pattern.name, | ||
}).test())) | ||
? false | ||
: // standard deep matching stuff, same as parent, but not simple. | ||
this.isSet() && !(pattern instanceof Set) | ||
? false | ||
: this.isMap() && !(pattern instanceof Map) | ||
? false | ||
: typeof pattern === 'function' && typeof obj === 'object' | ||
? obj instanceof pattern | ||
: typeof obj !== 'object' || typeof pattern !== 'object' | ||
? false | ||
: 'COMPLEX'; | ||
return (super.test() === true ? true | ||
// failures that would also fail in the super class | ||
// but if they didn't pass, then should fail here, too | ||
: pattern == null || obj == null ? false | ||
: pattern instanceof RegExp && obj instanceof RegExp ? false | ||
: Buffer.isBuffer(obj) && Buffer.isBuffer(pattern) ? false | ||
: typeof pattern === 'symbol' ? false | ||
// ok, Match-specific stuff | ||
: pattern instanceof RegExp ? pattern.test('' + obj) | ||
: (typeof obj === 'string' && | ||
typeof pattern === 'string' && | ||
pattern) ? | ||
obj.indexOf(pattern) !== -1 | ||
: obj instanceof Date && typeof pattern === 'string' ? | ||
obj.getTime() === new Date(pattern).getTime() | ||
: pattern === BigInt ? typeof obj === 'bigint' | ||
: pattern === Buffer ? Buffer.isBuffer(obj) | ||
: pattern === Function ? typeof obj === 'function' | ||
: pattern === Number ? | ||
typeof obj === 'number' && obj === obj && isFinite(obj) | ||
: pattern === String ? typeof obj === 'string' | ||
: pattern === Symbol ? typeof obj === 'symbol' | ||
: pattern === Boolean ? typeof obj === 'boolean' | ||
: pattern === Map ? this.isMap() | ||
: pattern === Set ? this.isSet() | ||
: pattern === Object ? obj && typeof obj === 'object' | ||
: pattern === Array ? new format_js_1.Format(obj).isArray() | ||
: !this.isError() && pattern instanceof Error ? false | ||
: (this.isError() && | ||
((pattern.message && | ||
!new Match(obj.message, { | ||
expect: pattern.message, | ||
}).test()) || | ||
(pattern.name && | ||
!new Match(obj.name, { | ||
expect: pattern.name, | ||
}).test()))) ? | ||
false | ||
// standard deep matching stuff, same as parent, but not simple. | ||
: this.isSet() && !(pattern instanceof Set) ? false | ||
: this.isMap() && !(pattern instanceof Map) ? false | ||
: typeof pattern === 'function' && typeof obj === 'object' ? | ||
obj instanceof pattern | ||
: typeof obj !== 'object' || typeof pattern !== 'object' ? false | ||
: 'COMPLEX'); | ||
} | ||
@@ -94,0 +74,0 @@ } |
@@ -76,44 +76,33 @@ "use strict"; | ||
const b = this.expect; | ||
return typeof a === 'function' && typeof b === 'function' | ||
? a === b || | ||
return (typeof a === 'function' && typeof b === 'function' ? | ||
a === b || | ||
(a.name === b.name && a.toString() === b.toString()) | ||
: typeof a === 'symbol' || typeof b === 'symbol' | ||
? typeof a === typeof b && a.toString() === b.toString() | ||
: typeof a !== 'object' && typeof b !== 'object' && a == b | ||
? true | ||
: a === b | ||
? true | ||
: a instanceof Date && b instanceof Date | ||
? a.getTime() === b.getTime() | ||
: typeof a?.valueOf === 'function' && | ||
: typeof a === 'symbol' || typeof b === 'symbol' ? | ||
typeof a === typeof b && a.toString() === b.toString() | ||
: typeof a !== 'object' && typeof b !== 'object' && a == b ? | ||
true | ||
: a === b ? true | ||
: a instanceof Date && b instanceof Date ? | ||
a.getTime() === b.getTime() | ||
: (typeof a?.valueOf === 'function' && | ||
typeof b?.valueOf === 'function' && | ||
a.valueOf() === b.valueOf() | ||
? true | ||
: typeof a?.valueOf === 'function' && a.valueOf() === b | ||
? true | ||
: typeof b?.valueOf === 'function' && b.valueOf() === a | ||
? true | ||
: a === null || b === null | ||
? a == b | ||
: a !== a | ||
? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' | ||
? false | ||
: !this.isError() && b instanceof Error | ||
? false | ||
: this.isError() && | ||
a.valueOf() === b.valueOf()) ? | ||
true | ||
: typeof a?.valueOf === 'function' && a.valueOf() === b ? true | ||
: typeof b?.valueOf === 'function' && b.valueOf() === a ? true | ||
: a === null || b === null ? a == b | ||
: a !== a ? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' ? false | ||
: !this.isError() && b instanceof Error ? false | ||
: (this.isError() && | ||
((b.message && b.message !== a.message) || | ||
(b.name && b.name !== a.name)) | ||
? false | ||
: this.isSet() && !new format_js_1.Format(b).isSet() | ||
? false | ||
: this.isMap() && !new format_js_1.Format(b).isMap() | ||
? false | ||
: this.isArray() && !new format_js_1.Format(b).isArray() | ||
? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) | ||
? a.equals(b) | ||
: a instanceof RegExp && b instanceof RegExp | ||
? this.regexpSame(a, b) | ||
: 'COMPLEX'; // might still be a deeper mismatch, of course | ||
(b.name && b.name !== a.name))) ? | ||
false | ||
: this.isSet() && !new format_js_1.Format(b).isSet() ? false | ||
: this.isMap() && !new format_js_1.Format(b).isMap() ? false | ||
: this.isArray() && !new format_js_1.Format(b).isArray() ? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) ? a.equals(b) | ||
: a instanceof RegExp && b instanceof RegExp ? | ||
this.regexpSame(a, b) | ||
: 'COMPLEX'); // might still be a deeper mismatch, of course | ||
} | ||
@@ -214,4 +203,4 @@ regexpSame(a, b) { | ||
child(obj, options, cls) { | ||
const expectKey = hasOwnProperty.call(options, 'expectKey') | ||
? options.expectKey | ||
const expectKey = hasOwnProperty.call(options, 'expectKey') ? | ||
options.expectKey | ||
: options.key; | ||
@@ -227,17 +216,11 @@ return super.child(obj, { | ||
// would have gotten the simple printed diff. | ||
return this.isSet() | ||
? key | ||
: this.isMap() | ||
? this.expect.get(key) | ||
: this.isArray() | ||
? this.expectAsArray[key] | ||
: this.expect[key]; | ||
return (this.isSet() ? key | ||
: this.isMap() ? this.expect.get(key) | ||
: this.isArray() ? this.expectAsArray[key] | ||
: this.expect[key]); | ||
} | ||
get expectAsArray() { | ||
const value = Array.isArray(this.expect) | ||
? this.expect | ||
: new format_js_1.Format(this.expect).isArray() | ||
? arrayFrom(this.expect) | ||
: /* c8 ignore start */ | ||
null; | ||
const value = Array.isArray(this.expect) ? this.expect | ||
: new format_js_1.Format(this.expect).isArray() ? arrayFrom(this.expect) | ||
: /* c8 ignore start */ null; | ||
/* c8 ignore stop */ | ||
@@ -263,6 +246,4 @@ defineProperty(this, 'expectAsArray', { value }); | ||
/* c8 ignore stop */ | ||
const sep = !key | ||
? '' | ||
: this.parent && this.parent.isMap() | ||
? this.style.mapKeyValSep() | ||
const sep = !key ? '' | ||
: this.parent && this.parent.isMap() ? this.style.mapKeyValSep() | ||
: this.style.pojoKeyValSep(); | ||
@@ -277,16 +258,10 @@ const start = this.style.start(indent, key, sep); | ||
} | ||
const end = this.parent.isMap() | ||
? this.style.mapEntrySep() | ||
: this.parent.isArray() | ||
? this.style.arrayEntrySep() | ||
: // these types are always simple printed | ||
/* c8 ignore start */ | ||
this.parent.isSet() | ||
? this.style.setEntrySep() | ||
: this.parent.isBuffer() | ||
? '' | ||
: this.parent.isString() | ||
? '' | ||
: /* c8 ignore stop */ | ||
this.style.pojoEntrySep(); | ||
const end = this.parent.isMap() ? this.style.mapEntrySep() | ||
: this.parent.isArray() ? this.style.arrayEntrySep() | ||
// these types are always simple printed | ||
: /* c8 ignore start */ | ||
this.parent.isSet() ? this.style.setEntrySep() | ||
: this.parent.isBuffer() ? '' | ||
: this.parent.isString() ? '' | ||
: /* c8 ignore stop */ this.style.pojoEntrySep(); | ||
this.memo += end; | ||
@@ -293,0 +268,0 @@ this.memoExpect += end; |
@@ -14,24 +14,16 @@ "use strict"; | ||
const st = super.test(); | ||
return st === false | ||
? false | ||
: a === b | ||
? true | ||
: a !== a | ||
? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' | ||
? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) | ||
? st | ||
: a instanceof Date && b instanceof Date | ||
? st | ||
: a instanceof RegExp && b instanceof RegExp | ||
? st | ||
: this.isArguments() && !new format_js_1.Format(b).isArguments() | ||
? false | ||
: a.constructor !== b.constructor && | ||
return (st === false ? false | ||
: a === b ? true | ||
: a !== a ? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' ? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) ? st | ||
: a instanceof Date && b instanceof Date ? st | ||
: a instanceof RegExp && b instanceof RegExp ? st | ||
: this.isArguments() && !new format_js_1.Format(b).isArguments() ? false | ||
: (a.constructor !== b.constructor && | ||
!(Array.isArray(b) && | ||
Array.isArray(b) && | ||
a.constructor.name === b.constructor.name) | ||
? false | ||
: 'COMPLEX'; | ||
a.constructor.name === b.constructor.name)) ? | ||
false | ||
: 'COMPLEX'); | ||
} | ||
@@ -38,0 +30,0 @@ } |
@@ -43,12 +43,12 @@ "use strict"; | ||
nodeId: id => `&ref_${id} `, | ||
errorEmpty: er => !(er instanceof Error) | ||
? `${er.name || '(no name)'}: ${er.message || '(no message)'}` | ||
errorEmpty: er => !(er instanceof Error) ? | ||
`${er.name || '(no name)'}: ${er.message || '(no message)'}` | ||
: `${er.toString()}`, | ||
errorHead: (er, cls) => { | ||
// assertion errors sometimes generate WACKY stuff | ||
return cls === 'AssertionError' && er.generatedMessage | ||
? er.name + ' {\n' | ||
: !(er instanceof Error) | ||
? `${er.name || '(no name)'}: ${er.message || '(no message)'} \{\n` | ||
: `${er.toString()} \{\n`; | ||
return (cls === 'AssertionError' && er.generatedMessage ? | ||
er.name + ' {\n' | ||
: !(er instanceof Error) ? | ||
`${er.name || '(no name)'}: ${er.message || '(no message)'} \{\n` | ||
: `${er.toString()} \{\n`); | ||
}, | ||
@@ -55,0 +55,0 @@ errorTail: indent => `${indent}}`, |
@@ -46,4 +46,4 @@ import { styles } from './styles.js'; | ||
this.idMap = this.parent ? this.parent.idMap : new Map(); | ||
const style = this.parent | ||
? this.parent.style | ||
const style = this.parent ? | ||
this.parent.style | ||
: styles[options.style || 'pretty']; | ||
@@ -55,4 +55,4 @@ if (!style) { | ||
this.bufferChunkSize = | ||
this.style.bufferChunkSize === Infinity | ||
? Infinity | ||
this.style.bufferChunkSize === Infinity ? | ||
Infinity | ||
: options.bufferChunkSize || this.style.bufferChunkSize; | ||
@@ -67,7 +67,6 @@ // for printing child values of pojos and maps | ||
this.level = this.parent ? this.parent.level + 1 : 0; | ||
this.indent = this.parent | ||
? this.parent.indent | ||
: typeof options.indent === 'string' | ||
? options.indent | ||
: ' '; | ||
this.indent = | ||
this.parent ? this.parent.indent | ||
: typeof options.indent === 'string' ? options.indent | ||
: ' '; | ||
this.match = true; | ||
@@ -138,9 +137,8 @@ this.object = obj; | ||
isReactElementChildren(children) { | ||
return !children || typeof children === 'string' | ||
? true | ||
: typeof children === 'object' | ||
? children instanceof Set || Array.isArray(children) | ||
? ![...children].some(c => !this.isReactElementChildren(c)) | ||
return (!children || typeof children === 'string' ? true | ||
: typeof children === 'object' ? | ||
children instanceof Set || Array.isArray(children) ? | ||
![...children].some(c => !this.isReactElementChildren(c)) | ||
: Format.prototype.isReactElement.call(this, children) | ||
: false; | ||
: false); | ||
} | ||
@@ -189,17 +187,14 @@ // technically this means "is an iterable we don't have another fit for" | ||
const ts = objToString(this.object).slice(8, -1); | ||
return this.object.constructor !== Object && | ||
return ((this.object.constructor !== Object && | ||
this.object.constructor && | ||
this.object.constructor.name && | ||
this.object.constructor.name !== ts | ||
? this.object.constructor.name | ||
: !Object.getPrototypeOf(this.object) | ||
? 'Null Object' | ||
: ts; | ||
this.object.constructor.name !== ts) ? | ||
this.object.constructor.name | ||
: !Object.getPrototypeOf(this.object) ? 'Null Object' | ||
: ts); | ||
} | ||
get objectAsArray() { | ||
// return the object as an actual array, if we can | ||
const value = Array.isArray(this.object) | ||
? this.object | ||
: this.isArray() | ||
? arrayFrom(this.object) | ||
const value = Array.isArray(this.object) ? this.object | ||
: this.isArray() ? arrayFrom(this.object) | ||
: null; | ||
@@ -340,6 +335,4 @@ if (value === null) { | ||
const key = this.isKeyless() ? '' : this.getKey(); | ||
const sep = !key | ||
? '' | ||
: this.parent && this.parent.isMap() | ||
? this.style.mapKeyValSep() | ||
const sep = !key ? '' | ||
: this.parent && this.parent.isMap() ? this.style.mapKeyValSep() | ||
: this.style.pojoKeyValSep(); | ||
@@ -354,23 +347,16 @@ this.memo = | ||
this.memo += | ||
this.isKey || !this.parent | ||
? '' | ||
: this.parent.isMap() | ||
? this.style.mapEntrySep() | ||
: this.parent.isBuffer() | ||
? '' | ||
: this.parent.isArray() | ||
? this.style.arrayEntrySep() | ||
: this.parent.isSet() | ||
? this.style.setEntrySep() | ||
: this.parent.isString() | ||
? '' | ||
this.isKey || !this.parent ? '' | ||
: this.parent.isMap() ? this.style.mapEntrySep() | ||
: this.parent.isBuffer() ? '' | ||
: this.parent.isArray() ? this.style.arrayEntrySep() | ||
: this.parent.isSet() ? this.style.setEntrySep() | ||
: this.parent.isString() ? '' | ||
: this.style.pojoEntrySep(); | ||
} | ||
getKey() { | ||
return this.parent && this.parent.isMap() | ||
? this.style.mapKeyStart() + | ||
return (this.parent && this.parent.isMap() ? | ||
this.style.mapKeyStart() + | ||
this.parent.child(this.key, { isKey: true }, Format).print() | ||
: typeof this.key === 'string' | ||
? JSON.stringify(this.key) | ||
: `[${this.#printSymbol(this.key)}]`; | ||
: typeof this.key === 'string' ? JSON.stringify(this.key) | ||
: `[${this.#printSymbol(this.key)}]`); | ||
} | ||
@@ -384,16 +370,10 @@ printCircular(seen) { | ||
printCollection() { | ||
return this.isError() | ||
? this.printError() | ||
: this.isSet() | ||
? this.printSet() | ||
: this.isMap() | ||
? this.printMap() | ||
: this.isBuffer() | ||
? this.printBuffer() | ||
: this.isArray() && this.objectAsArray | ||
? this.printArray() | ||
: this.isReactElement() | ||
? this.printReactElement() | ||
: // TODO streams, JSX | ||
this.printPojo(); | ||
return (this.isError() ? this.printError() | ||
: this.isSet() ? this.printSet() | ||
: this.isMap() ? this.printMap() | ||
: this.isBuffer() ? this.printBuffer() | ||
: this.isArray() && this.objectAsArray ? this.printArray() | ||
: this.isReactElement() ? this.printReactElement() | ||
// TODO streams, JSX | ||
: this.printPojo()); | ||
} | ||
@@ -725,4 +705,4 @@ nodeId() { | ||
}); | ||
return this.sort | ||
? ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
return this.sort ? | ||
ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
: ent; | ||
@@ -729,0 +709,0 @@ } |
@@ -36,4 +36,4 @@ import { Format } from './format.js'; | ||
.map(k => [k, obj[k]]); | ||
return this.sort | ||
? ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
return this.sort ? | ||
ent.sort((a, b) => String(a[0]).localeCompare(String(b[0]), 'en')) | ||
: ent; | ||
@@ -40,0 +40,0 @@ } |
@@ -24,69 +24,49 @@ import { Format } from './format.js'; | ||
const pattern = this.expect; | ||
return super.test() === true | ||
? true | ||
: // failures that would also fail in the super class | ||
// but if they didn't pass, then should fail here, too | ||
pattern == null || obj == null | ||
? false | ||
: pattern instanceof RegExp && obj instanceof RegExp | ||
? false | ||
: Buffer.isBuffer(obj) && Buffer.isBuffer(pattern) | ||
? false | ||
: typeof pattern === 'symbol' | ||
? false | ||
: // ok, Match-specific stuff | ||
pattern instanceof RegExp | ||
? pattern.test('' + obj) | ||
: typeof obj === 'string' && | ||
typeof pattern === 'string' && | ||
pattern | ||
? obj.indexOf(pattern) !== -1 | ||
: obj instanceof Date && typeof pattern === 'string' | ||
? obj.getTime() === new Date(pattern).getTime() | ||
: pattern === BigInt | ||
? typeof obj === 'bigint' | ||
: pattern === Buffer | ||
? Buffer.isBuffer(obj) | ||
: pattern === Function | ||
? typeof obj === 'function' | ||
: pattern === Number | ||
? typeof obj === 'number' && obj === obj && isFinite(obj) | ||
: pattern === String | ||
? typeof obj === 'string' | ||
: pattern === Symbol | ||
? typeof obj === 'symbol' | ||
: pattern === Boolean | ||
? typeof obj === 'boolean' | ||
: pattern === Map | ||
? this.isMap() | ||
: pattern === Set | ||
? this.isSet() | ||
: pattern === Object | ||
? obj && typeof obj === 'object' | ||
: pattern === Array | ||
? new Format(obj).isArray() | ||
: !this.isError() && pattern instanceof Error | ||
? false | ||
: this.isError() && | ||
((pattern.message && | ||
!new Match(obj.message, { | ||
expect: pattern.message, | ||
}).test()) || | ||
(pattern.name && | ||
!new Match(obj.name, { | ||
expect: pattern.name, | ||
}).test())) | ||
? false | ||
: // standard deep matching stuff, same as parent, but not simple. | ||
this.isSet() && !(pattern instanceof Set) | ||
? false | ||
: this.isMap() && !(pattern instanceof Map) | ||
? false | ||
: typeof pattern === 'function' && typeof obj === 'object' | ||
? obj instanceof pattern | ||
: typeof obj !== 'object' || typeof pattern !== 'object' | ||
? false | ||
: 'COMPLEX'; | ||
return (super.test() === true ? true | ||
// failures that would also fail in the super class | ||
// but if they didn't pass, then should fail here, too | ||
: pattern == null || obj == null ? false | ||
: pattern instanceof RegExp && obj instanceof RegExp ? false | ||
: Buffer.isBuffer(obj) && Buffer.isBuffer(pattern) ? false | ||
: typeof pattern === 'symbol' ? false | ||
// ok, Match-specific stuff | ||
: pattern instanceof RegExp ? pattern.test('' + obj) | ||
: (typeof obj === 'string' && | ||
typeof pattern === 'string' && | ||
pattern) ? | ||
obj.indexOf(pattern) !== -1 | ||
: obj instanceof Date && typeof pattern === 'string' ? | ||
obj.getTime() === new Date(pattern).getTime() | ||
: pattern === BigInt ? typeof obj === 'bigint' | ||
: pattern === Buffer ? Buffer.isBuffer(obj) | ||
: pattern === Function ? typeof obj === 'function' | ||
: pattern === Number ? | ||
typeof obj === 'number' && obj === obj && isFinite(obj) | ||
: pattern === String ? typeof obj === 'string' | ||
: pattern === Symbol ? typeof obj === 'symbol' | ||
: pattern === Boolean ? typeof obj === 'boolean' | ||
: pattern === Map ? this.isMap() | ||
: pattern === Set ? this.isSet() | ||
: pattern === Object ? obj && typeof obj === 'object' | ||
: pattern === Array ? new Format(obj).isArray() | ||
: !this.isError() && pattern instanceof Error ? false | ||
: (this.isError() && | ||
((pattern.message && | ||
!new Match(obj.message, { | ||
expect: pattern.message, | ||
}).test()) || | ||
(pattern.name && | ||
!new Match(obj.name, { | ||
expect: pattern.name, | ||
}).test()))) ? | ||
false | ||
// standard deep matching stuff, same as parent, but not simple. | ||
: this.isSet() && !(pattern instanceof Set) ? false | ||
: this.isMap() && !(pattern instanceof Map) ? false | ||
: typeof pattern === 'function' && typeof obj === 'object' ? | ||
obj instanceof pattern | ||
: typeof obj !== 'object' || typeof pattern !== 'object' ? false | ||
: 'COMPLEX'); | ||
} | ||
} | ||
//# sourceMappingURL=match.js.map |
@@ -73,44 +73,33 @@ import { createTwoFilesPatch } from 'diff'; | ||
const b = this.expect; | ||
return typeof a === 'function' && typeof b === 'function' | ||
? a === b || | ||
return (typeof a === 'function' && typeof b === 'function' ? | ||
a === b || | ||
(a.name === b.name && a.toString() === b.toString()) | ||
: typeof a === 'symbol' || typeof b === 'symbol' | ||
? typeof a === typeof b && a.toString() === b.toString() | ||
: typeof a !== 'object' && typeof b !== 'object' && a == b | ||
? true | ||
: a === b | ||
? true | ||
: a instanceof Date && b instanceof Date | ||
? a.getTime() === b.getTime() | ||
: typeof a?.valueOf === 'function' && | ||
: typeof a === 'symbol' || typeof b === 'symbol' ? | ||
typeof a === typeof b && a.toString() === b.toString() | ||
: typeof a !== 'object' && typeof b !== 'object' && a == b ? | ||
true | ||
: a === b ? true | ||
: a instanceof Date && b instanceof Date ? | ||
a.getTime() === b.getTime() | ||
: (typeof a?.valueOf === 'function' && | ||
typeof b?.valueOf === 'function' && | ||
a.valueOf() === b.valueOf() | ||
? true | ||
: typeof a?.valueOf === 'function' && a.valueOf() === b | ||
? true | ||
: typeof b?.valueOf === 'function' && b.valueOf() === a | ||
? true | ||
: a === null || b === null | ||
? a == b | ||
: a !== a | ||
? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' | ||
? false | ||
: !this.isError() && b instanceof Error | ||
? false | ||
: this.isError() && | ||
a.valueOf() === b.valueOf()) ? | ||
true | ||
: typeof a?.valueOf === 'function' && a.valueOf() === b ? true | ||
: typeof b?.valueOf === 'function' && b.valueOf() === a ? true | ||
: a === null || b === null ? a == b | ||
: a !== a ? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' ? false | ||
: !this.isError() && b instanceof Error ? false | ||
: (this.isError() && | ||
((b.message && b.message !== a.message) || | ||
(b.name && b.name !== a.name)) | ||
? false | ||
: this.isSet() && !new Format(b).isSet() | ||
? false | ||
: this.isMap() && !new Format(b).isMap() | ||
? false | ||
: this.isArray() && !new Format(b).isArray() | ||
? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) | ||
? a.equals(b) | ||
: a instanceof RegExp && b instanceof RegExp | ||
? this.regexpSame(a, b) | ||
: 'COMPLEX'; // might still be a deeper mismatch, of course | ||
(b.name && b.name !== a.name))) ? | ||
false | ||
: this.isSet() && !new Format(b).isSet() ? false | ||
: this.isMap() && !new Format(b).isMap() ? false | ||
: this.isArray() && !new Format(b).isArray() ? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) ? a.equals(b) | ||
: a instanceof RegExp && b instanceof RegExp ? | ||
this.regexpSame(a, b) | ||
: 'COMPLEX'); // might still be a deeper mismatch, of course | ||
} | ||
@@ -211,4 +200,4 @@ regexpSame(a, b) { | ||
child(obj, options, cls) { | ||
const expectKey = hasOwnProperty.call(options, 'expectKey') | ||
? options.expectKey | ||
const expectKey = hasOwnProperty.call(options, 'expectKey') ? | ||
options.expectKey | ||
: options.key; | ||
@@ -224,17 +213,11 @@ return super.child(obj, { | ||
// would have gotten the simple printed diff. | ||
return this.isSet() | ||
? key | ||
: this.isMap() | ||
? this.expect.get(key) | ||
: this.isArray() | ||
? this.expectAsArray[key] | ||
: this.expect[key]; | ||
return (this.isSet() ? key | ||
: this.isMap() ? this.expect.get(key) | ||
: this.isArray() ? this.expectAsArray[key] | ||
: this.expect[key]); | ||
} | ||
get expectAsArray() { | ||
const value = Array.isArray(this.expect) | ||
? this.expect | ||
: new Format(this.expect).isArray() | ||
? arrayFrom(this.expect) | ||
: /* c8 ignore start */ | ||
null; | ||
const value = Array.isArray(this.expect) ? this.expect | ||
: new Format(this.expect).isArray() ? arrayFrom(this.expect) | ||
: /* c8 ignore start */ null; | ||
/* c8 ignore stop */ | ||
@@ -260,6 +243,4 @@ defineProperty(this, 'expectAsArray', { value }); | ||
/* c8 ignore stop */ | ||
const sep = !key | ||
? '' | ||
: this.parent && this.parent.isMap() | ||
? this.style.mapKeyValSep() | ||
const sep = !key ? '' | ||
: this.parent && this.parent.isMap() ? this.style.mapKeyValSep() | ||
: this.style.pojoKeyValSep(); | ||
@@ -274,16 +255,10 @@ const start = this.style.start(indent, key, sep); | ||
} | ||
const end = this.parent.isMap() | ||
? this.style.mapEntrySep() | ||
: this.parent.isArray() | ||
? this.style.arrayEntrySep() | ||
: // these types are always simple printed | ||
/* c8 ignore start */ | ||
this.parent.isSet() | ||
? this.style.setEntrySep() | ||
: this.parent.isBuffer() | ||
? '' | ||
: this.parent.isString() | ||
? '' | ||
: /* c8 ignore stop */ | ||
this.style.pojoEntrySep(); | ||
const end = this.parent.isMap() ? this.style.mapEntrySep() | ||
: this.parent.isArray() ? this.style.arrayEntrySep() | ||
// these types are always simple printed | ||
: /* c8 ignore start */ | ||
this.parent.isSet() ? this.style.setEntrySep() | ||
: this.parent.isBuffer() ? '' | ||
: this.parent.isString() ? '' | ||
: /* c8 ignore stop */ this.style.pojoEntrySep(); | ||
this.memo += end; | ||
@@ -290,0 +265,0 @@ this.memoExpect += end; |
@@ -11,26 +11,18 @@ import { Format } from './format.js'; | ||
const st = super.test(); | ||
return st === false | ||
? false | ||
: a === b | ||
? true | ||
: a !== a | ||
? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' | ||
? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) | ||
? st | ||
: a instanceof Date && b instanceof Date | ||
? st | ||
: a instanceof RegExp && b instanceof RegExp | ||
? st | ||
: this.isArguments() && !new Format(b).isArguments() | ||
? false | ||
: a.constructor !== b.constructor && | ||
return (st === false ? false | ||
: a === b ? true | ||
: a !== a ? b !== b | ||
: typeof a !== 'object' || typeof b !== 'object' ? false | ||
: Buffer.isBuffer(a) && Buffer.isBuffer(b) ? st | ||
: a instanceof Date && b instanceof Date ? st | ||
: a instanceof RegExp && b instanceof RegExp ? st | ||
: this.isArguments() && !new Format(b).isArguments() ? false | ||
: (a.constructor !== b.constructor && | ||
!(Array.isArray(b) && | ||
Array.isArray(b) && | ||
a.constructor.name === b.constructor.name) | ||
? false | ||
: 'COMPLEX'; | ||
a.constructor.name === b.constructor.name)) ? | ||
false | ||
: 'COMPLEX'); | ||
} | ||
} | ||
//# sourceMappingURL=strict.js.map |
@@ -37,12 +37,12 @@ import reactElementToJsxString from './react-element-to-jsx-string.js'; | ||
nodeId: id => `&ref_${id} `, | ||
errorEmpty: er => !(er instanceof Error) | ||
? `${er.name || '(no name)'}: ${er.message || '(no message)'}` | ||
errorEmpty: er => !(er instanceof Error) ? | ||
`${er.name || '(no name)'}: ${er.message || '(no message)'}` | ||
: `${er.toString()}`, | ||
errorHead: (er, cls) => { | ||
// assertion errors sometimes generate WACKY stuff | ||
return cls === 'AssertionError' && er.generatedMessage | ||
? er.name + ' {\n' | ||
: !(er instanceof Error) | ||
? `${er.name || '(no name)'}: ${er.message || '(no message)'} \{\n` | ||
: `${er.toString()} \{\n`; | ||
return (cls === 'AssertionError' && er.generatedMessage ? | ||
er.name + ' {\n' | ||
: !(er instanceof Error) ? | ||
`${er.name || '(no name)'}: ${er.message || '(no message)'} \{\n` | ||
: `${er.toString()} \{\n`); | ||
}, | ||
@@ -49,0 +49,0 @@ errorTail: indent => `${indent}}`, |
{ | ||
"name": "tcompare", | ||
"version": "6.4.6", | ||
"version": "7.0.0", | ||
"description": "A comprehensive comparison library, for use in test frameworks", | ||
@@ -5,0 +5,0 @@ "tshy": { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
482239
4936