I hereby claim:
- I am thlorenz on github.
- I am thlorenz (https://keybase.io/thlorenz) on keybase.
- I have a public key ASDi53IJKgU2P7pjH8Aepd3pnhwCfFWfL7s7VHVBAuHPMwo
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
var stream = require('stream'); | |
var util = require('util'); | |
var Writable = stream.Writable; | |
module.exports = CheckEncodingWritable; | |
util.inherits(CheckEncodingWritable, Writable); | |
function CheckEncodingWritable (opts) { |
It is not usually recommended to reuse errors since the stack trace is attached whenever the error is instantiated.
However in some cases the overhead of doing that may affect performance, especially if the error is an exception that is known to occur frequently and is handled.
Only in these cases it may be advantagous to reuse the created Error
. In all other cases getting a full stacktrace created at the time the exception occurs is to be preferred as it gives much better information needed to debug the problem.
➝ node errors.js
Tried to improve debugging when an express middleware is wrapped to auto-handle errors of an asnync
function.
Turns out the below reads a bit better than a return Promise.catch()
implementation, but still, once we reach the central express error handler, the line of the wrapped function that caused the error isn't included.
'use strict'
This is specifically tailored to Node.js binding projects in which case the C++ layer is always a library.
Clone gyp:
git clone --depth 1 https://chromium.googlesource.com/external/gyp.git gyp
Add the below common.gypi
file in the root of the project.
'use strict' | |
const deferred = { | |
resolve: function dontCare() {} | |
} | |
class DeoptMark { | |
constructor({ ITER = 1E3 } = {}) { | |
this._ITER = ITER | |
this._fns = [] |
The entire V8 compiler architecture as well as large parts of the Garbage Collector where updated recently. TurboFan replaced Crankshaft, Orinoco now collects garbage in parallel whenever possible. Node.js v8 shipped with this new and improved version of V8. As a result we can finally write idiomatic and declarative JavaScript without worrying about incurring performance overhead due to JavaScript compiler shortcomings.
At least this is what the V8 team tells us. In this talk we will explore if and why this is true, one demo at a time.
#!/usr/bin/env node | |
const fs = require('fs') | |
const path = require('path') | |
function bySizeThenByName(a, b) { | |
if (a.size === b.size) { | |
return a.path.localeCompare(b) | |
} | |
return a.size < b.size |
#!/bin/bash | |
replacements=( | |
"NanAsyncWorker/Nan::AsyncWorker" | |
"NanAsyncQueueWorker/Nan::AsyncQueueWorker" | |
"NanCallback/Nan::Callback" | |
"NanSetInternalFieldPointer/Nan::SetInternalFieldPointer" | |
"NanGetInternalFieldPointer/Nan::GetInternalFieldPointer" | |
"NanNewBufferHandle\\(([^;]+);/Nan::NewBuffer(\\1.ToLocalChecked();" | |
"(NanNew(<(v8::)?String>)?\\(\"[^\"]*\"\\))/\\1.ToLocalChecked()" |