@clerc/parser 1.0.0-beta.1 → 1.0.0-beta.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/dist/index.d.ts +5 -1
- package/dist/index.js +6 -6
- package/package.json +2 -2
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ declare class InvalidSchemaError extends Error {
|
|
|
5
5
|
//#endregion
|
|
6
6
|
//#region ../utils/src/types/type-fest.d.ts
|
|
7
7
|
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
8
|
+
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
8
9
|
//#endregion
|
|
9
10
|
//#region ../utils/src/types/index.d.ts
|
|
10
11
|
type MaybeArray<T> = T | T[];
|
|
@@ -103,7 +104,10 @@ interface ParsedResult<TFlags extends Record<string, any>> {
|
|
|
103
104
|
type InferFlagDefault<T extends FlagDefinitionValue, Fallback> = T extends {
|
|
104
105
|
default: FlagDefaultValue<infer DefaultType>;
|
|
105
106
|
} ? DefaultType : Fallback;
|
|
106
|
-
type
|
|
107
|
+
type IsTypeAny<T extends FlagDefinitionValue> = IsAny<T> extends true ? true : T extends {
|
|
108
|
+
type: infer Type;
|
|
109
|
+
} ? IsAny<Type> extends true ? true : false : false;
|
|
110
|
+
type _InferFlags<T extends FlagsDefinition> = { [K in keyof T]: IsTypeAny<T[K]> extends true ? any : T[K] extends readonly [BooleanConstructor] | {
|
|
107
111
|
type: readonly [BooleanConstructor];
|
|
108
112
|
} ? number : T[K] extends ObjectConstructor | {
|
|
109
113
|
type: ObjectConstructor;
|
package/dist/index.js
CHANGED
|
@@ -59,14 +59,14 @@ function iterateArgs(args, result, shouldProcessAsFlag, isKnownFlag, ignore, cal
|
|
|
59
59
|
//#region ../utils/dist/index.js
|
|
60
60
|
const toArray = (a) => Array.isArray(a) ? a : [a];
|
|
61
61
|
/**
|
|
62
|
-
* Converts a dash-separated string to camelCase.
|
|
62
|
+
* Converts a dash- or space-separated string to camelCase.
|
|
63
63
|
* Not using regexp for better performance, because this function is used in parser.
|
|
64
64
|
*/
|
|
65
65
|
function camelCase(str) {
|
|
66
|
-
const
|
|
67
|
-
if (
|
|
68
|
-
let result = str.slice(0,
|
|
69
|
-
for (let i =
|
|
66
|
+
const firstIdx = Math.min(str.includes("-") ? str.indexOf("-") : Infinity, str.includes(" ") ? str.indexOf(" ") : Infinity);
|
|
67
|
+
if (firstIdx === Infinity) return str;
|
|
68
|
+
let result = str.slice(0, firstIdx);
|
|
69
|
+
for (let i = firstIdx; i < str.length; i++) if ((str[i] === "-" || str[i] === " ") && i + 1 < str.length) {
|
|
70
70
|
const nextChar = str.charCodeAt(i + 1);
|
|
71
71
|
if (nextChar >= 97 && nextChar <= 122) {
|
|
72
72
|
result += String.fromCharCode(nextChar - 32);
|
|
@@ -75,7 +75,7 @@ function camelCase(str) {
|
|
|
75
75
|
result += str[i + 1];
|
|
76
76
|
i++;
|
|
77
77
|
}
|
|
78
|
-
} else if (str[i] !== "-") result += str[i];
|
|
78
|
+
} else if (str[i] !== "-" && str[i] !== " ") result += str[i];
|
|
79
79
|
return result;
|
|
80
80
|
}
|
|
81
81
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/parser",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.2",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc parser",
|
|
@@ -55,7 +55,7 @@
|
|
|
55
55
|
"nopt": "^9.0.0",
|
|
56
56
|
"type-flag": "^4.0.3",
|
|
57
57
|
"yargs-parser": "^22.0.0",
|
|
58
|
-
"@clerc/utils": "1.0.0-beta.
|
|
58
|
+
"@clerc/utils": "1.0.0-beta.2"
|
|
59
59
|
},
|
|
60
60
|
"scripts": {
|
|
61
61
|
"build": "tsdown",
|