1 const isUndefined
= (value
: unknown
): boolean => {
2 return typeof value
=== 'undefined';
5 export const ifUndefined
= <T
>(value
: T
| undefined, isValue
: T
): T
=> {
6 if (isUndefined(value
) === true) return isValue
;
10 // const isIterable = <T>(obj: T): boolean => {
11 // if (obj === null || obj === undefined) {
14 // return typeof (obj as unknown as Iterable<T>)[Symbol.iterator] === 'function';
17 // const ifNotIterableDo = <T>(obj: T, cb: () => void): void => {
18 // if (isIterable(obj) === false) cb();
21 export const promiseWithTimeout
= <T
>(
25 timeoutCallback
: () => void = () => {
26 /* This is intentional */
29 // Create a timeout promise that rejects in timeout milliseconds
30 const timeoutPromise
= new Promise
<never>((_
, reject
) => {
32 // FIXME: The original promise state shall be checked
34 // FIXME: The original promise shall be canceled
39 // Returns a race between timeout promise and the passed promise
40 return Promise
.race
<T
>([promise
, timeoutPromise
]);
43 // export const compose = <T>(...fns: ((arg: T) => T)[]): ((x: T) => T) => {
44 // return (x: T) => fns.reduceRight((y, fn) => fn(y), x);