Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

create-timer

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

create-timer

[![license](https://img.shields.io/badge/License-MIT-blue.svg)](https://github.com/dutchenkoOleg/node-w3c-validator/blob/master/LICENSE) ![types](https://img.shields.io/badge/types-TypeScript-blue)

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
increased by50%
Maintainers
1
Weekly downloads
 
Created
Source

createTimer

license types

Creating timers with internal closure


Usage

import createTimer from 'create-timer';

const timer = createTimer(500);
$(window).on('resize', function () {
    timer(() => {
        console.log('done');
    });
});

// ...delay for current calling
timer(() => {
    console.log('just test after 2seconds');
}, 2000);

// ...clear timer if need
timer.clear();

API

createTimer([defaultDelay = 300])

  • @param {number} defaultDelay - default delay for created timer;
  • @returns {Function} timer
const timer1 = createTimer();
const timer2 = createTimer(600);

timer(fn[, customDelay])

  • @param {Function} fn - callback, executed after timout;
  • @param {number} [delay=defaultDelay] - delay for override with current calling
  • @returns {number} timeoutId - id of current timeout

timer.clear()

  • clear current timeout

Keywords

FAQs

Package last updated on 17 Feb 2020

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc