Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Add a disown method to un-hook child entries

  • Loading branch information...
commit ac337f91e1c2bd6576398d8b350c3627e424644b 1 parent 349eb9d
@isaacs isaacs authored
Showing with 16 additions and 3 deletions.
  1. +16 −3 lib/dir-reader.js
View
19 lib/dir-reader.js
@@ -101,13 +101,13 @@ DirReader.prototype._read = function () {
// This nomenclature is not completely final.
entry.on("pause", function (who) {
- if (!me._paused) {
+ if (!me._paused && !entry._disowned) {
me.pause(who)
}
})
entry.on("resume", function (who) {
- if (me._paused) {
+ if (me._paused && !entry._disowned) {
me.resume(who)
}
})
@@ -136,13 +136,16 @@ DirReader.prototype._read = function () {
var ended = false
entry.on("close", onend)
+ entry.on("disown", onend)
function onend () {
if (ended) return
ended = true
me.emit("childEnd", entry)
me.emit("entryEnd", entry)
me._currentEntry = null
- me._read()
+ if (!me._paused) {
+ me._read()
+ }
}
// XXX Make this work in node.
@@ -167,6 +170,16 @@ DirReader.prototype._read = function () {
})
}
+DirReader.prototype.disown = function (entry) {
+ entry.emit("beforeDisown")
+ entry._disowned = true
+ entry.parent = entry.root = null
+ if (entry === this._currentEntry) {
+ this._currentEntry = null
+ }
+ entry.emit("disown")
+}
+
DirReader.prototype.getChildProps = function (stat) {
return { depth: this.depth + 1
, root: this.root || this
Please sign in to comment.
Something went wrong with that request. Please try again.