Node.js

Only i/o is asyncarrow-up-right

It's important to understand that node isn't about functions being asynchronous all the time. It's about i/o being asynchronous and non-blocking. If your function doesn't do any i/o, node isn't going to help you make it asynchronous. It provides tools that will allow you to do that though. Like child processes. That's what felix's answer is getting at. Your function can spawn a child process to do your work and it will execute off of the main event loop.

How to catch all?

uncaughtExceptionarrow-up-right

process.on('uncaughtException', (err) => {
  fs.writeSync(1, `Caught exception: ${err}\n`);
});

How to use local (private) package?

Use git submodule

# when clone, remember to clone with submodules
git clone --recursive git@REPO-URL

# to update
git submodule update --remote
npm install

NOTE there is a bug for npm update: it doesn't work with local package now, see NPM #7426arrow-up-right

"my-package": "file:./my-package",

So my workaroud for now is, go to node_moduels folder and delete the package folder, then npm install again.

Reference:

FS

How to get the base file name: 'a.ext' -> 'a'?

How to glob in node?

Frontend

How to get url of root with domain?

var root = location.protocol + '//' + location.host; http://bl.ocks.org/abernier/3070589arrow-up-right and http://stackoverflow.com/a/1368295/166286arrow-up-right

A way to generate and download CSV files client-side

https://gist.github.com/hamxiaoz/a664f52e34c22f2be83farrow-up-right

Last updated