Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dates should merge #31

Closed
will123195 opened this issue Apr 11, 2016 · 2 comments
Closed

Dates should merge #31

will123195 opened this issue Apr 11, 2016 · 2 comments
Labels

Comments

@will123195
Copy link

For example:

$ node
> require('deepmerge')({a:new Date()}, {a:new Date()})
{ a: {} }

Expected behavior:

$ node
> require('deepmerge')({a:new Date()}, {a:new Date()})
{ a: Mon Apr 11 2016 19:25:29 GMT-0400 (EDT) }
@neopostmodern
Copy link

neopostmodern commented Sep 17, 2016

You can fix this by changing these lines to:

            if (Object.prototype.toString.call(src[key]).includes("Date")) {
                dst[key] = src[key];
            } else if (typeof src[key] !== 'object' || !src[key]) {
                dst[key] = src[key];
            }
            else {
                if (!target[key]) {
                    dst[key] = src[key];
                } else {
                    dst[key] = deepmerge(target[key], src[key]);
                }
            }

(I don't bother to write a PR because the package seems pretty abandoned.)

EDIT: If you don't need deepmerge specifically you should of course simply _.merge!

@KyleAMathews
Copy link
Collaborator

@neopostmodern this package isn't abandoned, it's waiting for someone like you to maintain it! ;-) Just sign up at #25 and I'll make you a collaborator + give you the release bit for NPM.

@TehShrike TehShrike added the bug label Sep 27, 2016
TehShrike added a commit that referenced this issue Sep 27, 2016
- Extra test for #18
- Some bugs similar to #23 and #31 where regexes and dates wouldn't be copied correctly across arrays
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants