Skip to content

Commit

Permalink
Merge pull request #140 from RebeccaStevens/no-enumerable-props
Browse files Browse the repository at this point in the history
  • Loading branch information
RebeccaStevens authored Jun 13, 2022
2 parents 172f29a + a8de1ca commit 73f0940
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/deepmerge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,9 @@ function defaultMergeRecords<
}
}

// assert(propValues.length > 0);
if (propValues.length === 0) {
continue;
}

const updatedMeta = utils.metaDataUpdater(meta, {
key,
Expand Down
33 changes: 33 additions & 0 deletions tests/deepmerge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -465,6 +465,39 @@ test(`supports symbols`, (t) => {
t.deepEqual(merged[testSymbol3], expected[testSymbol3]);
});

test("enumerable keys", (t) => {
const x = {};
const y = {};

Object.defineProperties(x, {
a: {
value: 1,
enumerable: false,
},
b: {
value: 2,
enumerable: true,
},
});

Object.defineProperties(y, {
a: {
value: 3,
enumerable: false,
},
b: {
value: 4,
enumerable: false,
},
});

const expected = { b: 2 };

const merged = deepmerge(x, y);

t.deepEqual(merged, expected);
});

/* eslint-disable no-proto, @typescript-eslint/naming-convention */
test(`merging objects with own __proto__`, (t) => {
const a = { key1: "value1" };
Expand Down

0 comments on commit 73f0940

Please sign in to comment.