UNPKG

@terrazzo/token-tools

Version:

Various utilities for token types

14 lines 700 B
/** * Convert token value to a JS string via acorn/astring. * @deprecated */ export function transformJSValue(token, { indent = 2, startingIndent = 0 }) { const indentStart = startingIndent > 0 ? ' '.repeat(startingIndent ?? 2) : ''; // note: since tokens are JSON-serializable to begin with, using // JSON.stringify generates the same output as an AST parser/generator would // but faster and without the added overhead (even acorn/astring leave object // keys quoted). // TODO: use @biomejs/js-api when it’s stable for pretty formatting return JSON.stringify(token.$value, undefined, indent).replaceAll('\n', `\n${indentStart}`); } //# sourceMappingURL=index.js.map