1.1.0 • Published 1 year ago

@daign/schedule v1.1.0

Weekly downloads
2
License
MIT
Repository
github
Last release
1 year ago

daign-schedule

CI Coverage NPM package

Utility mechanisms to manage the time-wise execution of functions.

Installation

npm install @daign/schedule --save

Usage

import {Schedule} from '@daign/schedule';

class TestClass {
  private count: number = 0;

  public increment(): void {
    this.count += 1;
    console.log( this.count );
  }
}
const test = new TestClass();

// Throttle the increment method with a waiting period of 40 milliseconds
const wait = 40;
const throttledFunction = Schedule.deferringThrottle( test.increment, wait, test );

// The first call will be executed immediately
throttledFunction();

// The following calls are blocked temporarily, but there will be a single execution after the
// waiting period has elapsed
throttledFunction();
throttledFunction();
throttledFunction();

Scripts

# Build
npm run build

# Run lint analysis
npm run lint

# Run unit tests with code coverage
npm run test

# Get a full lcov report
npm run coverage