Skip to content

Commit

Permalink
Merge pull request #62 from TehShrike/rollup
Browse files Browse the repository at this point in the history
Publish ESM + CJS + UMD modules
  • Loading branch information
TehShrike authored Jun 13, 2017
2 parents 4169ae4 + 89bc1d9 commit f224417
Show file tree
Hide file tree
Showing 7 changed files with 2,147 additions and 48 deletions.
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

0 comments on commit f224417

Please sign in to comment.