@magic/deep 0.1.5 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -118,5 +118,18 @@ update dependencies
118
118
  * bump required node version to 14.15.4
119
119
  * update dependencies
120
120
 
121
- ##### 0.1.6 - unreleased
121
+ ##### 0.1.6
122
+ * merge now checks if o2.hasOwnProperty is a function before using it to check if we should overwrite keys of o1 or not.
123
+
124
+ ##### 0.1.7
125
+ update @magic/types to avoid circular dependency
126
+
127
+ ##### 0.1.8
128
+ * update dependencies
129
+ * use @magic/types for all type comparisons
130
+
131
+ ##### 0.1.9
132
+ update dependencies
133
+
134
+ ##### 0.1.10 - unreleased
122
135
  ...
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@magic/deep",
3
- "version": "0.1.5",
3
+ "version": "0.1.9",
4
4
  "author": "Wizards & Witches",
5
5
  "description": "manipulate nested objects and arrays",
6
6
  "homepage": "https://github.com/magic/deep",
@@ -30,11 +30,11 @@
30
30
  "src"
31
31
  ],
32
32
  "dependencies": {
33
- "@magic/types": "0.1.14"
33
+ "@magic/types": "0.1.17"
34
34
  },
35
35
  "devDependencies": {
36
- "@magic/format": "0.0.20",
37
- "@magic/test": "0.1.59"
36
+ "@magic/format": "0.0.34",
37
+ "@magic/test": "0.2.0"
38
38
  },
39
39
  "contributors": [
40
40
  {
package/src/flatten.mjs CHANGED
@@ -1,4 +1,6 @@
1
- export const shallow = flat => (Array.isArray(flat) ? flatten(...flat) : flat)
1
+ import is from '@magic/types'
2
+
3
+ export const shallow = flat => (is.array(flat) ? flatten(...flat) : flat)
2
4
 
3
5
  export const concat = (flat, deep) => flat.concat(shallow(deep))
4
6
 
package/src/merge.mjs CHANGED
@@ -1,9 +1,9 @@
1
1
  import is from '@magic/types'
2
2
 
3
3
  export const merge = (o1, o2) => {
4
- if (typeof o1 === 'undefined') {
4
+ if (is.undefined(o1)) {
5
5
  return o2
6
- } else if (typeof o2 === 'undefined') {
6
+ } else if (is.undefined(o2)) {
7
7
  return o1
8
8
  }
9
9
 
@@ -16,8 +16,9 @@ export const merge = (o1, o2) => {
16
16
  if (is.mergeable(o1) && is.mergeable(o2)) {
17
17
  const keys = Object.keys({ ...o1, ...o2 })
18
18
  const final = {}
19
+
19
20
  keys.forEach(key => {
20
- if (!o2.hasOwnProperty(key)) {
21
+ if (!is.function(o2.hasOwnProperty) || !o2.hasOwnProperty(key)) {
21
22
  final[key] = o1[key]
22
23
  } else {
23
24
  final[key] = merge(o1[key], o2[key])