Socket
Socket
Sign inDemoInstall

time-worker

Package Overview
Dependencies
0
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    time-worker

Set Timeouts and Intervals in Web Workers So They Continue Working When the Page is Hidden.


Version published
Maintainers
1
Created

Readme

Source

Time Worker v1.0.4

Set Timeouts and Intervals in Web Workers So They Continue Working When the Page is Hidden.

Installation

$ npm install time-worker

Usage

The TimeWorker object has the methods:

  • setTimeout(callback: Function, ms: number) => id: string;
  • setInterval(callback: Function, ms: number) => id: string;
  • clearTimeout(id: string) => void;
  • clearInterval(id: string) => void;
  • clearAll() => void;
  • terminate() => void;

And the following properties:

  • isTerminated: boolean;
import TimeWorker from 'time-worker';

const timeWorker = new TimeWorker(); // Instantiate the TimeWorker

const interval = timeWorker.setInterval(() => console.log('interval'), 1000); // Set an interval

timeWorker.setTimeout(() => timeWorker.clearInterval(interval), 5000); // Set a timeout to clear the interval

timeWorker.clearAll(); // Clear all timeouts and intervals

timeWorker.terminate(); // Stop the worker itself

console.log(worker.isTerminated); // > true

Keywords

FAQs

Last updated on 21 Jul 2021

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc