@keeex/utils v7.2.1
@keeex/utils
Utility functions in pure JS used in many places.
You should check the API documentation for detailed informations about each functions. This is a general feature list overview.
Async utility
Stuff related to promises and async operations.
AsyncTrigger
, for easy debouncingDeferredPromise
to manipulate the usualresolve()
andreject()
functions outside of a promise blockKeyCache
to create a basic key-value cache with asynchronous fetchQueues
to create parallel queues of tasksTimeCache
to create a cache that keeps a value for a given amount of time and can automatically refresh it
CRON
Time-based task scheduling.
Marshalling
Serialization of random data into byte buffers.
Types
Various type-checking helpers to create TypeScript type predicates. Supports "shortcut" versions for performance after a full check was done.
Array
Generic operations on arrays, as well as array coercion.
Uint8Array and ArrayBuffer
Conversion between different formats and search in buffer functions.
base58, base64
Utility to manipulate strings encoded in these formats.
benchmark
Code to run a JavaScript function a lot to get performance benchmarks. Includes some form of "automatic" probing to get good average values.
bytebuffer
Helper wrapping JavaScript DataView into convenient functions.
dict
Functions to copy records with primitive types (deep copy).
These functions can probably be replaced with Object.assign()
or custom code.
error
Coerce anything (unknown
) into an Error
object for easier error handling.
global
Functions to use a JavaScript environment "global" dataset. Handles multiple environment somewhat gracefully.
hex
Hex string manipulation.
idx
IDX check and manipulation functions
json
JSON parsing with type safety. Also, a "canonical" JSON encoder that ensure property order is consistent.
line buffer
Buffer string inputs and output full lines only.
number
Manipulate number. Currently only round to a given decimal place.
path
Generic filename sanitization.
promise
Helpers around promises.
- controlled async delay
- retry a promise until it succeed (with max tries)
- run an array of promise, stop at the first that succeed
- silently drop a promise without crashing the VM
starttime
Get the elapsed time since the JavaScript environment started.
string
String and UTF-8 manipulations.
units
Convers between various units. Generic functions are available as well as byte and time conversions.