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

Publish ESM + CJS + UMD modules #62

Merged
merged 3 commits into from
Jun 13, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
node_modules
dist/*
4 changes: 3 additions & 1 deletion README.markdown
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
deepmerge
=========

> ~550B gzipped, ~1.0kB minified
> ~540B gzipped, ~1.1kB minified

Merge the enumerable attributes of two objects deeply.

Expand Down Expand Up @@ -111,6 +111,8 @@ With [npm](http://npmjs.org) do:
npm install deepmerge
```

Just want to download the file without using any package managers/bundlers? Click [here](https://unpkg.com/deepmerge).

test
====

Expand Down
28 changes: 5 additions & 23 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,4 @@
(function (root, factory) {
if (typeof define === 'function' && define.amd) {
define(factory);
} else if (typeof exports === 'object') {
module.exports = factory();
} else {
root.deepmerge = factory();
}
}(this, function () {

function isMergeableObject(val) {
var nonNullObject = val && typeof val === 'object'

return nonNullObject
&& Object.prototype.toString.call(val) !== '[object RegExp]'
&& Object.prototype.toString.call(val) !== '[object Date]'
}
var isMergeableObject = require('is-mergeable-object')

function emptyTarget(val) {
return Array.isArray(val) ? [] : {}
Expand Down Expand Up @@ -42,11 +26,11 @@ function defaultArrayMerge(target, source, optionsArgument) {
function mergeObject(target, source, optionsArgument) {
var destination = {}
if (isMergeableObject(target)) {
Object.keys(target).forEach(function (key) {
Object.keys(target).forEach(function(key) {
destination[key] = cloneIfNecessary(target[key], optionsArgument)
})
}
Object.keys(source).forEach(function (key) {
Object.keys(source).forEach(function(key) {
if (!isMergeableObject(source[key]) || !target[key]) {
destination[key] = cloneIfNecessary(source[key], optionsArgument)
} else {
Expand All @@ -57,7 +41,7 @@ function mergeObject(target, source, optionsArgument) {
}

function deepmerge(target, source, optionsArgument) {
var array = Array.isArray(source);
var array = Array.isArray(source)
var options = optionsArgument || { arrayMerge: defaultArrayMerge }
var arrayMerge = options.arrayMerge || defaultArrayMerge

Expand All @@ -79,6 +63,4 @@ deepmerge.all = function deepmergeAll(array, optionsArgument) {
})
}

return deepmerge

}));
module.exports = deepmerge
Loading