We start with the following code
function startListening(server, cb) {
server.listen(99999, 'localhost', cb)
}
we're discussing how we can safely abort on unhandled rejections and obtain meaningful debugging information. Related reading: https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#file-post-mortem-debugging-with-promises-md.
In particular, we're discussing https://gist.github.com/misterdjules/2969aa1b5e6440a7e401#removing-implicit-trycatch-blocks-from-v8s-promises-implementation
Othe recommended reading: On unhandledRejection
https://gist.github.com/benjamingr/0237932cee84712951a2
listen(port, cb) { | |
const server = http.createServer((req, res) => { | |
res.statusCode = 200; | |
res.setHeader("Content-Type", "text/plain"); | |
res.end("Hello World\n"); | |
}); | |
return server.listen.apply(server, arguments); | |
} |
const router = [{ | |
path: '*', | |
method: '*', | |
handle: function(req, res) { | |
res.writeHead(200, {'Content-Type': 'text/plain'}); | |
res.end('404'); | |
} | |
}]; |
using mocha/chai/sinon for node.js unit-tests? check out my utility: mocha-stirrer to easily reuse test components and mock require dependencies
var os = require("os"); | |
//Create function to get CPU information | |
function cpuAverage() { | |
//Initialise sum of idle and time of cores and fetch CPU info | |
var totalIdle = 0, totalTick = 0; | |
var cpus = os.cpus(); | |
//Loop through CPU cores |
Per https://code.google.com/p/v8/codesearch#v8/trunk/src/runtime.cc | |
%CreateSymbol | |
%CreatePrivateSymbol | |
%CreateGlobalPrivateSymbol | |
%NewSymbolWrapper | |
%SymbolDescription | |
%SymbolRegistry | |
%SymbolIsPrivate |