New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

dely

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dely

Delay execution of callbacks to a given minimum timeframe.

  • 1.0.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

js-dely

Delay execution of callbacks to a given minimum timeframe. Tiny package, has below 50 lines of code.

Build Status JavaScript Style Guide

For what?

Some events on the client happen very fast so that there is no visual feedback of "currently executing action XYZ". This package is an easy and minimalistic appraoch to realize such a feature. Define a minimum amount is miliseoonds the action should take and the callback wont't execute before this timeframe. If the callback took longer than the time - fine, no need to delay anymore.

The amount of time from prior function execution to callback execution is considered, of course.

Installation / usage

Use NPM to install the package via

$ npm install --save dely

Use it to create a delayed callback like so

import dely from 'dely'

/**
 * This could be a server call with callback, a setTimeout or
 * an IO related function... or anything else with callback 
 */
SomeAsyncFunctionWithCallback(dely(300, (/* args if any */) => {
  console.log('I have not been executed before 300ms have been passed')
}))

Or use it to factory-create callbacks like so

import dely from 'dely'

const by300 = dely(300)

SomeAsyncFunctionWithCallback(by300((/* args if any */) => {
  console.log('I have not been executed before 300ms have been passed')
}))

anotherAsyncFunctionWithCallback(by300((/* args if any */) => {
  console.log('I also have not been executed before 300ms have been passed')
}))

Keywords

FAQs

Package last updated on 06 Apr 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