pausable

4.4.2 • Public • Published

Pausable

Build Status

Pause and resume JavaScript code from arbitrary points.

Installation

$ npm install pausable

Usage

let pausable = require('pausable');

Execute code where the top level can pause

(async () => {
    let myResult = await pausable.execute(`
// Pause at this point for 4 seconds, after which
// myVar should be assigned the value "my string"
var myVar = giveMeAfter('my string', 4000);
 
return myVar + ' with something appended';
`, {
    expose: {
        giveMeAfter(value, milliseconds) {
            var pause = pausable.createPause();
 
            setTimeout(() => {
                // Timeout has elapsed, so we can resume the paused code
                pause.resume(value);
            }, milliseconds);
 
            // Do the pause
            pause.now();
        }
    }
});
 
    console.log(myResult);
})();

Output:

my string with something appended

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
4.4.24latest

Version History

VersionDownloads (Last 7 Days)Published
4.4.24
4.4.10
4.4.00
4.3.01
4.2.10
4.2.00
4.1.10
4.1.00
4.0.00
3.1.02
3.0.00
2.0.60
2.0.50
2.0.40
2.0.30
2.0.20
2.0.12
2.0.00
1.2.01
1.1.10
1.1.00
1.0.00

Package Sidebar

Install

npm i pausable

Weekly Downloads

10

Version

4.4.2

License

MIT

Unpacked Size

438 kB

Total Files

93

Last publish

Collaborators

  • asmblah