Wrap a value such that its use as a substitution value in a template
literal tagged with details or Fail will result in it
appearing quoted (in a way similar to but more general than
JSON.stringify) rather than redacted in the message of errors based on
the resulting DetailsToken.
This does not affect representation in output of an associated console,
which still logs the value as it would without quote, but does reveal
it to functions in the propagation path of such errors.
For example, the following will reveal the expected value in the thrown
error's message, but only the type of the actual incorrect value (using
the normal convention to locally rename properties like
const { quote: q, Fail } = assert;):
actual === expected || Fail`${actual} should be ${q(expected)}`;
The optional space parameter matches that of JSON.stringify, and is
used to request insertion of non-semantic line feeds, indentation, and
separating spaces in the output for improving readability of objects and
arrays.
Wrap a value such that its use as a substitution value in a template literal tagged with details or Fail will result in it appearing quoted (in a way similar to but more general than
JSON.stringify) rather than redacted in themessageof errors based on the resulting DetailsToken.This does not affect representation in output of an associated console, which still logs the value as it would without
quote, but does reveal it to functions in the propagation path of such errors.For example, the following will reveal the expected value in the thrown error's
message, but only the type of the actual incorrect value (using the normal convention to locally rename properties likeconst { quote: q, Fail } = assert;):The optional
spaceparameter matches that ofJSON.stringify, and is used to request insertion of non-semantic line feeds, indentation, and separating spaces in the output for improving readability of objects and arrays.