First upload version 0.0.1
This commit is contained in:
25
node_modules/node-llama-cpp/dist/utils/withStatusLogs.js
generated
vendored
Normal file
25
node_modules/node-llama-cpp/dist/utils/withStatusLogs.js
generated
vendored
Normal file
@@ -0,0 +1,25 @@
|
||||
import chalk from "chalk";
|
||||
import logSymbols from "log-symbols";
|
||||
import { clockChar } from "../consts.js";
|
||||
import { getConsoleLogPrefix } from "./getConsoleLogPrefix.js";
|
||||
export default async function withStatusLogs(messageAndOptions, callback) {
|
||||
if (typeof messageAndOptions !== "string" && messageAndOptions.disableLogs)
|
||||
return await callback();
|
||||
console.log(getConsoleLogPrefix() + `${chalk.cyan(clockChar)} ${typeof messageAndOptions === "string" ? messageAndOptions : messageAndOptions.loading}`);
|
||||
try {
|
||||
const res = await callback();
|
||||
if (typeof messageAndOptions !== "string")
|
||||
console.log(getConsoleLogPrefix() + `${logSymbols.success} ${messageAndOptions.success}`);
|
||||
else
|
||||
console.log(getConsoleLogPrefix() + `${logSymbols.success} ${messageAndOptions}`);
|
||||
return res;
|
||||
}
|
||||
catch (er) {
|
||||
if (typeof messageAndOptions !== "string")
|
||||
console.log(getConsoleLogPrefix() + `${logSymbols.error} ${messageAndOptions.fail}`);
|
||||
else
|
||||
console.log(getConsoleLogPrefix() + `${logSymbols.error} ${messageAndOptions}`);
|
||||
throw er;
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=withStatusLogs.js.map
|
||||
Reference in New Issue
Block a user