Coder Social home page Coder Social logo

fs-promise's Introduction

fs-promise

Build Status

var fsp = require('fs-promise');

fsp.writeFile('/tmp/hello1.txt', 'hello world')
  .then(function(){
    return fsp.readFile('/tmp/hello1.txt', {encoding:'utf8'});
  })
  .then(function(contents){});

Implementation

fs-promise is now a thin wrapper on top of mz/fs adding support for async functions from fs-extra. If you do not need the functions from fs-extra, consider using mz directly.

  • Proxies async fs and fs-extra methods exposing them as ES 2015 (ES6) compatible promises.
  • Uses any-promise to load preferred Promise implementation.
  • Directly uses mz/fs for all fs functions.
  • Proxies walk from fs-extra to resolve Promise as arrays of items.
  • Proxies the following functions from fs-extra using thenify-all. (Proxies all other functions directly).
[
  'copy',
  'emptyDir',
  'ensureFile',
  'ensureDir',
  'ensureLink'
  'ensureSymlink',
  'mkdirs',
  'move',
  'outputFile',
  'outputJson',
  'readJson',
  'remove',
  'writeJson'
]

Usage

Detects a Promise implementation using any-promise. If you have a preferred implementation, or are working in an environment without a global implementation, you must explicitly register a Promise implementation and it will be used. See any-promise for details.

Typical installation:

$ npm install --save fs-promise

Note that fs-extra depends on graceful-fs, so you will get the benefits of both libraries.

fs-promise's People

Contributors

jonathantneal avatar kevinbeaty avatar kittygiraudel avatar pcdevil avatar shinnn avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.