Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit d3f7bcc
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* vim:set ts=2 sw=2 sts=2 expandtab */ | ||
/*jshint asi: true undef: true es5: true node: true devel: true | ||
forin: true latedef: false supernew: true */ | ||
/*global define: true exports: true */ | ||
|
||
"use strict"; | ||
|
||
var fs = require('fs') | ||
|
||
exports.list = function list(path) { | ||
return function stream(next, stop) { | ||
fs.readdir(path, function callback(error, entries, entry) { | ||
if (!error) while ((entry = entries.shift())) next(entry) | ||
stop(error) | ||
}) | ||
} | ||
} | ||
|
||
exports.readFile = function readFile(path, encoding) { | ||
var args = Array.prototype.slice.call(arguments) | ||
return function stream(next, stop) { | ||
fs.readFile.apply(null, args.concat([function callback(error, data) { | ||
if (!error) next(data) | ||
stop(error) | ||
}])) | ||
} | ||
} | ||
|
||
exports.writeFile = function writeFile(path, data, encoding) { | ||
var args = Array.prototype.slice.call(arguments) | ||
return function stream(next, stop) { | ||
fs.writeFile.apply(null, args.concat([ stop ])) | ||
} | ||
} | ||
|
||
exports.stat = function stat(path) { | ||
return function stream(next, stop) { | ||
var descriptor = { path: { value: path, enumerable: true } } | ||
fs.stat(path, function callback(error, stats) { | ||
if (!error) next(Object.create(stats, descriptor)) | ||
stop(error) | ||
}) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
{ | ||
"name": "fs-streamer", | ||
"id": "fs-streamer", | ||
"version": "0.0.1", | ||
"description": "streamer 4 fs", | ||
"keywords": [ "fs", "file-system", "stream" ], | ||
"author": "Irakli Gozalishvili <rfobic@gmail.com> (http://jeditoolkit.com)", | ||
"homepage": "https://github.com/Gozala/fs-streamer", | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/Gozala/fs-streamer.git", | ||
"web": "https://github.com/Gozala/fs-streamer" | ||
}, | ||
"bugs": { | ||
"web": "http://github.com/Gozala/fs-streamer/issues/" | ||
}, | ||
"devDependencies": { | ||
"test": ">=0.0.10" | ||
}, | ||
"dependencies": { | ||
"streamer": ">=0.6.1" | ||
}, | ||
"main": "./index.js", | ||
"engines": { | ||
"node": "0.4.x" | ||
}, | ||
"scripts": { | ||
"test": "node tests/test-fs-streamer.js" | ||
}, | ||
"licenses": [{ | ||
"type" : "MIT", | ||
"url" : "http://jeditoolkit.com/LICENSE" | ||
}] | ||
} |