Skip to content

Commit

Permalink
Initial version.
Browse files Browse the repository at this point in the history
  • Loading branch information
Gozala committed Aug 4, 2011
0 parents commit d3f7bcc
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 0 deletions.
44 changes: 44 additions & 0 deletions fs.js
@@ -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)
})
}
}
34 changes: 34 additions & 0 deletions package.json
@@ -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"
}]
}

0 comments on commit d3f7bcc

Please sign in to comment.