UNPKG

read-file-string

Version:

Returns file content as a UTF-8 string. Returns null if file does not exist (or is a directory) instead of throwing an Error.

24 lines 861 B
/** @module read-file-string */ declare module "read-file-string" { /** * @function * @param {string} file Path to a file * @returns {Promise<string|null>} File contents in UTF-8 or null if file could not be read * @example * import readFileString from "read-file-string" * const result = await readFileString("readme.md") * result === "## Hewwo OwO" */ export default function(file: string): Promise<string | null>; /** * @function * @param {string} file Path to a file * @returns {string|null} File contents in UTF-8 or null if file could not be read * @example * import {readFileStringSync} from "read-file-string" * const result = readFileStringSync("readme.md") * result === "## Hewwo OwO" */ export function readFileStringSync(file: string): string | null; }