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

debounce-callback

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debounce-callback

debounceCallback works similar to useDebounceCallback hook in @react-hook/debounce. However debounceCallback is not a hook in react.

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-57.14%
Maintainers
1
Weekly downloads
 
Created
Source

Table of contents

Introduction

  • debounceCallback works similar to useDebounceCallback hook in @react-hook/debounce library. However debounceCallback is not a hook in react.
  • debounceCallback can work in the backend-node and in other frameworks like ReactJs, VueJs, React Native,....
  • Module : CommonJs

How to use ?

Example 1 - Typescript/NodeEnvironment

import { sleep } from 'sakura-time-service';
import { debounceCallback } from 'debounce-callback';

async function main(){
    const sums:number[] = [];

    const calcSumDebounce = debounceCallback(async (a: number, b: number) => {
        sums.push(a + b);
    }, 600); // wait 600 ms


    for (let i = 0; i < 10; i++) {
        calcSumDebounce(5, i);
        await sleep(100); // waiting for 100 ms
    }

    // latest invoke
    calcSumDebounce(5, 10);
    
    await sleep(1000); // waiting for 1000 ms

    console.log('sums =', sums); // sums = [ 15 ]
}

main();

Example 2 - Javascript/NodeEnvironment

const { sleep } = require('sakura-time-service');
const { debounceCallback } = require('debounce-callback');

async function main(){
    const sums = [];

    const calcSumDebounce = debounceCallback(async (a, b) => {
        sums.push(a + b);
    }, 600); // wait 600 ms


    for (let i = 0; i < 10; i++) {
        calcSumDebounce(5, i);
        await sleep(100); // waiting for 100 ms
    }

    // latest invoke
    calcSumDebounce(5, 10);
    
    await sleep(1000); // waiting for 1000 ms

    console.log('sums =', sums); // sums = [ 15 ]
}

main();

Keywords

FAQs

Package last updated on 13 Jan 2023

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