0.0.19 • Published 6 years ago

froq-util v0.0.19

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

froq-util

Travis branch Stability Looking for Contributors

npm node

license GitHub tag GitHub issues GitHub last commit GitHub top language GitHub code size in bytes

froq-util is a small util library for some useful stuff, needed for the froq packages.

Usage

npm install froq-util

We use npm package debug. To make me verbose use DEBUG=froq-util.

Parallel

Promise.all sometimes feels strange.

import {parallel} from 'froq-util';

const [google, twitter] = parallel(fetch('https://google.de'), fetch('https://twitter.com'));

Retry

retry is non-blocking lazy looping, also with defer = 0

import {retry} from 'froq-util';


// simple

const resp = await retry({try: () => fetch('https://mybooting-server/sanity')});
// resp.status: 200 (e.g.)


// more complex

const total = 30000; // millis
const defer = 1000; // 1sec between each try
const max = 100; // max iterations (as a total limit of tries at all)

await retry({try: () => fetch('https://my-crashed-server/sanity'), total, defer, max});
// throws: Error err (e.g.)
// all exceptions in `err.exceptions`
0.0.19

6 years ago

0.0.15

6 years ago

0.0.14

6 years ago

0.0.13

6 years ago

0.0.12

6 years ago

0.0.8

6 years ago

0.0.7

6 years ago

0.0.3

6 years ago

0.0.1

6 years ago