@cacheable/memoize
Advanced tools
+7
-3
@@ -32,3 +32,3 @@ "use strict"; | ||
| const { ttl, keyPrefix, cache } = options; | ||
| return function(...arguments_) { | ||
| return (...arguments_) => { | ||
| let cacheKey = createWrapKey(function_, arguments_, keyPrefix); | ||
@@ -79,3 +79,3 @@ if (options.createKey) { | ||
| const { keyPrefix, cache } = options; | ||
| return async function(...arguments_) { | ||
| return async (...arguments_) => { | ||
| let cacheKey = createWrapKey(function_, arguments_, keyPrefix); | ||
@@ -85,3 +85,7 @@ if (options.createKey) { | ||
| } | ||
| return getOrSet(cacheKey, async () => function_(...arguments_), options); | ||
| return getOrSet( | ||
| cacheKey, | ||
| async () => function_(...arguments_), | ||
| options | ||
| ); | ||
| }; | ||
@@ -88,0 +92,0 @@ } |
+8
-4
| // src/index.ts | ||
| import { hash, coalesceAsync } from "@cacheable/utils"; | ||
| import { coalesceAsync, hash } from "@cacheable/utils"; | ||
| function wrapSync(function_, options) { | ||
| const { ttl, keyPrefix, cache } = options; | ||
| return function(...arguments_) { | ||
| return (...arguments_) => { | ||
| let cacheKey = createWrapKey(function_, arguments_, keyPrefix); | ||
@@ -51,3 +51,3 @@ if (options.createKey) { | ||
| const { keyPrefix, cache } = options; | ||
| return async function(...arguments_) { | ||
| return async (...arguments_) => { | ||
| let cacheKey = createWrapKey(function_, arguments_, keyPrefix); | ||
@@ -57,3 +57,7 @@ if (options.createKey) { | ||
| } | ||
| return getOrSet(cacheKey, async () => function_(...arguments_), options); | ||
| return getOrSet( | ||
| cacheKey, | ||
| async () => function_(...arguments_), | ||
| options | ||
| ); | ||
| }; | ||
@@ -60,0 +64,0 @@ } |
+10
-12
| { | ||
| "name": "@cacheable/memoize", | ||
| "version": "1.1.0", | ||
| "version": "1.1.1", | ||
| "description": "Memoization utilities for cacheable", | ||
@@ -24,7 +24,5 @@ "type": "module", | ||
| "devDependencies": { | ||
| "@faker-js/faker": "^9.9.0", | ||
| "@keyv/redis": "^5.0.0", | ||
| "@keyv/valkey": "^1.0.7", | ||
| "@types/eslint": "^9.6.1", | ||
| "@types/node": "^24.1.0", | ||
| "@biomejs/biome": "^2.2.2", | ||
| "@faker-js/faker": "^10.0.0", | ||
| "@types/node": "^24.3.0", | ||
| "@vitest/coverage-v8": "^3.2.4", | ||
@@ -34,5 +32,4 @@ "lru-cache": "^11.1.0", | ||
| "tsup": "^8.5.0", | ||
| "typescript": "^5.8.3", | ||
| "vitest": "^3.2.4", | ||
| "xo": "^1.2.1" | ||
| "typescript": "^5.9.2", | ||
| "vitest": "^3.2.4" | ||
| }, | ||
@@ -55,3 +52,3 @@ "keywords": [ | ||
| "dependencies": { | ||
| "@cacheable/utils": "^1.1.0" | ||
| "@cacheable/utils": "^1.1.1" | ||
| }, | ||
@@ -61,6 +58,7 @@ "scripts": { | ||
| "prepublish": "pnpm build", | ||
| "test": "xo --fix && vitest run --coverage", | ||
| "test:ci": "xo && vitest run --coverage", | ||
| "lint": "biome check --write --error-on-warnings", | ||
| "test": "pnpm lint && vitest run --coverage", | ||
| "test:ci": "biome check --error-on-warnings && vitest run --coverage", | ||
| "clean": "rimraf ./dist ./coverage ./node_modules" | ||
| } | ||
| } |
+0
-2
@@ -10,4 +10,2 @@ [<img align="center" src="https://cacheable.org/logo.svg" alt="Cacheable" />](https://github.com/jaredwray/cacheable) | ||
| [](https://github.com/jaredwray/cacheable/blob/main/LICENSE) | ||
| [](https://www.npmjs.com/package/@cacheable/memoize) | ||
| [](https://github.com/jaredwray/cacheable/blob/main/LICENSE) | ||
@@ -14,0 +12,0 @@ # Table of Contents |
9
-25%219
3.79%19042
-1.05%167
-1.18%Updated