Update the bundled fstream to v0.1.14

This commit is contained in:
Nathan Rajlich 2012-03-19 19:09:41 -07:00
parent 6efb29b326
commit eac48fe38b
10 changed files with 262 additions and 20 deletions

4
node_modules/fstream/.npmignore generated vendored
View file

@ -1,3 +1,5 @@
.*.swp
examples/deep-copy
node_modules/
examples/deep-copy/
examples/path/
examples/filter-copy/

25
node_modules/fstream/LICENCE generated vendored Normal file
View file

@ -0,0 +1,25 @@
Copyright (c) Isaac Z. Schlueter
All rights reserved.
The BSD License
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions
are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.

131
node_modules/fstream/examples/filter-pipe.js generated vendored Normal file
View file

@ -0,0 +1,131 @@
var fstream = require("../fstream.js")
var path = require("path")
var r = fstream.Reader({ path: path.dirname(__dirname)
, filter: function () {
return !this.basename.match(/^\./) &&
!this.basename.match(/^node_modules$/)
!this.basename.match(/^deep-copy$/)
!this.basename.match(/^filter-copy$/)
}
})
// this writer will only write directories
var w = fstream.Writer({ path: path.resolve(__dirname, "filter-copy")
, type: "Directory"
, filter: function () {
return this.type === "Directory"
}
})
var indent = ""
var escape = {}
r.on("entry", appears)
r.on("ready", function () {
console.error("ready to begin!", r.path)
})
function appears (entry) {
console.error(indent + "a %s appears!", entry.type, entry.basename, typeof entry.basename)
if (foggy) {
console.error("FOGGY!")
var p = entry
do {
console.error(p.depth, p.path, p._paused)
} while (p = p.parent)
throw new Error("\033[mshould not have entries while foggy")
}
indent += "\t"
entry.on("data", missile(entry))
entry.on("end", runaway(entry))
entry.on("entry", appears)
}
var foggy
function missile (entry) {
if (entry.type === "Directory") {
var ended = false
entry.once("end", function () { ended = true })
return function (c) {
// throw in some pathological pause()/resume() behavior
// just for extra fun.
process.nextTick(function () {
if (!foggy && !ended) { // && Math.random() < 0.3) {
console.error(indent +"%s casts a spell", entry.basename)
console.error("\na slowing fog comes over the battlefield...\n\033[32m")
entry.pause()
entry.once("resume", liftFog)
foggy = setTimeout(liftFog, 1000)
function liftFog (who) {
if (!foggy) return
if (who) {
console.error("%s breaks the spell!", who && who.path)
} else {
console.error("the spell expires!")
}
console.error("\033[mthe fog lifts!\n")
clearTimeout(foggy)
foggy = null
if (entry._paused) entry.resume()
}
}
})
}
}
return function (c) {
var e = Math.random() < 0.5
console.error(indent + "%s %s for %d damage!",
entry.basename,
e ? "is struck" : "fires a chunk",
c.length)
}
}
function runaway (entry) { return function () {
var e = Math.random() < 0.5
console.error(indent + "%s %s",
entry.basename,
e ? "turns to flee" : "is vanquished!")
indent = indent.slice(0, -1)
}}
w.on("entry", attacks)
//w.on("ready", function () { attacks(w) })
function attacks (entry) {
console.error(indent + "%s %s!", entry.basename,
entry.type === "Directory" ? "calls for backup" : "attacks")
entry.on("entry", attacks)
}
ended = false
var i = 1
r.on("end", function () {
if (foggy) clearTimeout(foggy)
console.error("\033[mIT'S OVER!!")
console.error("A WINNAR IS YOU!")
console.log("ok " + (i ++) + " A WINNAR IS YOU")
ended = true
// now go through and verify that everything in there is a dir.
var p = path.resolve(__dirname, "filter-copy")
var checker = fstream.Reader({ path: p })
checker.checker = true
checker.on("child", function (e) {
var ok = e.type === "Directory"
console.log((ok ? "" : "not ") + "ok " + (i ++) +
" should be a dir: " +
e.path.substr(checker.path.length + 1))
})
})
process.on("exit", function () {
console.log((ended ? "" : "not ") + "ok " + (i ++) + " ended")
})
r.pipe(w)

View file

