rx-fs
v1.0.0-alpha.2
Published
RxJs wrapper for Node's fs module.
Readme
RxFs
This is an RxJS wrapper for the Node.js fs module. It is intended to track the fs API as closely as possible, with the following exceptions:
- If the fs method expects a callback, the RxFs method instead returns an Observable.
- If the fs method creates a stream, RxFs has an analogous method that creates an Observable, with
Streamreplaced byObservablein the name. Where you would usepipefor streams, you can useletfor RxFs. For example,RxFs.createReadStreamcreates a stream andRxFs.createReadObservablecreates an observable. - The result from calling
fs.createReadObservablehas propertyopenSource, which is an observable indicating the file has been opened.
Example: move old.txt to new.txt
var RxFs = require('rx-fs');
var inputPath = './old.txt';
var outputPath = './new.txt';
var source = RxFs.createReadObservable(inputPath);
var sink = RxFs.createWriteObservable(outputPath);
return source
.let(sink)
.subscribeOnCompleted(function() {
RxFs.unlink(inputPath).subscribeOnCompleted(done);
});Not all methods are currently fully tested. API may change to better reflect latest version of fs API. Pull requests welcome!
See also this alternative that has a more full-featured API but does not match the current node fs API.
