Module de minuterie Node.js

❮ Modules intégrés


Exemple

Écrivez "Bonjour" toutes les 500 ms :

var myInt = setInterval(function () {
    console.log("Hello");
}, 500);

Définition et utilisation

Le module Timers fournit un moyen de planifier des fonctions à appeler ultérieurement à un moment donné.

L'objet Timer est un objet global dans Node.js, et il n'est pas nécessaire de l'importer à l'aide du mot- requireclé.


Minuteries Méthodes

Method Description
clearImmediate() Cancels an Immediate object
clearInterval() Cancels an Interval object
clearTimeout() Cancels a Timeout object
ref() Makes the Timeout object active. Will only have an effect if the Timeout.unref() method has been called to make the Timeout object inactive.
setImmediate() Executes a given function immediately.
setInterval() Executes a given function at every given milliseconds
setTimeout() Executes a given function after a given time (in milliseconds)
unref() Stops the Timeout object from remaining active.

❮ Modules intégrés