Skip to content

Commit

Permalink
Handle an empty array too, why not
Browse files Browse the repository at this point in the history
Related to #71
  • Loading branch information
TehShrike committed Oct 4, 2017
1 parent bdc290b commit 970a26e
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@ function deepmerge(target, source, optionsArgument) {
}

deepmerge.all = function deepmergeAll(array, optionsArgument) {
if (!Array.isArray(array) || array.length < 1) {
throw new Error('first argument should be an array with at least one element')
if (!Array.isArray(array)) {
throw new Error('first argument should be an array')
}

return array.reduce(function(prev, next) {
Expand Down
4 changes: 2 additions & 2 deletions test/merge-all.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ test('throw error if first argument is not an array', function(t) {
t.end()
})

test('throw error if first argument is an array with no elements', function(t) {
t.throws(merge.all.bind(null, []), Error)
test('return an empty object if first argument is an array with no elements', function(t) {
t.deepEqual(merge.all([]), {})
t.end()
})

Expand Down

0 comments on commit 970a26e

Please sign in to comment.