Most of the ixfx functions that take millisecond arguments also allow you to provided an Type Flow.Interval . This can make for more readable code.
The Interval
type looks like:
Example usage with Flow.delay :
import { delay } from " https://unpkg.com/ixfx/dist/flow.js "
// instead of these options:
delay ( () => ... , 300000 ); // How long is that!?
delay ( () => ... , 5 * 60 * 1000 ); // A bit better
delay ( () => ... , { mins : 5 });
If you just want to give a millisecond value, a bare number can be used.
// These two lines are the same
delay ( () => ... , { millis : 1000 });
Any of the time units can be combined to define an interval, with a cumulative effect. Flow.intervalToMs allows you to convert to milliseconds, useful for combining with vanilla JS functions.
import { intervalToMs } from " https://unpkg.com/ixfx/dist/flow.js "
const period = { secs : 2 , millis : 1 };
// Yields 2001 (2 seconds + 1 millisecond);
const ms = intervalToMs (period);
setTimeout (someFn, intervalToMs ({ secs : 2 , millis : 1 }));
Human-friendly string
Flow.elapsedToHumanString prints an elapsed time in a human-friendly way:
import { elapsedToHumanString } from " https://unpkg.com/ixfx/dist/flow.js "
elapsedToHumanString ( 100 ); // "100ms"
elapsedToHumanString ( 1234567 ); // "20.58mins"