Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

load-text-file

LinusU4.3kMIT2.0.0TypeScript support: included

Strips UTF-8 BOM, uses graceful-fs, and returns Promises.

file, fs, graceful, load, parse, read, text

readme

load-text-file

Strips UTF-8 BOM, uses graceful-fs, and returns Promises.

Install

npm install --save load-text-file

Usage

import { loadTextFile } from 'load-text-file'

const text = await loadTextFile('foo.txt')
console.log(text)
//=> Hello, World!

Sync

import { loadTextFileSync } from 'load-text-file'

const text = loadTextFileSync('foo.txt')
console.log(text)
//=> Hello, World!

API

loadTextFile(path)

  • path (string | Buffer | URL, required)
  • returns Promise<string> - a promise for the text content

loadTextFileSync(path)

  • path (string | Buffer | URL, required)
  • returns string - the text content