Skip to content

Commit

Permalink
Merge branch 'master' into setter-observable
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Apr 28, 2021
2 parents 4952147 + db9602f commit 8a69dfe
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
sudo: false
os:
- linux
- osx
Expand Down
11 changes: 11 additions & 0 deletions test.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ describe('set', function() {
assert.equal(o.a.b, 'c');
});

it('should create a nested array if it does not already exist', function() {
const o = {};
set(o, 'a.0', 'c');
set(o, 'a.1', 'd');
assert(Array.isArray(o.a));
assert.equal(o.a[0], 'c');
let actual = "";
o.a.map(i=> actual +=i);
assert.equal(actual, "cd");
});

it('should merge an existing value with the given value', function() {
var o = {a: {b: {c: 'd'}}};
set(o, 'a.b', {y: 'z'}, { merge: true });
Expand Down

0 comments on commit 8a69dfe

Please sign in to comment.