Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/node-cache/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,11 @@
"@biomejs/biome": "^2.3.5",
"@faker-js/faker": "^10.1.0",
"@types/node": "^24.10.1",
"@vitest/coverage-v8": "^3.2.4",
"@vitest/coverage-v8": "^4.0.9",
"rimraf": "^6.1.0",
"tsup": "^8.5.1",
"typescript": "^5.9.3",
"vitest": "^3.2.4"
"vitest": "^4.0.9"
},
"dependencies": {
"cacheable": "workspace:^",
Expand Down
10 changes: 6 additions & 4 deletions packages/node-cache/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,13 +122,13 @@ export class NodeCache<T> extends Hookified {
ttl: number | string = 0,
): boolean {
// Check on key type
/* c8 ignore next 3 */
/* v8 ignore next -- @preserve */
if (typeof key !== "string" && typeof key !== "number") {
throw this.createError(NodeCacheErrors.EKEYTYPE, key);
}

// Check on ttl type
/* c8 ignore next 3 */
/* v8 ignore next -- @preserve */
if (ttl && typeof ttl !== "number" && typeof ttl !== "string") {
throw this.createError(NodeCacheErrors.ETTLTYPE, this.formatKey(key));
}
Expand All @@ -149,6 +149,7 @@ export class NodeCache<T> extends Hookified {
}

// Check on max key size
/* v8 ignore next -- @preserve */
if (this.options.maxKeys) {
const { maxKeys } = this.options;
if (maxKeys > -1 && this.store.size >= maxKeys) {
Expand Down Expand Up @@ -179,7 +180,7 @@ export class NodeCache<T> extends Hookified {
*/
public mset(data: Array<PartialNodeCacheItem<T>>): boolean {
// Check on keys type
/* c8 ignore next 3 */
/* v8 ignore next -- @preserve */
if (!Array.isArray(data)) {
throw this.createError(NodeCacheErrors.EKEYSTYPE);
}
Expand Down Expand Up @@ -242,6 +243,7 @@ export class NodeCache<T> extends Hookified {

for (const key of keys) {
const value = this.get(key);
/* v8 ignore next -- @preserve */
if (value) {
result[this.formatKey(key)] = value as T;
}
Expand Down Expand Up @@ -477,7 +479,7 @@ export class NodeCache<T> extends Hookified {

private createError(errorCode: string, key?: string): Error {
let error = errorCode;
/* c8 ignore next 3 */
/* v8 ignore next -- @preserve */
if (key) {
error = error.replace("__key", key);
}
Expand Down
3 changes: 2 additions & 1 deletion packages/node-cache/src/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ export class NodeCacheStore<T> extends Hookified {

// Hook up the cacheable events
this._cache.on("error", (error: Error) => {
/* c8 ignore next 1 */
/* v8 ignore next -- @preserve */
this.emit("error", error);
});
}
Expand Down Expand Up @@ -133,6 +133,7 @@ export class NodeCacheStore<T> extends Hookified {
*/
public set maxKeys(maxKeys: number) {
this._maxKeys = maxKeys;
/* v8 ignore next -- @preserve */
if (this._maxKeys > 0) {
this._cache.stats.enabled = true;
}
Expand Down
Loading