Skip to content

Commit

Permalink
refine conditional
Browse files Browse the repository at this point in the history
  • Loading branch information
standielpls committed Aug 28, 2024
1 parent eb4b0dc commit 0fbf903
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions packages/core/src/tools/create-cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -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"'
Expand All @@ -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);
Expand Down

0 comments on commit 0fbf903

Please sign in to comment.