Skip to content

Commit

Permalink
fix: tap add null condition
Browse files Browse the repository at this point in the history
  • Loading branch information
rubeniskov committed Dec 6, 2020
1 parent aa6d047 commit e19ba48
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tap.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ const {
JSONPATCH_SEP,
} = require('./constants');

const tap = (obj, path, defaultValue) => path.substring(1).split(JSONPATCH_SEP).reduce((prev, chunk) => typeof prev === 'object' && prev[chunk] !== undefined ? prev[chunk] : defaultValue, obj);
const tap = (obj, path, defaultValue) => path.substring(1).split(JSONPATCH_SEP).reduce((prev, chunk) => typeof prev === 'object' && prev !== null && prev[chunk] !== undefined ? prev[chunk] : defaultValue, obj);

module.exports = tap;

0 comments on commit e19ba48

Please sign in to comment.