0.1.9 • Published 4 years ago

@nsfilho/unique v0.1.9

Weekly downloads
18
License
GPL-3.0
Repository
github
Last release
4 years ago

Unique Execution

A very simple and small services to guarantee a Unique Execution of some piece of code (async) in a javascript / typescript applications.

  • Project licensed under: GPLv3
  • Site Documentation: Homepage
  • Repository: GitHub

Environment Variables

This services use some environment variables to pre-adjust some things, like:

  • UNIQUE_START_DELAY: define a minimum delay to start func execution;
  • UNIQUE_POOLING: pooling time to check delayed func to execute;

The delay time is a mininum delay time, checked at UNIQUE_POOLING interval.

Example

import { uniqueExecution } from '@nsfilho/unique';

/**
 * Simple async function for example.
 * Show a message after certain amount of time.
 */
const delayMessage = async (message: string, delay: number): Promise<void> =>
    new Promise((resolve) => {
        setTimeout(() => {
            console.log(message);
            resolve();
        }, delay);
    });

uniqueExecution({
    name: __filename,
    callback: async () => {
        // execute a async func
        await delayMessage('Hello World!!', 2000);
    },
});
0.1.9

4 years ago

0.1.8

4 years ago

0.1.7

4 years ago

0.1.6

4 years ago

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago