Read the contents of file from the filesystem.
npm install @wrote/read
@wrote/read is a package to read a file as a string or a Buffer.
``sh`
yarn add -E @wrote/read
- Table Of Contents
- API
- async read(path: string): string
- async readBuffer(path: string): Buffer
- Copyright
The package is available by importing its default function read, and named function readBuffer:
`js`
import read, { readBuffer } from '@wrote/read'
path: string,
): stringRead the file as a string.
`js
/ yarn example/ /
import read from '@wrote/read'
(async () => {
const res = await read('example/data.txt')
console.log(res)
})()
```
Hello World
path: string,
): BufferRead the file as a Buffer.
`js
/ yarn example/ /
import { readBuffer } from '@wrote/read'
(async () => {
const res = await readBuffer('example/data.txt')
console.log(res)
})()
````
![]() | © Art Deco for Wrote 2019 | alt="Tech Nation Visa" /> | Tech Nation Visa Sucks |
|---|