Socket
Socket
Sign inDemoInstall

fstream

Package Overview
Dependencies
Maintainers
1
Versions
46
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fstream - npm Package Compare versions

Comparing version 0.1.14 to 0.1.15

examples/deep-copy/examples/filter-pipe.js

5

lib/abstract.js

@@ -23,2 +23,7 @@ // the parent class for all fstreams.

Abstract.prototype.abort = function () {
this._aborted = true
this.emit("abort")
}
Abstract.prototype.destroy = function () {}

@@ -25,0 +30,0 @@

78

lib/dir-reader.js

@@ -14,2 +14,3 @@ // A thing that emits "entry" events with Reader objects

, Reader = require("./reader.js")
, assert = require("assert").ok

@@ -28,3 +29,3 @@ inherits(DirReader, Reader)

me._entries = null
me.entries = null
me._index = -1

@@ -41,9 +42,17 @@ me._paused = false

if (er) return me.error(er)
me._entries = entries
me._length = entries.length
// console.error("DR %s sort =", me.path, me.props.sort)
if (typeof me.props.sort === "function") {
me._entries.sort(me.props.sort)
me.entries = entries
me.emit("entries", entries)
if (me._paused) me.once("resume", processEntries)
else processEntries()
function processEntries () {
me._length = me.entries.length
// console.error("DR %s sort =", me.path, me.props.sort)
if (typeof me.props.sort === "function") {
me.entries.sort(me.props.sort)
}
me._read()
}
me._read()
})

@@ -56,3 +65,3 @@ }

if (!me._entries) return me._getEntries()
if (!me.entries) return me._getEntries()

@@ -77,3 +86,6 @@ if (me._paused || me._currentEntry || me._aborted) {

// save creating a proxy, by stat'ing the thing now.
var p = path.resolve(me._path, me._entries[me._index])
var p = path.resolve(me._path, me.entries[me._index])
assert(p !== me._path)
assert(me.entries[me._index])
// set this to prevent trying to _read() again in the stat time.

@@ -84,11 +96,8 @@ me._currentEntry = p

var entry = Reader({ path: p
, depth: me.depth + 1
, root: me.root || me._proxy || me
, parent: me._proxy || me
, follow: me.follow
, filter: me.filter
, sort: me.props.sort
}, stat)
var who = me._proxy || me
var childProps = me.getChildProps.call(who, stat)
childProps.path = p
var entry = Reader(childProps, stat)
// console.error("DR Entry", p, stat.size)

@@ -103,3 +112,3 @@

entry.on("pause", function (who) {
if (!me._paused) {
if (!me._paused && !entry._disowned) {
me.pause(who)

@@ -110,3 +119,3 @@ }

entry.on("resume", function (who) {
if (me._paused) {
if (me._paused && !entry._disowned) {
me.resume(who)

@@ -116,2 +125,6 @@ }

entry.on("stat", function (props) {
me.emit("entryStat", entry, props)
})
entry.on("ready", function EMITCHILD () {

@@ -141,2 +154,3 @@ // console.error("DR emit child", entry._path)

entry.on("close", onend)
entry.on("disown", onend)
function onend () {

@@ -148,6 +162,8 @@ if (ended) return

me._currentEntry = null
me._read()
if (!me._paused) {
me._read()
}
}
// XXX Make this work in node.
// XXX Remove this. Works in node as of 0.6.2 or so.
// Long filenames should not break stuff.

@@ -174,2 +190,22 @@ entry.on("error", function (er) {

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
, parent: this
, follow: this.follow
, filter: this.filter
, sort: this.props.sort
}
}
DirReader.prototype.pause = function (who) {

@@ -176,0 +212,0 @@ var me = this

@@ -66,2 +66,3 @@ // A reader for when we don't yet know what kind of thing

, "warn"
, "stat"
].forEach(function (ev) {

@@ -68,0 +69,0 @@ // console.error("~~ proxy event", ev, me.path)

@@ -190,7 +190,10 @@

if (me.filter) {
var who = me._proxy || me
// special handling for ProxyReaders
if (!me.filter.call(me._proxy || me)) {
me._aborted = true
me.emit("end")
me.emit("close")
if (!me.filter.call(who, who, props)) {
if (!me._disowned) {
me.abort()
me.emit("end")
me.emit("close")
}
return

@@ -200,6 +203,14 @@ }

// last chance to abort or disown before the flow starts!
me.emit("stat", props)
if (me._aborted) {
me.emit("end")
me.emit("close")
return
}
me.emit("ready", props)
// if it's a directory, then we'll be emitting "entry" events.
me._read()
if (!me._paused) me._read()
}

@@ -206,0 +217,0 @@ }

@@ -126,2 +126,3 @@

, stat = props.follow ? "stat" : "lstat"
, who = me._proxy || me

@@ -132,3 +133,3 @@ if (current) statCb(null, current)

function statCb (er, current) {
if (me.filter && !me.filter.call(me._proxy || me, current)) {
if (me.filter && !me.filter.call(who, who, current)) {
me._aborted = true

@@ -135,0 +136,0 @@ me.emit("end")

@@ -5,3 +5,3 @@ {

"description": "Advanced file system stream things",
"version": "0.1.14",
"version": "0.1.15",
"repository": {

@@ -8,0 +8,0 @@ "type": "git",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc