balagan
v0.1.0
Published
🙅 put some order to all of this mess
Readme
balagan
🙅 put some order to all of this mess
Install
npm i balaganUsage
import {
help,
hint,
note,
code,
frame,
inline,
renderAnnotated,
} from "balagan";
// Styled messages
console.log(help("run with --verbose for more info"));
console.log(hint("try using a different port"));
console.log(note("this feature is experimental"));
// Inline code styling
console.log(`Use ${code("npm start")} to begin`);
// Frame content in a tree structure
console.log(
frame("2 errors emitted", ["Missing semicolon", "Undefined variable"]),
);
// Annotate code with explanations (compiler-style)
console.log(inline`function ${["hello", "invalid name"]}() {}`);
// Output:
// function hello() {}
// ──┬──
// ╰▶ invalid name
// Or use renderAnnotated with absolute offsets
console.log(
renderAnnotated("function hello() {}", [
{ start: 9, end: 14, explain: "invalid name" },
]),
);API
help(msg)- Blue "help:" prefixed messagehint(msg)- Blue "hint:" prefixed messagenote(msg)- Blue "note:" prefixed messagecode(str)- Inline code with backticksframe(text, contents)- Tree-framed contentinline- Template tag for inline annotations with underlinesrenderAnnotated(text, markers)- Annotate text with markers at absolute offsets
License
MIT
