Skip to content

Commit

Permalink
(hotfix): jsonify shouldn't set false to true
Browse files Browse the repository at this point in the history
- meant to use the previous code as an alternative to using a default
  arg, but `!jsonify` detects false (etc), not just undefined
  - switched to just using a default arg, which was what I originally
    used before moving defaults outside of the destructuring
  - alternative is to check `typeof jsonify === 'undefined'` instead
  - default args seem to provide better typings in my experience, so
    stick to that for now
  • Loading branch information
agilgur5 committed Nov 19, 2019
1 parent 10d4cd7 commit 6b1dd3b
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface IOptions {
type StrToAnyMap = {[key: string]: any}

export const persist: IArgs = (name, store, options = {}) => {
let {storage, jsonify, whitelist, blacklist} = options
let {storage, jsonify = true, whitelist, blacklist} = options

// use AsyncLocalStorage by default (or if localStorage was passed in)
if (
Expand All @@ -30,7 +30,6 @@ export const persist: IArgs = (name, store, options = {}) => {
'engine via the `storage:` option.')
}

if (!jsonify) { jsonify = true } // default to true like mobx-persist
const whitelistDict = arrToDict(whitelist)
const blacklistDict = arrToDict(blacklist)

Expand Down

0 comments on commit 6b1dd3b

Please sign in to comment.