Package detail

sb-fs

steelbrain566MIT4.0.0

Promisified fs for Node.js

sb, fs, promise

readme

FS

sb-fs is a Node.js module that exports a promisified FS.

Installation

npm install --save sb-fs

API

export promisifyAll(*) from 'fs'
export function exists(path: string): Promise<boolean>
export function readFile(path: string): Promise<string>
// ^ Returns a BOM stripped string

Usage

import { readFile, exists, createReadStream, createWriteStream } from "sb-fs";

export default async function freedom() {
  console.log(await readFile(__filename));
  console.log(
    (await exists("/path/to/humanity")) ? "it exists!!" : "Naah it doesnt exist"
  );
  createReadStream("source.js").pipe(createWriteStream("target.js"), {
    end: true
  });
}

License

This package is licensed under the terms of MIT License. See the LICENSE file for more info.

changelog

4.0.0

  • Upgrade all dependencies
  • Require at least node v8

3.0.0

  • Remove mkdirp and rimraf to make the package lightweight
  • Return a buffer or string depending on encoding in readFile instead of a string each time

2.0.0

  • Make FS.readFile return a BOM stripped string

1.1.1

  • Fix a bug where sync methods like createReadStream and classes like ReadStream would be promisified

1.1.0

  • Add exists method

1.0.0

  • Initial implementation