cute
A Typescript tool library to stringify and output values to the console.
It can be used as an alternative to Node's util.inspect
or JSON.stringify
.
This library is quite similar to stringify-object but it also handles:
- big integers,
- console colors.
It has no dependencies and can work in any environment.
Stringify API
export function stringify(
value: unknown,
options?: Partial<StringifyOptions>
): string
export type StringifyOptions = {
maxCharacters: number = 24
indent: string = ' '
level: number = 0
colors: boolean = false
theme: Record<ThemeToken, string>
}
Usage
import { stringify } from "@digitak/cute"
console.log(stringify({ foo: 12, bar: "12" }))
console.log(stringify({ foo: 12, bar: "12" }, {
indentation: '\t',
colors: true,
}))
Colors API
This library also export ASCII colors.
You can import them separately or under a namespace.
import { red, blue, brightCyan } from "@digitak/cute/colors"
import * as colors from "@digitak/cute/colors"