import type { GenericEmbedded } from './embedded'; import type { Value } from './values'; import { Annotated } from './annotated'; import { Bytes } from './bytes'; import { KeyedDictionary, KeyedSet } from './dictionary'; import { Writer, Writable, WriterOptions } from './writer'; export function stringify(x: any, options?: WriterOptions): string { return Writer.stringify(x as Writable, options); } export function preserves(pieces: TemplateStringsArray, ...values: Value[]): string { const result = [pieces[0]]; values.forEach((v, i) => { result.push(stringify(v)); result.push(pieces[i + 1]); }); return result.join(''); } [Annotated, Bytes, KeyedDictionary, KeyedSet].forEach((C) => { C.prototype.toString = function () { return stringify(this); }; });