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/LruCache.js generated vendored Normal file
View File

@@ -0,0 +1,44 @@
export class LruCache {
maxSize;
/** @internal */ _cache = new Map();
/** @internal */ _onDelete;
constructor(maxSize, { onDelete } = {}) {
this.maxSize = maxSize;
this._onDelete = onDelete;
}
get(key) {
if (!this._cache.has(key))
return undefined;
// move the key to the end of the cache
const item = this._cache.get(key);
this._cache.delete(key);
this._cache.set(key, item);
return item;
}
set(key, value) {
if (this._cache.has(key))
this._cache.delete(key);
else if (this._cache.size >= this.maxSize) {
const firstKey = this.firstKey;
if (this._onDelete != null)
this._onDelete(firstKey, this._cache.get(firstKey));
this._cache.delete(firstKey);
}
this._cache.set(key, value);
return this;
}
get firstKey() {
return this._cache.keys()
.next().value;
}
clear() {
this._cache.clear();
}
keys() {
return this._cache.keys();
}
delete(key) {
this._cache.delete(key);
}
}
//# sourceMappingURL=LruCache.js.map