@terrazzo/token-tools
Version:
Various utilities for token types
13 lines (12 loc) • 457 B
JavaScript
//#region src/js/index.ts
/**
* Convert token value to a JS string via acorn/astring.
*/
function transformJSValue(token, { mode, indent = 2, startingIndent = 0 }) {
if (!(mode in token.mode)) return;
const indentStart = startingIndent > 0 ? " ".repeat(startingIndent ?? 2) : "";
return JSON.stringify(token.mode[mode].$value, void 0, indent).replace(/\n/g, `\n${indentStart}`);
}
//#endregion
export { transformJSValue };
//# sourceMappingURL=js.js.map