@boost/common
Advanced tools
Comparing version 2.2.2 to 2.3.0
@@ -6,2 +6,14 @@ # Change Log | ||
## 2.3.0 - 2020-10-15 | ||
#### 🚀 Updates | ||
- Add `deepMerge` helper. ([93659b8](https://github.com/milesj/boost/commit/93659b8)) | ||
**Note:** Version bump only for package @boost/common | ||
### 2.2.2 - 2020-10-08 | ||
@@ -8,0 +20,0 @@ |
export { default as createBlueprint } from './createBlueprint'; | ||
export { default as deepFreeze } from './deepFreeze'; | ||
export { default as deepMerge } from './deepMerge'; | ||
export { default as formatMs } from './formatMs'; | ||
@@ -4,0 +5,0 @@ export { default as instanceOf } from './instanceOf'; |
@@ -586,2 +586,29 @@ 'use strict'; | ||
function merge(prev, next) { | ||
const base = prev; | ||
Object.entries(next).forEach(([key, value]) => { | ||
const prevValue = base[key]; | ||
if (isObject(prevValue) && isObject(value)) { | ||
base[key] = merge({ ...prevValue | ||
}, value); | ||
} else if (Array.isArray(prevValue) && Array.isArray(value)) { | ||
base[key] = merge([...prevValue], value); | ||
} else { | ||
base[key] = value; | ||
} | ||
}); | ||
return base; | ||
} | ||
function deepMerge(base, other) { | ||
const next = Array.isArray(base) ? merge([], base) : merge({}, base); | ||
if (other) { | ||
merge(next, other); | ||
} | ||
return next; | ||
} | ||
function formatMs(ms, options) { | ||
@@ -715,2 +742,3 @@ if (!Number.isFinite(ms) || ms === 0) { | ||
exports.deepFreeze = deepFreeze; | ||
exports.deepMerge = deepMerge; | ||
exports.formatMs = formatMs; | ||
@@ -717,0 +745,0 @@ exports.instanceOf = instanceOf; |
{ | ||
"name": "@boost/common", | ||
"version": "2.2.2", | ||
"version": "2.3.0", | ||
"release": "1594765247526", | ||
@@ -38,3 +38,3 @@ "description": "A collection of common utilities, classes, and helpers.", | ||
}, | ||
"gitHead": "ae1d2626dae91a712357029bc6d43a78b422ed27" | ||
"gitHead": "d62e9f07d8ba7d6b195a9bfdc0945eb12d0222ed" | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
60484
53
969