Champions:
- @JakobJingleheimer
Authors:
- @JakobJingleheimer
Current: 1 (30 May 2025)
Detailed inspection information in a human-friendly way, such as when comparing (diffing) values.
In the context of Comparisons, merely knowing A
is unexpected is almost useless when you can't see what A
and B
are.
examples (current native capability)
Annoying:
if (A !== B) throw new Error('A does not equal B');
// Error: A does not equal B
Better
if (A !== B) throw new Error(`${A} does not equal ${B}`);
// Error: 1 does not equal 2
But brittle
if (A !== B) throw new Error(`${A} does not equal ${B}`);
// Error: [object Object] does not equal [object Object]
examples (the general desire)
const result = compare(A, B);
{
pretty: `{
…
✓ qux: 'a',
✗ qux: 'b',
…
}`,
paths: ['foo.bar.qux'],
expected: 'a',
actual: 'b',
}
- Very expensive for userland to compose (the vast majority of test runner execution time)
- Pretty printing
- Special access (requires Modes - will not be available in "production"):
- Proxies
- Constituents of expressions (compiler)
- Constituents of structure (diff)
- Internal slots
- Broadly applicable: can be used by more than Comparisons (e.g. Pattern Matching could leverage this; it could be used entirely on its own).
Currently, there are several libraries in userland that provide this functionality in varying ways.
Runtimes (can offer special access):
- Bun
inspect
- Does not offer special access
- Node.js
util.inspect
(also used by Deno)- Offers special access (ex
showProxy
)
- Offers special access (ex
Libraries (cannot offer special access):
- Consider customisation/extensibility (public symbols?)
- This is potentially especially important for frameworks that may want to utilise Inspector under the hood and want to tweak only a very small piece.
- Determine what information to provide, how, and under what cicumstances.
- Modes as a requirement to offer "special access".