chore: switch coding style to JS standard
[e-mobility-charging-stations-simulator.git] / ui / web / src / composables / Utils.ts
CommitLineData
f568f368 1const isUndefined = (value: unknown): boolean => {
66a7748d
JB
2 return typeof value === 'undefined'
3}
f568f368
JB
4
5export const ifUndefined = <T>(value: T | undefined, isValue: T): T => {
66a7748d
JB
6 if (isUndefined(value) === true) return isValue
7 return value as T
8}
f568f368
JB
9
10// const isIterable = <T>(obj: T): boolean => {
11// if (obj === null || obj === undefined) {
66a7748d 12// return false
f568f368 13// }
66a7748d
JB
14// return typeof (obj as unknown as Iterable<T>)[Symbol.iterator] === 'function'
15// }
f568f368
JB
16
17// const ifNotIterableDo = <T>(obj: T, cb: () => void): void => {
66a7748d
JB
18// if (isIterable(obj) === false) cb()
19// }
f568f368 20
f568f368 21// export const compose = <T>(...fns: ((arg: T) => T)[]): ((x: T) => T) => {
66a7748d
JB
22// return (x: T) => fns.reduceRight((y, fn) => fn(y), x)
23// }