First upload version 0.0.1
This commit is contained in:
19
node_modules/node-llama-cpp/dist/chatWrappers/generic/utils/getFirstValidResult.js
generated
vendored
Normal file
19
node_modules/node-llama-cpp/dist/chatWrappers/generic/utils/getFirstValidResult.js
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
/**
|
||||
* Call the functions in the array one by one and return the result of the first one that doesn't throw an error.
|
||||
*
|
||||
* If all functions throw an error, throw the error of the last function.
|
||||
*/
|
||||
export function getFirstValidResult(options) {
|
||||
for (let i = 0; i < options.length; i++) {
|
||||
if (i === options.length - 1)
|
||||
return options[i]();
|
||||
try {
|
||||
return options[i]();
|
||||
}
|
||||
catch (err) {
|
||||
// do nothing
|
||||
}
|
||||
}
|
||||
throw new Error("All options failed");
|
||||
}
|
||||
//# sourceMappingURL=getFirstValidResult.js.map
|
||||
Reference in New Issue
Block a user