@ztimson/utils 0.25.12 → 0.25.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cache.d.ts +7 -0
- package/dist/index.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -644,6 +644,15 @@ class Cache {
|
|
|
644
644
|
} else this.delete(key);
|
|
645
645
|
return this;
|
|
646
646
|
}
|
|
647
|
+
/**
|
|
648
|
+
* Find the first cached item to match a filter
|
|
649
|
+
* @param {Partial<T>} filter Partial item to match
|
|
650
|
+
* @param {Boolean} expired Include expired items, defaults to false
|
|
651
|
+
* @returns {T | undefined} Cached item or undefined if nothing matched
|
|
652
|
+
*/
|
|
653
|
+
find(filter, expired) {
|
|
654
|
+
return Object.values(this.store).find((row) => (expired || !row._expired) && includes(row, filter));
|
|
655
|
+
}
|
|
647
656
|
/**
|
|
648
657
|
* Get item from the cache
|
|
649
658
|
* @param {K} key Key to lookup
|