Latest Threat ResearchGlassWorm Loader Hits Open VSX via Developer Account Compromise.Details
Socket
Book a DemoInstallSign in
Socket

idle-timeout

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

idle-timeout

A basic idle state detector written in ES6.

Source
npmnpm
Version
2.1.1
Version published
Weekly downloads
2.3K
10.17%
Maintainers
1
Weekly downloads
 
Created
Source

idleTimeout

Version Size License

A zero dependency, ~3KB library to make idle state detection in the browser an ease. With it's simple but yet powerful API it features everything you will ever need.

Installation

Using npm

npm install idle-timeout

Using pnpm

pnpm add idle-timeout

Using yarn

yarn add idle-timeout

Using CDN

<script src="https://unpkg.com/idle-timeout/dist/idle-timeout.min.js"></script>

Usage

idleTimeout is totally easy to use. All you basically need to do is:

idleTimeout(() => {
  // Do some cool stuff
});

Documentation

The idleTimeout constructor takes two arguments:

  • callback [Function] - The callback function
    • element [Element] - The element that was listened for the timeout
  • options [Object] - An optional options object
    • element [Element] - The element to listen for the timeout
    • timeout [Number] - The idle timeout (in milliseconds)
    • loop [Boolean] - Whether the timeout should be looped when idle
const instance = idleTimeout(
  (element) => {
    // Callback
  },
  {
    element: document,
    timeout: 1000 * 60 * 5,
    loop: false
  }
);

Methods

pause() - Pauses the timeout

instance.pause();

resume() - Resumes an paused timeout

instance.resume();

reset() - Reset the timeout

instance.reset();

destroy() - Destroy the instance

instance.destroy();

Getters

idle [Boolean] - Whether the current state is idle

instance.idle; // false

Setters

timeout = value [Number] - Set the timeout (in milliseconds)

instance.timeout = 1000 * 60;

loop = value [Boolean] - Set whether the timeout should be looped

instance.loop = true;

idle = value [Boolean] - Set the idle state

instance.idle = true;

Browser Support

Chrome
Chrome
Firefox
Firefox
Safari
Safari
Opera
Opera
Edge
Edge
IE
IE
 Latest 2Latest 2Latest 2Latest 2Latest 211

License

This project is licensed under the terms of the MIT License.

FAQs

Package last updated on 05 Aug 2025

Did you know?

Socket

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