Files

27 lines
508 B
JavaScript
Raw Permalink Normal View History

2024-04-25 09:29:22 +02:00
function isNumber(value) {
if (Array.isArray(value)) {
2024-04-25 09:29:22 +02:00
return false;
}
return !isNaN(value);
2024-04-25 09:29:22 +02:00
}
/*
Composes multiple functions with same arguments into a single one
NOTE: Functions are executed from end of array to start (right to left)
*/
function compose(...funcs) {
if (funcs.length === 1) {
return funcs[0]
}
return funcs.reduce(
(firstFunction, nextFunction) =>
(...args) =>
firstFunction(nextFunction(...args))
)
}
module.exports = {
isNumber,
compose
}