@jsopen/objects 1.5.0 → 1.5.1

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/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
- # v1.5.0
2
- [2024-11-26]
1
+ # v1.5.1
2
+ [2025-02-27]
3
3
 
4
- ### Changes
4
+ ### Fixes
5
5
 
6
- * refactor: Optimized typing ([`a333bd9`](https://github.com/panates/jsopen-objects/commit/a333bd938277888a98a9161123f532872c65ac06))
6
+ * fix: Fixed calling cached filter function issue ([`b8a3849`](https://github.com/panates/jsopen-objects/commit/b8a38494567cf824d8c6983e0a00b4233356fa2f))
package/cjs/merge.js CHANGED
@@ -13,9 +13,8 @@ function merge(target, source, options) {
13
13
  throw new TypeError('"target" argument must be an object');
14
14
  }
15
15
  const fn = getMergeFunction(options);
16
- return fn(target, source, '', options, fn, is_object_js_1.isObject, is_object_js_1.isPlainObject, arrayClone);
16
+ return fn(target, source, options, '');
17
17
  }
18
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
19
18
  const functionCache = new Map();
20
19
  function getMergeFunction(options) {
21
20
  const cacheKey = [
@@ -48,7 +47,7 @@ function getMergeFunction(options) {
48
47
  function buildMerge(options) {
49
48
  const scriptL0 = [
50
49
  `
51
- const { options, merge, isObject, isPlainObject, deepTest, arrayClone } = context;
50
+ const { merge, isObject, isPlainObject, deepTest, arrayClone } = context;
52
51
  const hasOwnProperty = Object.prototype.hasOwnProperty;
53
52
  const keys = Object.getOwnPropertyNames(source);
54
53
  keys.push(...Object.getOwnPropertySymbols(source));
@@ -60,7 +59,6 @@ let trgVal;
60
59
  ];
61
60
  // noinspection JSUnusedGlobalSymbols
62
61
  const context = {
63
- options,
64
62
  deepTest: is_object_js_1.isPlainObject,
65
63
  isPlainObject: is_object_js_1.isPlainObject,
66
64
  isObject: is_object_js_1.isObject,
@@ -194,7 +192,7 @@ if (moveArraysCallback(key, subPath, target, source)) {
194
192
  scriptL4IsArray.push('}');
195
193
  }
196
194
  scriptL5CloneArrays.push(`
197
- descriptor.value = arrayClone(srcVal, merge, subPath);
195
+ descriptor.value = arrayClone(srcVal, options, merge, subPath);
198
196
  Object.defineProperty(target, key, descriptor);
199
197
  continue;
200
198
  `);
@@ -206,7 +204,7 @@ if (!isObject(trgVal)) {
206
204
  descriptor.value = trgVal = {};
207
205
  Object.defineProperty(target, key, descriptor);
208
206
  }
209
- merge(trgVal, srcVal, subPath, options);
207
+ merge(trgVal, srcVal, options, subPath);
210
208
  continue;`);
211
209
  }
212
210
  /** ************* finalize *****************/
@@ -215,17 +213,16 @@ descriptor.value = srcVal;
215
213
  Object.defineProperty(target, key, descriptor);`);
216
214
  scriptL0.push('return target;');
217
215
  const script = _flattenText(scriptL0);
218
- // eslint-disable-next-line @typescript-eslint/no-implied-eval,prefer-const
219
- const fn = Function('target', 'source', 'curPath', 'context', script);
220
- context.merge = (target, source, curPath) => fn(target, source, curPath, context);
216
+ const fn = Function('target', 'source', 'options', 'curPath', 'context', script);
217
+ context.merge = (target, source, opts, curPath) => fn(target, source, opts, curPath, context);
221
218
  return context.merge;
222
219
  }
223
- function arrayClone(arr, _merge, curPath) {
220
+ function arrayClone(arr, options, _merge, curPath) {
224
221
  return arr.map((x) => {
225
222
  if (Array.isArray(x))
226
- return arrayClone(x, _merge, curPath);
223
+ return arrayClone(x, options, _merge, curPath);
227
224
  if (typeof x === 'object' && !(0, type_guards_js_1.isBuiltIn)(x))
228
- return _merge({}, x, curPath);
225
+ return _merge({}, x, options, curPath);
229
226
  return x;
230
227
  });
231
228
  }
@@ -1 +1 @@
1
- {"root":["../../src/clone.ts","../../src/index.ts","../../src/is-object.ts","../../src/merge.ts","../../src/omit.ts","../../src/type-guards.ts"],"version":"5.7.2"}
1
+ {"root":["../../src/clone.ts","../../src/index.ts","../../src/is-object.ts","../../src/merge.ts","../../src/omit.ts","../../src/type-guards.ts"],"version":"5.7.3"}
package/esm/merge.js CHANGED
@@ -9,9 +9,8 @@ export function merge(target, source, options) {
9
9
  throw new TypeError('"target" argument must be an object');
10
10
  }
11
11
  const fn = getMergeFunction(options);
12
- return fn(target, source, '', options, fn, isObject, isPlainObject, arrayClone);
12
+ return fn(target, source, options, '');
13
13
  }
14
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
15
14
  const functionCache = new Map();
16
15
  export function getMergeFunction(options) {
17
16
  const cacheKey = [
@@ -44,7 +43,7 @@ export function getMergeFunction(options) {
44
43
  function buildMerge(options) {
45
44
  const scriptL0 = [
46
45
  `
47
- const { options, merge, isObject, isPlainObject, deepTest, arrayClone } = context;
46
+ const { merge, isObject, isPlainObject, deepTest, arrayClone } = context;
48
47
  const hasOwnProperty = Object.prototype.hasOwnProperty;
49
48
  const keys = Object.getOwnPropertyNames(source);
50
49
  keys.push(...Object.getOwnPropertySymbols(source));
@@ -56,7 +55,6 @@ let trgVal;
56
55
  ];
57
56
  // noinspection JSUnusedGlobalSymbols
58
57
  const context = {
59
- options,
60
58
  deepTest: isPlainObject,
61
59
  isPlainObject,
62
60
  isObject,
@@ -190,7 +188,7 @@ if (moveArraysCallback(key, subPath, target, source)) {
190
188
  scriptL4IsArray.push('}');
191
189
  }
192
190
  scriptL5CloneArrays.push(`
193
- descriptor.value = arrayClone(srcVal, merge, subPath);
191
+ descriptor.value = arrayClone(srcVal, options, merge, subPath);
194
192
  Object.defineProperty(target, key, descriptor);
195
193
  continue;
196
194
  `);
@@ -202,7 +200,7 @@ if (!isObject(trgVal)) {
202
200
  descriptor.value = trgVal = {};
203
201
  Object.defineProperty(target, key, descriptor);
204
202
  }
205
- merge(trgVal, srcVal, subPath, options);
203
+ merge(trgVal, srcVal, options, subPath);
206
204
  continue;`);
207
205
  }
208
206
  /** ************* finalize *****************/
@@ -211,17 +209,16 @@ descriptor.value = srcVal;
211
209
  Object.defineProperty(target, key, descriptor);`);
212
210
  scriptL0.push('return target;');
213
211
  const script = _flattenText(scriptL0);
214
- // eslint-disable-next-line @typescript-eslint/no-implied-eval,prefer-const
215
- const fn = Function('target', 'source', 'curPath', 'context', script);
216
- context.merge = (target, source, curPath) => fn(target, source, curPath, context);
212
+ const fn = Function('target', 'source', 'options', 'curPath', 'context', script);
213
+ context.merge = (target, source, opts, curPath) => fn(target, source, opts, curPath, context);
217
214
  return context.merge;
218
215
  }
219
- function arrayClone(arr, _merge, curPath) {
216
+ function arrayClone(arr, options, _merge, curPath) {
220
217
  return arr.map((x) => {
221
218
  if (Array.isArray(x))
222
- return arrayClone(x, _merge, curPath);
219
+ return arrayClone(x, options, _merge, curPath);
223
220
  if (typeof x === 'object' && !isBuiltIn(x))
224
- return _merge({}, x, curPath);
221
+ return _merge({}, x, options, curPath);
225
222
  return x;
226
223
  });
227
224
  }
@@ -1 +1 @@
1
- {"root":["../../src/clone.ts","../../src/index.ts","../../src/is-object.ts","../../src/merge.ts","../../src/omit.ts","../../src/type-guards.ts"],"version":"5.7.2"}
1
+ {"root":["../../src/clone.ts","../../src/index.ts","../../src/is-object.ts","../../src/merge.ts","../../src/omit.ts","../../src/type-guards.ts"],"version":"5.7.3"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@jsopen/objects",
3
3
  "description": "Helper utilities for working with JavaScript objects and arrays",
4
- "version": "1.5.0",
4
+ "version": "1.5.1",
5
5
  "author": "Panates",
6
6
  "license": "MIT",
7
7
  "dependencies": {