First upload version 0.0.1

This commit is contained in:
Neyra
2026-02-05 15:27:49 +08:00
commit 8e9b7201ed
4182 changed files with 593136 additions and 0 deletions

44
node_modules/node-llama-cpp/dist/utils/withLockfile.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
import lockfile from "proper-lockfile";
import { withLock } from "lifecycle-utils";
import { getConsoleLogPrefix } from "./getConsoleLogPrefix.js";
export const lockfileLockScope = {};
export async function withLockfile({ resourcePath, staleDuration = 1000 * 10, updateInterval = staleDuration / 2, retries = 2 }, callback) {
return await withLock([lockfileLockScope, resourcePath], async () => {
let releaseLock;
let res;
const lockPromise = lockfile.lock(resourcePath, {
stale: staleDuration,
update: updateInterval,
retries,
realpath: false
});
try {
releaseLock = await lockPromise;
}
catch (err) {
console.error(getConsoleLogPrefix() + `Failed to acquire lockfile for "${resourcePath}"`, err);
throw err;
}
try {
res = await callback();
}
catch (err) {
try {
await releaseLock();
}
catch (err) {
console.error(getConsoleLogPrefix() + `Failed to release lockfile for "${resourcePath}"`, err);
}
throw err;
}
try {
await releaseLock();
}
catch (err) {
console.error(getConsoleLogPrefix() + `Failed to release lockfile for "${resourcePath}"`, err);
throw err;
}
return res;
});
}
//# sourceMappingURL=withLockfile.js.map