another-cache-wrapper
Advanced tools
Comparing version 1.0.22 to 1.0.23
@@ -16,2 +16,2 @@ /** | ||
export declare function cacheKey(key: any, prefixes?: string[] | string): string; | ||
export declare function cachedMethodCall(prefix: string[] | string, method: () => any, keyExtractor?: () => any, ttl?: number): () => Promise<any>; | ||
export declare function cachedMethodCall(prefix: string[] | string, method: () => any, keyExtractor?: () => any, ttl?: number, thisArg?: any): () => Promise<any>; |
@@ -38,3 +38,3 @@ "use strict"; | ||
exports.cacheKey = cacheKey; | ||
function cachedMethodCall(prefix, method, keyExtractor = index_1.default.identity, ttl = exports.DEFAULT_TTL) { | ||
function cachedMethodCall(prefix, method, keyExtractor = index_1.default.identity, ttl = exports.DEFAULT_TTL, thisArg = null) { | ||
return function () { | ||
@@ -51,3 +51,3 @@ return __awaiter(this, arguments, void 0, function* () { | ||
// fallback to call unwrapped method | ||
return method.apply(null, args); | ||
return method.apply(thisArg, args); | ||
} | ||
@@ -65,3 +65,3 @@ // workout cache key for this params | ||
// otherwise call the function | ||
const liveResult = yield index_1.default.attempt(method, args); | ||
const liveResult = yield index_1.default.attempt(index_1.default.bind(method, thisArg, args)); | ||
// if it raises an error | ||
@@ -68,0 +68,0 @@ if (index_1.default.isError(liveResult)) { |
{ | ||
"name": "another-cache-wrapper", | ||
"version": "1.0.22", | ||
"version": "1.0.23", | ||
"description": "custom cache interface", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
54258