0.1.4 • Published 8 months ago

tardy v0.1.4

Weekly downloads
-
License
ISC
Repository
github
Last release
8 months ago

tardy

Turn promises into progress reporting processes in a functional/monadic style.

Requires ES modules.

Quickstart

import { Tardy } from 'tardy'

const delay = (ms: number) => new Promise(resolve => setTimeout(resolve, ms));
const process = (min: number, max: number) => delay(Math.random() * (max - min) + min);
const increments = (count: number) => Array.from({ length: count }, (_, i) => i);

const sample = new Tardy(async client => {
    await Tardy.reportCountdown(5).run(client);

    await Tardy.seq(increments(10).map(n => 
        new Tardy(() => process(100, 500)).report(`Doing ${n}`)
    )).report('Sequence', 0, .5).run(client);

    await Tardy.all(increments(100).map(n => 
        new Tardy(() => process(1000, 5000)).report()
    )).report('Parallel', 0.5, 1).run(client);

    client.log('Done'); 
});

sample.exec().then(() => 
    sample.exec({ multiline: false })
);
0.1.4

8 months ago

0.1.2

2 years ago

0.1.3

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago

0.0.8

2 years ago

0.0.7

2 years ago

0.0.6

2 years ago

0.0.5

2 years ago

0.0.4

2 years ago

0.0.3

2 years ago

0.0.2

2 years ago

0.0.1

2 years ago