Skip to content

Commit

Permalink
Merge pull request #46 from SebastienTainon/patch-typeof
Browse files Browse the repository at this point in the history
Use typeof instead of instanceof to check for functions (fix for [vuex] unknown local mutation type)
  • Loading branch information
davestewart authored Feb 16, 2019
2 parents 78a1d56 + 8d1bc31 commit 6cbb37a
Show file tree
Hide file tree
Showing 4 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/helpers/accessors.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export default function (store) {
const getter = makeGetter(store, path)
if (typeof getter !== 'undefined') {
const value = getter()
return value instanceof Function
return typeof value === 'function'
? value(...args)
: value
}
Expand Down
2 changes: 1 addition & 1 deletion src/helpers/store.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Payload from '../classes/Payload'
* @returns {Array}
*/
function getStateKeys (state) {
return getKeys(state instanceof Function ? state() : state)
return getKeys(typeof state === 'function' ? state() : state)
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/plugin/debug.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export default function debug () {
console.log(`
[Vuex Pathify] Options:
Mapping (${options.mapping instanceof Function ? 'custom' : options.mapping})
Mapping (${typeof options.mapping === 'function' ? 'custom' : options.mapping})
-------------------------------
path : value
state : ${resolve('state')}
Expand Down
2 changes: 1 addition & 1 deletion src/services/resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export function resolveName (type, name) {

// unconfigured resolver! (runs once)
if (!fn) {
if (options.mapping instanceof Function) {
if (typeof options.mapping === 'function') {
fn = options.mapping
}
else {
Expand Down

0 comments on commit 6cbb37a

Please sign in to comment.