@sorrell/cli-utilities 1.0.26 → 1.0.27
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.
|
@@ -31,10 +31,12 @@ export declare function Format(Message: string, Rules: FormatRules): string;
|
|
|
31
31
|
* Creates a function that formats a given `string` with the given {@link Rules}.
|
|
32
32
|
*
|
|
33
33
|
* @param Rules - The {@link FormatRules} used to format messages passed to the
|
|
34
|
-
* returned function.
|
|
34
|
+
* returned function. If multiple are given, then the keys will be pooled. If
|
|
35
|
+
* multiple {@link Rules} share a given key, then the respective formatter functions
|
|
36
|
+
* will be composed in the order of the given {@link Rules} objects.
|
|
35
37
|
*
|
|
36
38
|
* @returns A function that will format the `Message` passed to it according to the
|
|
37
39
|
* {@link Rules} passed to this function.
|
|
38
40
|
*/
|
|
39
|
-
export declare function MakeFormatter(Rules: FormatRules): Formatter;
|
|
41
|
+
export declare function MakeFormatter(...Rules: [FormatRules] | Array<FormatRules>): Formatter;
|
|
40
42
|
//# sourceMappingURL=Print.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Print.d.ts","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAiB/D;;;;;;GAMG;AACH,wBAAgB,IAAI,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,CAG5C;AAED;;;;;;;;GAQG;AACH,wBAAgB,IAAI,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAGzC;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAClB,OAAO,EAAE,MAAM,EACf,KAAK,EAAE,WAAW,GACnB,MAAM,CAYR;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,aAAa,CAAC,GAAG,KAAK,EAAE,CAAE,WAAW,CAAE,GAAG,KAAK,CAAC,WAAW,CAAC,GAAG,SAAS,CAsCvF"}
|
|
@@ -60,14 +60,36 @@ export function Format(Message, Rules) {
|
|
|
60
60
|
* Creates a function that formats a given `string` with the given {@link Rules}.
|
|
61
61
|
*
|
|
62
62
|
* @param Rules - The {@link FormatRules} used to format messages passed to the
|
|
63
|
-
* returned function.
|
|
63
|
+
* returned function. If multiple are given, then the keys will be pooled. If
|
|
64
|
+
* multiple {@link Rules} share a given key, then the respective formatter functions
|
|
65
|
+
* will be composed in the order of the given {@link Rules} objects.
|
|
64
66
|
*
|
|
65
67
|
* @returns A function that will format the `Message` passed to it according to the
|
|
66
68
|
* {@link Rules} passed to this function.
|
|
67
69
|
*/
|
|
68
|
-
export function MakeFormatter(Rules) {
|
|
70
|
+
export function MakeFormatter(...Rules) {
|
|
71
|
+
/* eslint-disable-next-line jsdoc/require-jsdoc */
|
|
72
|
+
function ComposeRules() {
|
|
73
|
+
if (Rules.length === 1) {
|
|
74
|
+
return Rules[0];
|
|
75
|
+
}
|
|
76
|
+
return Rules.reduce((PreviousValue, CurrentValue) => {
|
|
77
|
+
const NewValue = { ...PreviousValue };
|
|
78
|
+
Object.keys(CurrentValue).forEach((Key) => {
|
|
79
|
+
if (Key in NewValue && PreviousValue[Key] !== undefined && CurrentValue[Key] !== undefined) {
|
|
80
|
+
const OriginalFunction = PreviousValue[Key];
|
|
81
|
+
const CurrentFunction = CurrentValue[Key];
|
|
82
|
+
NewValue[Key] = function (Message) {
|
|
83
|
+
return CurrentFunction(OriginalFunction(Message));
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
});
|
|
87
|
+
return NewValue;
|
|
88
|
+
}, {});
|
|
89
|
+
}
|
|
90
|
+
const OutRules = ComposeRules();
|
|
69
91
|
return function (Message) {
|
|
70
|
-
return Format(Message,
|
|
92
|
+
return Format(Message, OutRules);
|
|
71
93
|
};
|
|
72
94
|
}
|
|
73
95
|
//# sourceMappingURL=Print.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Print.js","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;
|
|
1
|
+
{"version":3,"file":"Print.js","sourceRoot":"","sources":["../../Source/Print/Print.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAGH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD;;;;;;GAMG;AACH,SAAS,UAAU,CAAC,OAAe;IAE/B,OAAO,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;AAChC,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAAC,OAAe;IAEhC,OAAO,UAAU,CAAC,KAAK,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC;AAC1C,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,IAAI,CAAC,IAAY;IAE7B,OAAO,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC;AACjC,CAAC;AAED;;;;;;;;GAQG;AACH,MAAM,UAAU,MAAM,CAClB,OAAe,EACf,KAAkB;IAGlB,OAAO,GAAG,UAAU,CAAC,OAAO,CAAC,CAAC;IAE9B,MAAM,WAAW,GAAsB,gBAAgB,CAAC,KAAK,CAAC,CAAC;IAE/D,KAAK,MAAM,CAAE,KAAK,EAAE,SAAS,CAAE,IAAI,WAAW,EAC9C,CAAC;QACG,OAAO,GAAG,OAAO,CAAC,UAAU,CAAC,KAAK,EAAE,SAAS,CAAC,CAAC;IACnD,CAAC;IAED,OAAO,OAAO,CAAC;AACnB,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,aAAa,CAAC,GAAG,KAA2C;IAExE,kDAAkD;IAClD,SAAS,YAAY;QAEjB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,EACtB,CAAC;YACG,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