svelte-ast-print
Version:
Serialize Svelte AST nodes into stringified syntax. A.k.a parse in reverse.
43 lines • 1.13 kB
JavaScript
/**
* @internal
* Gives us a better control on transforming passed options.
*/
export class Options {
static DEFAULT_INDENT = "tab";
static DEFAULT_ORDER = /** @type {const} */ [
"options",
"module",
"instance",
"fragment",
"css",
];
static INDENT = new Map(
/** @type {const} */ [
["tab", "\t"],
["2-space", " "],
["4-space", " "],
]);
/**
* _(before transformation)_ - for better DX
*/
/**
* @param raw provided options by user - before transformation
*/
constructor(raw) {
this.
}
get indent() {
const { format } = this.
const transformed = Options.INDENT.get(format?.indent ?? Options.DEFAULT_INDENT);
if (!transformed) {
throw new Error(`Unrecognized indent name - ${format?.indent}, allowed are: ${[...Options.INDENT.keys()]}`);
}
return transformed;
}
get order() {
const { root } = this.
return root?.order ?? Options.DEFAULT_ORDER;
}
}
//# sourceMappingURL=option.js.map