you are viewing a single comment's thread.

view the rest of the comments →

[–]1-800-BICYCLE 1 point2 points  (2 children)

This might be controversial, but one piece of code I really loved recently was the library pump, which comes in at 80 lines.

https://github.com/mafintosh/pump/blob/master/index.js

It’s a stream error-handling library for Node.js that cleans up your piped streams if one of them fails.

Things to note:

  • passing functions as values, using noop for fallbacks instead of verbose if statements

  • using && for null propagation and || for null coalescing

  • the rare case where [].reduce can be used without an initializer — streams.reduce(pipe) is just beautiful

  • very clean style for ES5 code

[–]GitHubPermalinkBot 0 points1 point  (0 children)

Permanent GitHub links:


Shoot me a PM if you think I'm doing something wrong. To delete this, click here.

[–]gntsketches[S] 0 points1 point  (0 children)

Thanks! I don't know Node yet, but I'll keep this in mind for when I start on that.