0.1.5 • Published 7 years ago

fse-promise v0.1.5

Weekly downloads
1
License
MIT
Repository
github
Last release
7 years ago

fse-promise

Promisified version of Node fs and fs-extra that preserves callbacks.

NPM version

Install

npm install fse-promise

Usage

Drop-in replacement for Node fs and fs-extra module.

All Node fs and fs-extra asynchronous methods are wrapped so that they return a promise if callback is not provided. If callback is defined then the method works as defined in fs and fs-extra.

Check index.js for list of supported methods. If you notice any missing methods in that list, add it and create PR to get it added.

Example usage:

const fs = require('fse-promise');

// using callbacks
fs.readFile(filepath, (err, data) => {
	if (err) return console.error(err);
	console.log(data);

	fs.outputFile(filepath, (err, data => {
		if (err) return console.error(err);
		console.log('saved');
	}));
});

// using promises
fs.readFile(filepath)
	.then((data) => {
		console.log(data);

		return fs.outputFile(filepath);
	})
	.then(() => {
		console.log('saved');
	})
	.catch((err) => {
		console.error(err);
	});
0.1.5

7 years ago

0.1.4

7 years ago

0.1.3

7 years ago

0.1.2

8 years ago

0.1.1

8 years ago

0.1.0

8 years ago