JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 450
  • Score
    100M100P100Q97591F
  • License MIT

Read the contents of file from the filesystem.

Package Exports

  • @wrote/read

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@wrote/read) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@wrote/read

npm version

@wrote/read is a package to read a file as a string or a Buffer.

yarn add -E @wrote/read

Table Of Contents

API

The package is available by importing its default function read, and named function readBuffer:

import read, { readBuffer } from '@wrote/read'

async read(
  path: string,
): string

Read the file as a string.

/* yarn example/ */
import read from '@wrote/read'

(async () => {
  const res = await read('example/data.txt')
  console.log(res)
})()
Hello World

async readBuffer(
  path: string,
): Buffer

Read the file as a Buffer.

/* yarn example/ */
import { readBuffer } from '@wrote/read'

(async () => {
  const res = await readBuffer('example/data.txt')
  console.log(res)
})()
<Buffer 48 65 6c 6c 6f 20 57 6f 72 6c 64>

Art Deco © Art Deco for Wrote 2019 Wrote Tech Nation Visa Tech Nation Visa Sucks