key-value-file
Version:
A simple key/value file parser/writer
33 lines (32 loc) • 1.1 kB
TypeScript
/// <reference types="node" />
import { PathLike, WriteFileOptions } from 'fs';
import { KeyValue } from './keyvalue';
import { Token } from './token';
/**
* Read/write a key/value file
*/
export declare class KeyValueFile extends KeyValue {
/** Returns the path of the key/value file */
get path(): PathLike;
/**
* Creates an instance of {@link KeyValueFile}. If `path` exists it is
* loaded.
*/
static create(path: PathLike): Promise<KeyValueFile>;
private _path;
/**
* Constructor
*
* @param path The path of the key/value file
* @param tokens The tokens of the file {@see tokenize:tokenize()|tokenize()}
*/
constructor(path: PathLike, tokens?: Token[]);
/**
* Save the file to disk
* @param collapseWhitespace If `true` all unnecessary whitespace will
* be removed
* @param options Options passed to {@link
* https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback | fs.writeFile}
*/
writeFile(collapseWhitespace?: boolean, options?: WriteFileOptions): Promise<this>;
}