1.0.0 • Published 5 years ago
pause-repl v1.0.0
pause-repl
Function that opens a node.js REPL and returns a promise that resolves only when unpause() is called in the REPL.
When you await for this function to return, it will pause a script and open an interactive session.
Installation
$ npm install pause-replUsage
Import the pause function from pause-repl.
const { pause } = require('pause-repl');await pause() from an async function to open a REPL.
await pause();Pass any object to pause() to expose its properties to the REPL.
await pause({ hello: 'world' });While pause() returns a promise and is intended to be used in an async/await context but it can be used like any other promise. The unpause() function is attached to the promise so you can unpause programmatically, like in a timeout or when another action completes.
const pausedRepl = await pause();
pausedRepl.then(() => {
console.log('unpaused');
});
pausedRepl.unpause();Example
const { pause } = require('pause-repl');
(async () => {
const replContext = {
greet: () => 'Hello you!', // greet() will be availble in the REPL
};
await pause(replContext);
// the script won't continue until unpaused()-ed from the REPL.
console.log('Done');
})();Screenshot

1.0.0
5 years ago