Skip to content

Instantly share code, notes, and snippets.

@Integralist
Integralist / node debug.md
Last active December 31, 2015 00:49
Node debugger API
Run your application using: `node debug xxx.js` then use the following commands to step-through the code (note: Ctrl+D to exit the debugger)...
 
    `cont`                      -> continue running
    `next`                      -> step over next statement
    `step`                      -> step into next statement (if possible, otherwise it just steps over)
    `out`                       -> step out of the currently executing function
    `backtrace`                 -> show the current call execution frame or call stack
    `repl`                      -> start the node repl to allow you to view variable values and execute code
    `watch(expr)`               -> add given expression to the watch list (which is shown whenever you step through anything in the debugger)
@domenic
domenic / promise-retryer.js
Last active September 16, 2023 02:43
Generalized promise retryer
"use strict";
// `f` is assumed to sporadically fail with `TemporaryNetworkError` instances.
// If one of those happens, we want to retry until it doesn't.
// If `f` fails with something else, then we should re-throw: we don't know how to handle that, and it's a
// sign something went wrong. Since `f` is a good promise-returning function, it only ever fulfills or rejects;
// it has no synchronous behavior (e.g. throwing).
function dontGiveUp(f) {
return f().then(
undefined, // pass through success