Skip to content

Instantly share code, notes, and snippets.

View woanversace's full-sized avatar
💭
I may be slow to respond.

Khiet Vo woanversace

💭
I may be slow to respond.
View GitHub Profile
@LeCoupa
LeCoupa / nodejs-cheatsheet.js
Last active June 30, 2024 04:14
Complete Node.js CheatSheet --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
/* *******************************************************************************************
* THE UPDATED VERSION IS AVAILABLE AT
* https://github.com/LeCoupa/awesome-cheatsheets
* ******************************************************************************************* */
// 0. Synopsis.
// http://nodejs.org/api/synopsis.html
@spion
spion / 01-fractal-weird-design.md
Last active November 2, 2019 12:27
Node streams - a fractal of weird design

Node streams - a fractal of weird design

and a potential refactor that could fix that

This is a list of issues and confusions I've encountered with node streams, and things I wish were designed and implemented differently. If promise-streams is ever going to change to a design that doesn't build on top of node streams, this would be a list of mistakes to avoid

  1. enc parameter - Why is encoding always passed together with the data? It should be a separate concern. It doesn't even make sense in objectMode
  2. eventemitter base - This encourages a lot of random events to be "attached" by other authors which doesn't work. Best to have an uniform (typed) interface so that everyone knows what to expect.
  3. relying on nextTick etc for execution order - This is very unreliable and causes all sorts of unpredictable rules for implementers which are not documented anywhere. When you attach listeners determines what will happen.
  4. no error propagation - we need the
var Nightmare = require('nightmare'),
vo = require('vo');
function *start() {
var nightmare = new Nightmare({
show: true,
'download-preferences': {
destination: require('path').resolve(__dirname, 'downloads')
}
});