Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/npm/cli.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorisaacs <i@izs.me>2012-08-02 02:55:32 +0400
committerisaacs <i@izs.me>2012-08-02 02:55:32 +0400
commit1e97cc955b90088bc3b134db05f913c813b4ce84 (patch)
tree89d750474fe93e6c9f55da9b6c0e7c648fd55769 /node_modules/glob/glob.js
parenta6f0cee57412a1ba13a8eedcfc86f47a8a68059d (diff)
glob@3.1.11
Diffstat (limited to 'node_modules/glob/glob.js')
-rw-r--r--node_modules/glob/glob.js47
1 files changed, 24 insertions, 23 deletions
diff --git a/node_modules/glob/glob.js b/node_modules/glob/glob.js
index 0e7135842..6285962a9 100644
--- a/node_modules/glob/glob.js
+++ b/node_modules/glob/glob.js
@@ -44,7 +44,6 @@ var fs = require("graceful-fs")
, path = require("path")
, isDir = {}
, assert = require("assert").ok
-, EOF = {}
function glob (pattern, options, cb) {
if (typeof options === "function") cb = options, options = {}
@@ -95,6 +94,9 @@ function Glob (pattern, options, cb) {
options = options || {}
+ this.EOF = {}
+ this._emitQueue = []
+
this.maxDepth = options.maxDepth || 1000
this.maxLength = options.maxLength || Infinity
this.statCache = options.statCache || {}
@@ -211,8 +213,8 @@ Glob.prototype._finish = function () {
if (this.debug) console.error("emitting end", all)
- EOF = this.found = all
- this.emitMatch(EOF)
+ this.EOF = this.found = all
+ this.emitMatch(this.EOF)
}
function alphasorti (a, b) {
@@ -244,32 +246,31 @@ Glob.prototype.resume = function () {
this.emit("error", new Error("Can't pause/resume sync glob"))
this.paused = false
this.emit("resume")
+ this._processEmitQueue()
+ //process.nextTick(this.emit.bind(this, "resume"))
}
-
Glob.prototype.emitMatch = function (m) {
- if (!this.paused) {
- this.emit(m === EOF ? "end" : "match", m)
- return
- }
-
- if (!this._emitQueue) {
- this._emitQueue = []
- this.once("resume", function () {
- var q = this._emitQueue
- this._emitQueue = null
- q.forEach(function (m) {
- this.emitMatch(m)
- }, this)
- })
- }
-
this._emitQueue.push(m)
-
- //this.once("resume", this.emitMatch.bind(this, m))
+ this._processEmitQueue()
}
-
+Glob.prototype._processEmitQueue = function (m) {
+ while (!this._processingEmitQueue &&
+ !this.paused) {
+ this._processingEmitQueue = true
+ var m = this._emitQueue.shift()
+ if (!m) {
+ this._processingEmitQueue = false
+ break
+ }
+ if (this.debug) {
+ console.error('emit!', m === this.EOF ? "end" : "match")
+ }
+ this.emit(m === this.EOF ? "end" : "match", m)
+ this._processingEmitQueue = false
+ }
+}
Glob.prototype._process = function (pattern, depth, index, cb_) {
assert(this instanceof Glob)