@ditojs/utils 1.15.0 → 1.16.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.15.0",
3
+ "version": "1.16.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",
@@ -35,5 +35,5 @@
35
35
  "typescript": "^4.9.3"
36
36
  },
37
37
  "types": "types",
38
- "gitHead": "848aed21b94e81ac68f089c4a6bd335b1a97073d"
38
+ "gitHead": "e7e7ddb88965dbffc29c0968054015a647844803"
39
39
  }
@@ -4,7 +4,11 @@ import {
4
4
  import { pick } from '../object/index.js'
5
5
 
6
6
  export function clone(arg, options) {
7
- const { shallow = false, processValue = null } = isFunction(options)
7
+ const {
8
+ shallow = false,
9
+ enumerable = true,
10
+ processValue = null
11
+ } = isFunction(options)
8
12
  ? { processValue: options } // TODO: `callback` deprecated in December 2022.
9
13
  : options || {}
10
14
 
@@ -31,7 +35,8 @@ export function clone(arg, options) {
31
35
  // Prevent calling the actual constructor since it is not guaranteed to
32
36
  // work as intended here, and only clone the non-inherited own properties.
33
37
  copy = Object.create(Object.getPrototypeOf(arg))
34
- for (const key of Reflect.ownKeys(arg)) {
38
+ const keys = enumerable ? Object.keys(arg) : Reflect.ownKeys(arg)
39
+ for (const key of keys) {
35
40
  const desc = Reflect.getOwnPropertyDescriptor(arg, key)
36
41
  if (desc.value != null) {
37
42
  desc.value = handleValue(desc.value)
@@ -63,7 +63,7 @@ describe('clone()', () => {
63
63
  it('should handle non-enumerable properties', async () => {
64
64
  const object = { a: 1 }
65
65
  Object.defineProperty(object, 'b', { value: 2, enumerable: false })
66
- const copy = clone(object)
66
+ const copy = clone(object, { enumerable: false })
67
67
  expect(copy.a).toEqual(1)
68
68
  expect(copy.b).toEqual(2)
69
69
  })