Dev Build / cleanup (push) Canceled after 0s
Dev Build / typecheck (push) Canceled after 0s
Dev Build / build (linux-arm64, ubuntu-24.04-arm, linux-arm64) (push) Canceled after 0s
Dev Build / build (linux-x64, ubuntu-latest, linux-x64) (push) Canceled after 0s
Dev Build / build (win-x64, windows-latest, win32-x64) (push) Canceled after 0s
Dev Build / dispatch-dev-docker (push) Skipped
20 lines
495 B
Plaintext
20 lines
495 B
Plaintext
"use strict";
|
|
function returnValue(value) {
|
|
return value;
|
|
}
|
|
function formatMessage(message, callback = returnValue) {
|
|
return message.reduce((prev, curr, index) => {
|
|
let msg;
|
|
if (curr instanceof Error) {
|
|
msg = curr.stack || curr.message;
|
|
} else if (typeof curr === "object") {
|
|
msg = JSON.stringify(curr);
|
|
} else {
|
|
msg = String(curr);
|
|
}
|
|
msg = callback(msg);
|
|
return index === 0 ? msg : `${prev} ${msg}`;
|
|
}, "");
|
|
}
|
|
module.exports = formatMessage;
|