Skip to content

Commit

Permalink
Merge pull request #13 from mbelsky/patch-1
Browse files Browse the repository at this point in the history
Fix TypeError for null objects (#12)

closes #12
  • Loading branch information
jonschlinkert authored May 25, 2019
2 parents 923d58d + c280ba3 commit 7bd5011
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 1 addition & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,8 @@ function createKey(pattern, options) {

function isObject(val) {
switch (typeof val) {
case 'null':
return false;
case 'object':
return true;
return val !== null;
case 'function':
return true;
default: {
Expand Down
4 changes: 3 additions & 1 deletion test.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,10 @@ const set = require('./');

describe('set', function() {
it('should return non-objects', function() {
const res = set('foo', 'a.b', 'c');
var res = set('foo', 'a.b', 'c');
assert.equal(res, 'foo');
res = set(null, 'a.b', 'c');
assert.equal(res, null);
});

it('should create a nested property if it does not already exist', function() {
Expand Down

0 comments on commit 7bd5011

Please sign in to comment.