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

tgul

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

tgul

TypeScript Generalized Utility Library

latest
Source
npmnpm
Version
1.0.2
Version published
Maintainers
1
Created
Source

tgul

Typescript Generalized Utility Library

utilities

awaitable

converts callback based promise into a resolveable entity to retain 2 dimensional code flow

const awaitableObj = awaitable<boolean>();

try{

    setTimeout(()=>awaitableObj.reject(new Error("Timed Out")),5000); // reject if not resolved within 5 seconds

    something.withAsynchronousCallback((isSuccess)=>{
        successBoolean ? awaitableObj.resolve(isSuccess) : awaitableObj.reject(new Error("unexpected data return"));
    })
}
catch(err){
    awaitableObj.reject(new Error("Not successful"));
}

const result = await awaitableObj.promise; // await any of the asynchronous/synchronous callback paths
console.log(result); // log result, resolution is of the awaitable type, rejection is of error in this example

queue

simple inline asynchronous queueing system with simple idle sleep resource reduction

const exampleQueueDefaultInterval = 1000;
create_queue({ 
    queue:"example queue", 
    interval: exampleQueueDefaultInterval, 
    limiter: limiter_throttle 
}) // create queue with queue execution interval of 1000

const backoffQueueDefaultInterval = 1000;
create_queue({ 
    queue:"backoff queue",
    interval: backoffQueueDefaultInterval,
    limiter: limiter_throttle
}) // create queue with queue execution interval of 1000

const someFn = async (data: any[]) => {
    const newData = await Promises.all(
        data.map(async (row) => {
            console.log("do stuff. any stuff. async or not doesn't matter")

            await queue({ queue:"example queue" }); // await until asynchronous ready signal from queue with name "example queue"
            row.new_property = "someValue";
            return row;
        })
    );

    return newData;
}

const someFnWithExponentialBackoff = async (data: any[]) => {
    while(true){
        try{
            await queue({ queue:"backoff queue" }); // await until asynchronous ready signal from queue with name "backoff queue"
            const result = await fetchWithReturn();
            if(result) {
                backon_queue({ queue:"backoff queue" }); // tell queue to reset backoff to behave on normal interval;
                break;
            }
        }
        catch(err){
            console.error(err);
        }
        finally {
            backoff_queue({ queue:"backoff queue" }); // tell queue to backoff
        }
    }

}

timeout

asynchronous timeout function which blocks 2 dimensional flow until millisecond timeout return;

console.log("start",new Date().toISOString());
await timeout(1000) // 1 second timeout
console.log("end",new Date().toISOString());

limiter

limiting execution class capable of throttle, debounce & lockout

// To Be Documented

scripts

run

npm run dev

build

npm run build

test

npm run test

Keywords

typescript

FAQs

Package last updated on 20 Sep 2025

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