@gulujs/toml
Version:
TOML parser and serializer
32 lines (31 loc) • 1.55 kB
TypeScript
import { ObjectPath } from '@gulujs/object-path';
import { AnySchema, Key, KeyValueSchema, Schema, SimpleSchemaType, SplitFn } from '../schema.js';
import { Converter } from '../../converter/index.js';
export type GlobalSplitFn = (value: string, path: Array<string | number>) => string[];
export interface StringifyValueOptions {
simpleMode?: boolean;
topLevel: boolean;
objectPath: ObjectPath;
newline: '\n' | '\r\n';
treatFunctionAsObject?: boolean;
preferQuote: "'" | '"';
preferOneLineString?: boolean;
escapeTabChar?: boolean;
globalStringSplitter?: GlobalSplitFn;
schemaStringSplitters?: Record<string, SplitFn>;
integerConverter: Converter<unknown>;
floatConverter: Converter<unknown>;
datetimeConverter: Converter<unknown>;
strict?: boolean;
}
type AssertorFn = (value: any, options: StringifyValueOptions, path: Array<Key | number>) => void;
type SerializerFn = (value: any, schema: any, options: StringifyValueOptions, path: Array<Key | number>) => string;
export declare const valueAssertors: {
[key in SimpleSchemaType]: AssertorFn;
};
export declare const valueSerializers: {
[key in SimpleSchemaType]: SerializerFn;
};
export declare function serializeSimpleTypeValue(value: unknown, schema: Exclude<KeyValueSchema, AnySchema>, options: StringifyValueOptions, path: Array<Key | number>): string;
export declare function tryStringifyKeyValue(value: unknown, schema: Schema, options: StringifyValueOptions, path: Array<Key | number>, lines: string[]): boolean;
export {};