kriskowal / q-io

Interfaces for IO using Q promises in JavaScript on Node
http://documentup.com/kriskowal/q-io
MIT License
317 stars 73 forks source link

fix empty second request due BufferStream chunks reference colateral #161

Closed hthetiot closed 7 years ago

hthetiot commented 7 years ago

fix empty File.chunks on MockFs second request due BufferStream splice on reference.

Using following example with Joey, "a/b/d.txt" get only served once: See example https://github.com/montagejs/joey/pull/16

var joey = require("../joey");
var MockFs = require("q-io/fs-mock");

var mockFs = MockFs({
    "a": {
        "b": {
            "c.txt": "Content of a/b/c.txt"
        }
    },
    "a/b/d.txt": new Buffer("Content of a/b/d.txt", "utf-8")
})

var server = joey // Hi.
  .fileTree('/', {fs: mockFs}) // Use mockFs
  .listen(8888) // start the server
  .then(function (server) { // when it has started
      // let us know
      console.log("Listening on", server.address().port);
  }).done();
hthetiot commented 7 years ago

@kriskowal How about 469ff2cffc6bbb04cd04614e8bd93e779b7e93ef it should not change forEach behavior.

hthetiot commented 7 years ago

Nah breaking test, will look why previous change did not.

hthetiot commented 7 years ago

Here we go, restored BufferStream and only fixed fsMock, tests are passing.

hthetiot commented 7 years ago

@kriskowal if you agreed, merge. If you want BufferStream.prototype.clone in this pull request let me know see review comment.

kriskowal commented 7 years ago

I’ve granted you collaborator permissions and approved the request. You are free to merge, cut a patch, and release. (I don’t want to block you)

I will add you as an owner in npm as well. Is this you? https://www.npmjs.com/~hthetiot

hthetiot commented 7 years ago

@kriskowal Yes I'm ~hthetiot on npm. Merging this pull.

kriskowal commented 7 years ago
❯ npm owner ls q-io
arikon <peimei@ya.ru>
gagern <Martin.vGagern@gmx.net>
hthetiot <hthetiot@gmail.com>
kriskowal <kris.kowal@cixar.com>