4.4.2 • Published 5 years ago

pausable v4.4.2

Weekly downloads
24
License
MIT
Repository
-
Last release
5 years ago

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
4.4.2

5 years ago

4.4.1

5 years ago

4.4.0

5 years ago

4.3.0

7 years ago

4.2.1

7 years ago

4.2.0

9 years ago

4.1.1

9 years ago

4.1.0

9 years ago

4.0.0

10 years ago

3.1.0

10 years ago

3.0.0

10 years ago

2.0.6

10 years ago

2.0.5

10 years ago

2.0.4

10 years ago

2.0.3

10 years ago

2.0.2

10 years ago

2.0.1

10 years ago

2.0.0

10 years ago

1.2.0

10 years ago

1.1.1

10 years ago

1.1.0

10 years ago

1.0.0

10 years ago