nfw

node-fs-writefile-promise

fs.writeFile wrapped in an ES6 Promise

Showing:

Popularity

Downloads/wk

28

GitHub Stars

1

Maintenance

Last Commit

5yrs ago

Contributors

0

Package

Dependencies

1

License

MIT

Type Definitions

Tree-Shakeable

No?

Categories

Readme

node-fs-writefile-promise

NPM version Build Status Build status Coverage Status Dependency Status devDependency Status

fs.writeFile wrapped in an ES6 Promise

const writeFile = require('node-fs-writefile-promise');

writeFile('path/to/file', 'string or buffer data')
  .then(() => console.log('data written successfully to disk'))
  .catch(err => console.error(err.message));

A simple ES6 Promise-based wrapper around Node's built-in writeFile.

Installation

npm i node-fs-writefile-promise

npm install docs

API

const writeFile = require('node-fs-writefile-promise');

writeFile(file, data [, options])

file: String | Buffer | Integer filename or file descriptor
data: String | Buffer
options: Object | String (fs.writeFile options)

Returns: (Promise)

Once the file is written, the returned promise will be resolved with no arguments.

If there is an error, the returned promise will be rejected with an error as its first argument.

const writeFile = require('node-fs-writefile-promise');

const onFulfilled = () => console.log('File written successfully');
const onRejected = err => console.log('Cannot write to the file');

writeFile('path/to/file', 'string or buffer data').then(onFulfilled, onRejected);

writeFile('path/to/file', 'string or buffer data')
  .then(onFulfilled)
  .catch(onRejected);

License

Copyright (c) 2014 - 2016 Stephen Meyerhofer

Licensed under the MIT License.

Rate & Review

Great Documentation0
Easy to Use0
Performant0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Slow0
Buggy0
Abandoned0
Unwelcoming Community0
100
No reviews found
Be the first to rate

Alternatives

No alternatives found

Tutorials

No tutorials found
Add a tutorial