hinted-tree-merger 4.7.1 → 4.8.2
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/LICENSE +1 -1
- package/README.md +3 -3
- package/package.json +5 -5
- package/src/util.mjs +12 -5
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -160,7 +160,7 @@ Returns **any** value without hint
|
|
|
160
160
|
|
|
161
161
|
## indexFor
|
|
162
162
|
|
|
163
|
-
Find best insertion point for b\[i] in a
|
|
163
|
+
Find best insertion point for b\[i] in a.
|
|
164
164
|
|
|
165
165
|
### Parameters
|
|
166
166
|
|
|
@@ -170,7 +170,7 @@ Find best insertion point for b\[i] in a
|
|
|
170
170
|
|
|
171
171
|
## keyFor
|
|
172
172
|
|
|
173
|
-
Deliver key value to identify object
|
|
173
|
+
Deliver key value to identify object.
|
|
174
174
|
|
|
175
175
|
### Parameters
|
|
176
176
|
|
|
@@ -181,7 +181,7 @@ Returns **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
181
181
|
|
|
182
182
|
## sortObjectsByKeys
|
|
183
183
|
|
|
184
|
-
Sort keys in source
|
|
184
|
+
Sort keys in source.
|
|
185
185
|
|
|
186
186
|
### Parameters
|
|
187
187
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hinted-tree-merger",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.2",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -32,13 +32,13 @@
|
|
|
32
32
|
"lint:docs": "documentation lint ./src/**/*.mjs"
|
|
33
33
|
},
|
|
34
34
|
"devDependencies": {
|
|
35
|
-
"ava": "^
|
|
36
|
-
"c8": "^7.
|
|
35
|
+
"ava": "^4.0.1",
|
|
36
|
+
"c8": "^7.11.0",
|
|
37
37
|
"documentation": "^13.2.5",
|
|
38
|
-
"semantic-release": "^
|
|
38
|
+
"semantic-release": "^19.0.2"
|
|
39
39
|
},
|
|
40
40
|
"engines": {
|
|
41
|
-
"node": ">=14.
|
|
41
|
+
"node": ">=14.18.3"
|
|
42
42
|
},
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
package/src/util.mjs
CHANGED
|
@@ -270,7 +270,7 @@ export function isScalar(a) {
|
|
|
270
270
|
}
|
|
271
271
|
|
|
272
272
|
/**
|
|
273
|
-
* Find best insertion point for b[i] in a
|
|
273
|
+
* Find best insertion point for b[i] in a.
|
|
274
274
|
* @param {any[]} b
|
|
275
275
|
* @param {number} i
|
|
276
276
|
* @param {any[]} a
|
|
@@ -281,8 +281,15 @@ export function indexFor(b, i, a) {
|
|
|
281
281
|
return f >= 0 ? f : a.length;
|
|
282
282
|
}
|
|
283
283
|
|
|
284
|
+
function normalizeValue(value, hint) {
|
|
285
|
+
if (value !== undefined && hint.normalizeValue) {
|
|
286
|
+
return value.replace(new RegExp(hint.normalizeValue), '');
|
|
287
|
+
}
|
|
288
|
+
return value;
|
|
289
|
+
}
|
|
290
|
+
|
|
284
291
|
/**
|
|
285
|
-
* Deliver key value to identify object
|
|
292
|
+
* Deliver key value to identify object.
|
|
286
293
|
* @param {any} object
|
|
287
294
|
* @param {Object} hint
|
|
288
295
|
* @return {string}
|
|
@@ -292,21 +299,21 @@ export function keyFor(object, hint) {
|
|
|
292
299
|
const andKeys = Array.isArray(hint.key) ? hint.key : hint.key.split(/\&/);
|
|
293
300
|
|
|
294
301
|
if (andKeys.length > 1) {
|
|
295
|
-
const keyValues = andKeys.map(k => object[k]);
|
|
302
|
+
const keyValues = andKeys.map(k => normalizeValue(object[k], hint));
|
|
296
303
|
return keyValues.every(v => v === undefined)
|
|
297
304
|
? undefined
|
|
298
305
|
: keyValues.join(":");
|
|
299
306
|
}
|
|
300
307
|
|
|
301
308
|
const orKeys = Array.isArray(hint.key) ? hint.key : hint.key.split(/\|/);
|
|
302
|
-
return orKeys.map(k => object[k]).find(v => v !== undefined);
|
|
309
|
+
return orKeys.map(k => normalizeValue(object[k], hint)).find(v => v !== undefined);
|
|
303
310
|
}
|
|
304
311
|
|
|
305
312
|
return undefined;
|
|
306
313
|
}
|
|
307
314
|
|
|
308
315
|
/**
|
|
309
|
-
* Sort keys in source
|
|
316
|
+
* Sort keys in source.
|
|
310
317
|
* @param {Object} source
|
|
311
318
|
* @param compare
|
|
312
319
|
* @return {Object} source with keys orderd by compare function
|