@ditojs/utils 1.5.0 → 1.8.0

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ditojs/utils",
3
- "version": "1.5.0",
3
+ "version": "1.8.0",
4
4
  "type": "module",
5
5
  "description": "Dito.js Utility Functions – Dito.js is a declarative and modern web framework, based on Objection.js, Koa.js and Vue.js",
6
6
  "repository": "https://github.com/ditojs/dito/tree/master/packages/utils",
@@ -27,5 +27,5 @@
27
27
  "dependencies": {
28
28
  "punycode": "^2.1.1"
29
29
  },
30
- "gitHead": "36a57512228cc233211bf6e4038123a9e775f5c5"
30
+ "gitHead": "bb2c9e85083eabc51d1f4b1fd0bffd6b306b0e47"
31
31
  }
@@ -7,7 +7,7 @@ describe('shuffle()', () => {
7
7
  expect(shuffle(array)).not.toBe(array)
8
8
  })
9
9
 
10
- it('should contain the same elements after a collection is shuffled', () => {
10
+ it(`should contain the same elements after a collection is shuffled and sorted again`, () => {
11
11
  expect(shuffle(array).sort()).toStrictEqual(array)
12
12
  })
13
13
 
@@ -11,10 +11,7 @@ export function merge(target, ...sources) {
11
11
  ? clone(target)
12
12
  : target
13
13
  for (const key of Object.keys(source)) {
14
- const value = _merge(target[key], source[key], true)
15
- if (value !== undefined || !(key in result)) {
16
- result[key] = value
17
- }
14
+ result[key] = _merge(target[key], source[key], true)
18
15
  }
19
16
  return result
20
17
  }
@@ -80,21 +80,20 @@ describe('merge()', () => {
80
80
  expect(actual2.a).toStrictEqual([[4, 5, 3]])
81
81
  })
82
82
 
83
- it('should not overwrite existing values with `undefined` in objects', () => {
83
+ it('should overwrite existing values with `undefined` in objects', () => {
84
84
  const actual = merge({ a: 1 }, { a: undefined, b: undefined })
85
- expect(actual).toStrictEqual({ a: 1, b: undefined })
85
+ expect(actual).toStrictEqual({ a: undefined, b: undefined })
86
86
  })
87
87
 
88
- it('should not overwrite existing values with `undefined` in arrays', () => {
88
+ it('should overwrite existing values with `undefined` in arrays', () => {
89
89
  const array1 = [1]
90
90
  array1[2] = 3
91
91
  const actual1 = merge([4, 5, 6], array1)
92
- const expected1 = [1, 5, 3]
93
- expect(actual1).toStrictEqual(expected1)
92
+ expect(actual1).toStrictEqual([1, 5, 3])
94
93
 
95
94
  const array2 = [1, undefined, 3]
96
95
  const actual2 = merge([4, 5, 6], array2)
97
- expect(actual2).toStrictEqual(expected1)
96
+ expect(actual2).toStrictEqual([1, undefined, 3])
98
97
  })
99
98
 
100
99
  it('should merge regexps', () => {
@@ -1,4 +1,4 @@
1
- // eslint-disable-next-line node/no-deprecated-api
1
+ // eslint-disable-next-line n/no-deprecated-api
2
2
  import punycode from 'punycode'
3
3
 
4
4
  // Best effort approach, allowing Internationalized domain name (with punycode)