delay-decorator
v2.0.0
Published
An ES7 decorator for delaying function calls.
Downloads
7
Maintainers
Readme
delay-decorator
An ES7 decorator for delaying function calls. Uses setTimeout internally.
Installation
Install the package with NPM:
$ npm install delay-decorator
Usage
The following example should be self-explanatory:
import delay from "delay-decorator";
class Dog {
@delay(2000)
makeNoise() { return "Woof!" }
}
let dog = new Dog();
let promise = dog.makeNoise();
promise.then(noise => console.log(noise)); // Print "Woof!" after 2 seconds.