From 0fbf903e6d8665aba929630d8a85db2afb29435c Mon Sep 17 00:00:00 2001 From: Stanley Chin Date: Wed, 28 Aug 2024 12:08:31 -0400 Subject: [PATCH] refine conditional --- packages/core/src/tools/create-cache.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/packages/core/src/tools/create-cache.js b/packages/core/src/tools/create-cache.js index bd41da0e1..96040c464 100644 --- a/packages/core/src/tools/create-cache.js +++ b/packages/core/src/tools/create-cache.js @@ -27,8 +27,9 @@ const createCache = (input) => { } if ( - (scope != null && !_.isArray(scope)) || - !scope.every((v) => v === 'user' || v === 'auth') + scope !== null && + (!Array.isArray(scope) || + !scope.every((v) => v === 'user' || v === 'auth')) ) { throw new TypeError( 'scope must be an array of strings with values "user" or "auth"' @@ -45,12 +46,12 @@ const createCache = (input) => { const result = await rpc('zcache_get', key, scope); return result ? JSON.parse(result) : null; }, - set: async (key, value, ttl = null, scope = []) => { + set: async (key, value, ttl = null, scope = null) => { runValidationChecks(rpc, key, value, ttl, scope); return await rpc('zcache_set', key, JSON.stringify(value), ttl, scope); }, - delete: async (key, scope = []) => { + delete: async (key, scope = null) => { runValidationChecks(rpc, key, scope); return await rpc('zcache_delete', key, scope);