Created
July 19, 2017 15:19
-
-
Save harish2704/299d520b641ae4fc00c4aa18da1173f8 to your computer and use it in GitHub Desktop.
Log promise in Node js repl. This will add a command ".log" which can be used like ".log Promise.resolve(123)" Raw
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function logSuccess( a, b, c ){ console.log('Success'); global.uu = arguments; global.aa = a; global.bb = b; global.cc = c; } | |
function logError( e ){ console.log( 'Error'); global.ee = e; } | |
function log( promise ){ promise.then(logSuccess).catch(logError); } | |
function doLog( task ){ var cmd =`log(${task})`; this.outputStream.write(cmd); this.context.vm.runInThisContext(cmd); this.displayPrompt();} | |
repl.repl.defineCommand('log', doLog); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment