Giter Site home page Giter Site logo

Comments (4)

bcomnes avatar bcomnes commented on August 29, 2024 1

The challenge with concat and pump is that you a split callback paths with pump and concat.

Remember the callback on pump isn't just the error handler, it's more accurately dubbed the 'stream ended' or 'stream finished' handler, where you handle the first error thrown by the pipeline, but also handle any outer callbacks with pipeline results or info.

Any in-memory writable segment should (can?) capture the result on the scope outside of the pipeline and then callback from the pump callback with it. Callbacks/events/properties of the pipeline segments should always be process in the pump callback, and never act as the exit path of the pipeline. These callbacks should always be though of, resolve and behave as if they are nested inside the pump operation.

var fs = require('fs')
var miss = require('mississippi')

let results
miss.pipe(
  fs.createReadStream('./nofile'),
  miss.concat(function (result) {
    console.log('concat', result)
    results = result
  }),
  function (err) {
    if (err) throw err
    console.log('stream ended')
    console.log(results)
  }
)

from mississippi.

bcomnes avatar bcomnes commented on August 29, 2024

One could wire up concat stream and pump to somehow automatically pass results, but this would probably be a non-standard convention on top of the stream API. Perhaps it could be defined by pump?

from mississippi.

bcomnes avatar bcomnes commented on August 29, 2024

Closing, but we can re-open if there are more questions.

from mississippi.

laduke avatar laduke commented on August 29, 2024

Callbacks/events/properties of the pipeline segments should always be process in the pump callback, and never act as the exit path of the pipeline.

that's the answer!

from mississippi.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.