load-text-file
TypeScript icon, indicating that this package has built-in type declarations

2.0.0 • Public • Published

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

Related

/load-text-file/

    Package Sidebar

    Install

    npm i load-text-file

    Weekly Downloads

    38

    Version

    2.0.0

    License

    MIT

    Unpacked Size

    2.87 kB

    Total Files

    6

    Last publish

    Collaborators

    • linusu