Comments (4)
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.
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.
Closing, but we can re-open if there are more questions.
from mississippi.
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)
- update duplexify dependency to add compatibility for [email protected] streams... HOT 1
- Typescript Types? HOT 1
- cut new release? HOT 4
- Add split? HOT 1
- What stream should I use for rate limiting (i.e. for object mode)? HOT 3
- Add whatwg streams adapter? HOT 2
- Stream segment index HOT 1
- Include module for connecting streams end-to-end? HOT 4
- Which versions of Node need these utilities? HOT 2
- Consider adding pump-chain to the collection? HOT 7
- Add from2? HOT 1
- Promise-friendly API? HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mississippi.