@hyperlane-xyz/utils
Version:
General utilities and types for the Hyperlane network
31 lines • 1.31 kB
TypeScript
import { DocumentOptions, ParseOptions, SchemaOptions, ToJSOptions } from 'yaml';
type YamlParseOptions = ParseOptions & DocumentOptions & SchemaOptions & ToJSOptions;
/**
* Parses YAML content with sensible defaults.
* @see stackoverflow.com/questions/63075256/why-does-the-npm-yaml-library-have-a-max-alias-number
*/
export declare function yamlParse<T>(content: string, options?: YamlParseOptions): T;
/**
* Reads and parses a YAML file.
*/
export declare function readYaml<T>(filepath: string): T;
/**
* Attempts to read and parse a YAML file, returning null if it fails.
*/
export declare function tryReadYaml<T>(filepath: string): T | null;
/**
* Writes an object as YAML to a file with a trailing newline.
* Uses stringifyObject to properly handle ethers BigNumber serialization.
*/
export declare function writeYaml(filepath: string, obj: unknown): void;
/**
* Merges an object with existing YAML file content and writes the result.
* If the file doesn't exist, writes the object directly.
*/
export declare function mergeYaml<T extends Record<string, unknown>>(filepath: string, obj: T): void;
/**
* Reads YAML from a directory with the specified filename.
*/
export declare function readYamlFromDir<T>(directory: string, filename: string): T;
export {};
//# sourceMappingURL=yaml.d.ts.map