tersify
One readable line for any value — built for error messages, logs, and assertions.
tersify turns any JavaScript value — a primitive, an object, an array, a class instance, a
function — into a short string you can put in an error message without drowning the reader in it.
JSON.stringify refuses functions, loses classes, and throws on cycles. util.inspect is Node-only
and formats for a terminal. tersify is neither: it produces one compact, length-bounded string that
works the same in Node and in the browser.
What it gives you
Section titled “What it gives you”Bounded outputmaxLength caps the result so a log line stays a log line.
Everything rendersFunctions, classes, symbols, bigints, Buffers, Dates, RegExps.
Cycles are safeA revisited value renders as a reference instead of throwing.
Your own formatGive a type a .tersify() method and tersify uses it.
Where to go next
Section titled “Where to go next”- Introduction — the problem it solves and when to reach for it.
- Installation — install, import, and the Node/browser split.
- Options —
maxLength,indent, andraw. - Reference — every export, one page each.