4.4.2 • Published 4 years ago

pausable v4.4.2

Weekly downloads
24
License
MIT
Repository
-
Last release
4 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

4 years ago

4.4.1

4 years ago

4.4.0

4 years ago

4.3.0

6 years ago

4.2.1

6 years ago

4.2.0

8 years ago

4.1.1

8 years ago

4.1.0

8 years ago

4.0.0

8 years ago

3.1.0

9 years ago

3.0.0

9 years ago

2.0.6

9 years ago

2.0.5

9 years ago

2.0.4

9 years ago

2.0.3

9 years ago

2.0.2

9 years ago

2.0.1

9 years ago

2.0.0

9 years ago

1.2.0

9 years ago

1.1.1

9 years ago

1.1.0

9 years ago

1.0.0

9 years ago