coldstitch
Version:
A code generation library, that helps you craft code snippets in code for multiple languages
27 lines (26 loc) • 1.34 kB
TypeScript
import { CodeFormatOptions, CodeIndentOptions } from "./format";
import { TypeRef } from "./types";
type ObjectBoundaryTokens = [string, string];
export interface ObjectFormatter {
objectTokens: ObjectBoundaryTokens;
arrayTokens: ObjectBoundaryTokens;
inlineArrayElements?: boolean;
assignToken: string;
formatKey(key: string): string;
formatValue(value: any): string;
}
type IndentLevel = {
indentLevel?: number;
};
type Reference = Record<string, any> | any[];
export declare function stringify(reference: Reference, formatter: ObjectFormatter, options?: Partial<CodeFormatOptions> & IndentLevel): string;
export declare function createTemplateStringsArray(literals: string[]): TemplateStringsArray;
export declare function resolveLineIndentation(line: string): CodeIndentOptions;
export declare function getLineIndentation(line: string): string;
export declare function resolveIndentation(code: string): CodeIndentOptions;
export declare function lastItem<T>(array: T[]): T | undefined;
export declare function groupTypesByNamespace<T extends TypeRef = TypeRef>(types: T[]): Record<string, T[]>;
export declare function escapeStringQuotes(value: string, quoteChar?: string): string;
export declare function isPlainObject(value: any): boolean;
export declare function isScalar(value: any): boolean;
export {};