Git Product home page Git Product logo

Comments (4)

juliangruber avatar juliangruber commented on July 17, 2024
  1. Not all streams implement .destroy and they also don't have to, but if they do, it's useful because you can just tell the stream "destroy yourself, i don't want to hear from you ever again"
  2. The through2 syntax takes in account asynchronous operations, which makes it more generic. If all you do is sync though, for your purpose that module makes sense.

Also keep in mind that this is also valid with through2:

fs.createReadStream('ex.txt')
  .pipe(thru(function (chunk, enc, callback) {
    for (var i = 0; i < chunk.length; i++)
      if (chunk[i] == 97)
        chunk[i] = 122 // swap 'a' for 'z'
    callback(null, chunk)
   }))
  .pipe(fs.createWriteStream('out.txt'))

from through2.

 avatar commented on July 17, 2024

@juliangruber Thanks!

(1) I see, but could you name some / any use cases of having your stream destroy itself? I don't want to add this feature until I can fully understand this point.

(2) My through version also takes async operations into account via promises. If you return a promise it will handle it accordingly.

from through2.

juliangruber avatar juliangruber commented on July 17, 2024
  1. if you don't need it, don't add it, simple as that. see also #25 for motivation in this repo
  2. if that works for you, that's great

from through2.

 avatar commented on July 17, 2024

@juliangruber Thanks! 😄

from through2.

Related Issues (20)

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.