hinted-tree-merger 6.2.8 → 6.3.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/README.md +1 -2
- package/package.json +2 -2
- package/src/reanimate-hints.mjs +18 -6
- package/src/util.mjs +10 -9
- package/types/util.d.mts +2 -1
package/README.md
CHANGED
|
@@ -8,7 +8,6 @@
|
|
|
8
8
|
[](https://github.com/prettier/prettier)
|
|
9
9
|
[](http://commitizen.github.io/cz-cli/)
|
|
10
10
|
[](https://snyk.io/test/github/arlac77/hinted-tree-merger)
|
|
11
|
-
[](https://coveralls.io/github/arlac77/hinted-tree-merger)
|
|
12
11
|
|
|
13
12
|
# hinted-tree-merger
|
|
14
13
|
|
|
@@ -214,7 +213,7 @@ Returns **[Object](https://developer.mozilla.org/docs/Web/JavaScript/Reference/G
|
|
|
214
213
|
|
|
215
214
|
* `a` **any** 
|
|
216
215
|
* `b` **any** 
|
|
217
|
-
* `definedOrder`
|
|
216
|
+
* `definedOrder` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<([RegExp](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/RegExp) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))>** 
|
|
218
217
|
|
|
219
218
|
## matchingIndex
|
|
220
219
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "hinted-tree-merger",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.3.0",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public",
|
|
6
6
|
"provenance": true
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"ava": "^6.4.1",
|
|
45
|
-
"browser-ava": "^2.3.
|
|
45
|
+
"browser-ava": "^2.3.47",
|
|
46
46
|
"c8": "^10.1.3",
|
|
47
47
|
"documentation": "^14.0.3",
|
|
48
48
|
"semantic-release": "^25.0.2",
|
package/src/reanimate-hints.mjs
CHANGED
|
@@ -19,13 +19,25 @@ const mergeFunctions = [
|
|
|
19
19
|
|
|
20
20
|
export function reanimateHints(hints) {
|
|
21
21
|
for (const { value, path, parents } of walk(hints)) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
22
|
+
switch (path[path.length - 1]) {
|
|
23
|
+
case "merge":
|
|
24
|
+
for (const f of mergeFunctions) {
|
|
25
|
+
if (f.name === value) {
|
|
26
|
+
parents[parents.length - 1].merge = f;
|
|
27
|
+
break;
|
|
28
|
+
}
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
break;
|
|
31
|
+
case "orderBy":
|
|
32
|
+
parents[parents.length - 1].orderBy = value.map(v => {
|
|
33
|
+
if (typeof v === "string" && v[0] === "/" && v.match(/\/[img]?$/)) {
|
|
34
|
+
const m = v.match(/\/([a-z]*)$/)
|
|
35
|
+
const inner = v.substring(1,v.length - m[0].length)
|
|
36
|
+
return new RegExp(inner,m[1]);
|
|
37
|
+
}
|
|
38
|
+
return v;
|
|
39
|
+
});
|
|
40
|
+
break;
|
|
29
41
|
}
|
|
30
42
|
}
|
|
31
43
|
|
package/src/util.mjs
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
OVERWRITE_HINT_REGEX
|
|
5
5
|
} from "./hint.mjs";
|
|
6
6
|
|
|
7
|
-
export function nullAction(options,hint) {}
|
|
7
|
+
export function nullAction(options, hint) {}
|
|
8
8
|
|
|
9
9
|
export function asArray(a) {
|
|
10
10
|
return Array.isArray(a) ? a : a === undefined ? [] : [a];
|
|
@@ -293,7 +293,7 @@ export function indexFor(b, i, a) {
|
|
|
293
293
|
}
|
|
294
294
|
|
|
295
295
|
function normalizeValue(value, hint) {
|
|
296
|
-
if(typeof
|
|
296
|
+
if (typeof value === "string" && hint.normalizeValue) {
|
|
297
297
|
return value.replace(new RegExp(hint.normalizeValue), "");
|
|
298
298
|
}
|
|
299
299
|
return value;
|
|
@@ -339,15 +339,16 @@ export function sortObjectsByKeys(source, compare) {
|
|
|
339
339
|
return sorted;
|
|
340
340
|
}
|
|
341
341
|
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
342
|
+
/**
|
|
343
|
+
*
|
|
344
|
+
* @param {any} a
|
|
345
|
+
* @param {any} b
|
|
346
|
+
* @param {Array<RegExp|string>} definedOrder
|
|
347
|
+
*/
|
|
347
348
|
export function compareWithDefinedOrder(a, b, definedOrder) {
|
|
348
349
|
/**
|
|
349
|
-
*
|
|
350
|
-
* @param {any} value
|
|
350
|
+
*
|
|
351
|
+
* @param {any} value
|
|
351
352
|
* @returns {number}
|
|
352
353
|
*/
|
|
353
354
|
function matchingIndex(value) {
|
package/types/util.d.mts
CHANGED
|
@@ -50,5 +50,6 @@ export function sortObjectsByKeys(source: any, compare: any): any;
|
|
|
50
50
|
*
|
|
51
51
|
* @param {any} a
|
|
52
52
|
* @param {any} b
|
|
53
|
+
* @param {Array<RegExp|string>} definedOrder
|
|
53
54
|
*/
|
|
54
|
-
export function compareWithDefinedOrder(a: any, b: any, definedOrder:
|
|
55
|
+
export function compareWithDefinedOrder(a: any, b: any, definedOrder: Array<RegExp | string>): number;
|