@ -123,6 +123,9 @@ DirWriter.prototype._process = function () {
// get rid of any ../../ shenanigans
props.path = path.join(me.path, path.join("/", p))
// if i have a filter, the child should inherit it.
props.filter = me.filter
// all the rest of the stuff, copy over from the source.
Object.keys(entry.props).forEach(function (k) {
if (!props.hasOwnProperty(k)) {

View file

@ -59,6 +59,9 @@ ProxyReader.prototype._addProxy = function (proxy) {
, "close"
, "linkpath"
, "entry"
, "entryEnd"
, "child"
, "childEnd"
, "warn"
].forEach(function (ev) {
// console.error("~~ proxy event", ev, me.path)

9
node_modules/fstream/lib/writer.js generated vendored
View file

@ -98,6 +98,8 @@ function Writer (props, current) {
me._buffer = []
me.ready = false
me.filter = typeof props.filter === "function" ? props.filter: null
// start the ball rolling.
// this checks what's there already, and then calls
// me._create() to call the impl-specific creation stuff.
@ -126,6 +128,13 @@ Writer.prototype._stat = function (current) {
else fs[stat](me._path, statCb)
function statCb (er, current) {
if (me.filter && !me.filter.call(me._proxy || me, current)) {
me._aborted = true
me.emit("end")
me.emit("close")
return
}
// if it's not there, great. We'll just create it.
// if it is there, then we'll need to change whatever differs
if (er || !current) {

View file

@ -6,8 +6,7 @@ var fs = require("fs")
// there is such a thing as TOO graceful.
if (fs.open === gracefulOpen) return
var FastList = require("fast-list")
, queue = new FastList()
var queue = []
, curOpen = 0
, constants = require("constants")

View file

@ -1,8 +1,12 @@
{
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me)",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me"
},
"name": "graceful-fs",
"description": "fs monkey-patching to avoid EMFILE and other problems",
"version": "1.1.5",
"version": "1.1.6",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/node-graceful-fs.git"
@ -11,8 +15,21 @@
"engines": {
"node": ">=0.4.0"
},
"dependencies": {
"fast-list": "1"
"devDependencies": {},
"_npmUser": {
"name": "tootallnate",
"email": "nathan@tootallnate.net"
},
"devDependencies": {}
"_id": "graceful-fs@1.1.6",
"dependencies": {},
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.9",
"_nodeVersion": "v0.6.13",
"_defaultsLoaded": true,
"dist": {
"shasum": "d0d5fb3ff6c6d625a071bc5061a44b0efc4a1f47"
},
"_from": "graceful-fs@~1.1.2",
"scripts": {}
}

View file

@ -1,7 +1,41 @@
{ "name" : "inherits"
, "description": "A tiny simple way to do classic inheritance in js"
, "version" : "1.0.0"
, "keywords" : ["inheritance", "class", "klass", "oop", "object-oriented"]
, "main" : "./inherits.js"
, "repository" : "https://github.com/isaacs/inherits"
, "author" : "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)" }
{
"name": "inherits",
"description": "A tiny simple way to do classic inheritance in js",
"version": "1.0.0",
"keywords": [
"inheritance",
"class",
"klass",
"oop",
"object-oriented"
],
"main": "./inherits.js",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/inherits.git"
},
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"_npmUser": {
"name": "tootallnate",
"email": "nathan@tootallnate.net"
},
"_id": "inherits@1.0.0",
"dependencies": {},
"devDependencies": {},
"optionalDependencies": {},
"engines": {
"node": "*"
},
"_engineSupported": true,
"_npmVersion": "1.1.9",
"_nodeVersion": "v0.6.13",
"_defaultsLoaded": true,
"dist": {
"shasum": "662904d1fe699d60dacc7d5c16d1c05debd3c9a1"
},
"_from": "inherits@1.x"
}

29
node_modules/fstream/package.json generated vendored
View file

@ -1,15 +1,19 @@
{
"author": "Isaac Z. Schlueter <i@izs.me> (http://blog.izs.me/)",
"author": {
"name": "Isaac Z. Schlueter",
"email": "i@izs.me",
"url": "http://blog.izs.me/"
},
"name": "fstream",
"description": "Advanced file system stream things",
"version": "0.1.13",
"version": "0.1.14",
"repository": {
"type": "git",
"url": "git://github.com/isaacs/fstream.git"
},
"main": "fstream.js",
"engines": {
"node": "0.5 || 0.6 || 0.7"
"node": ">=0.6"
},
"dependencies": {
"rimraf": "2",
@ -18,9 +22,24 @@
"inherits": "~1.0.0"
},
"devDependencies": {
"tap": "0.1"
"tap": ""
},
"scripts": {
"test": "tap examples/*.js"
}
},
"license": "BSD",
"_npmUser": {
"name": "tootallnate",
"email": "nathan@tootallnate.net"
},
"_id": "fstream@0.1.14",
"optionalDependencies": {},
"_engineSupported": true,
"_npmVersion": "1.1.9",
"_nodeVersion": "v0.6.13",
"_defaultsLoaded": true,
"dist": {
"shasum": "f5941062531126749ce385aed910e5fbac5edaee"
},
"_from": "fstream@0.1.14"
}