New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

debounce-decorator-ts

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

debounce-decorator-ts

Simple debounce decorator for functions

latest
Source
npmnpm
Version
1.0.4
Version published
Weekly downloads
124
-38.92%
Maintainers
1
Weekly downloads
 
Created
Source

DEBOUNCE-DECORATOR

  • About
  • Install
  • API
  • Usage
  • License

ABOUT

Simple function debounce decorator written in Typescript.

  • Has no dependencies.
  • Very tiny < 1kb
  • Very easy to use

An live example of function use: Live Example

INSTALL

Install package by npm

  npm install --save-dev debounce-decorator-ts

API

SYNTAX

   @debounceFn(debounceTime, timeoutPropertyName);

Properties

  • debounceTime
    Action: Setting debounceTimer
    Default value: 100 (ms)
    Argument type: number ( miliseconds )

  • timeoutPropertyName
    Action: Setting timeout property name ( for clearTimeout )
    Default value: 'timeoutFn'
    Argument type: string

USAGE

Basic usage

    import { debounceFn } from "debounce-decorator-ts";

    class MyClass {
    	constructor() {
    	    window.addEventListener('resize', this.onResizeFn.bind(this));
    	}
    	
    	@debounceFn()
    	private onResizeFn(e: Event): void {
    	    console.log('resized!');
    	}
    }

    const myClass = new MyClass;

Override default properties value

    import { debounceFn } from "debounce-decorator-ts";

    class MyClass {
    	constructor() {
    	    window.addEventListener('resize', this.onResizeFn.bind(this));
    	}
    	
    	@debounceFn(1000, 'myCustomTimeoutPropertyName')
    	private onResizeFn(e: Event): void {
    	    console.log('resized!');
    	}
    }

    const myClass = new MyClass;

LICENSE

MIT License

Keywords

debounce

FAQs

Package last updated on 29 Aug 2018

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