@clerc/parser 1.0.1 → 1.0.3
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 +2 -5
- package/dist/index.js +2 -25
- package/package.json +5 -3
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,10 @@
|
|
|
1
|
+
import { IsAny, Prettify, RequireExactlyOneOrNone } from "@clerc/utils";
|
|
2
|
+
|
|
1
3
|
//#region src/errors.d.ts
|
|
2
4
|
declare class InvalidSchemaError extends Error {
|
|
3
5
|
constructor(message: string);
|
|
4
6
|
}
|
|
5
7
|
//#endregion
|
|
6
|
-
//#region ../utils/src/types/type-fest.d.ts
|
|
7
|
-
type Prettify<T> = { [K in keyof T]: T[K] } & {};
|
|
8
|
-
type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
9
|
-
type RequireExactlyOneOrNone<T, Keys extends keyof T = keyof T> = ({ [K in Keys]-?: Required<Pick<T, K>> & Partial<Record<Exclude<Keys, K>, never>> }[Keys] & Omit<T, Keys>) | (Partial<Record<Keys, never>> & Omit<T, Keys>);
|
|
10
|
-
//#endregion
|
|
11
8
|
//#region src/types.d.ts
|
|
12
9
|
interface FlagDefaultValueFunction<T> {
|
|
13
10
|
(): T;
|
package/dist/index.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { camelCase, looseIsArray, resolveValue } from "@clerc/utils";
|
|
2
|
+
|
|
1
3
|
//#region src/errors.ts
|
|
2
4
|
var InvalidSchemaError = class extends Error {
|
|
3
5
|
constructor(message) {
|
|
@@ -55,31 +57,6 @@ function iterateArgs(args, result, shouldProcessAsFlag, isKnownFlag, ignore, cal
|
|
|
55
57
|
}
|
|
56
58
|
}
|
|
57
59
|
|
|
58
|
-
//#endregion
|
|
59
|
-
//#region ../utils/src/index.ts
|
|
60
|
-
const looseIsArray = (arr) => Array.isArray(arr);
|
|
61
|
-
/**
|
|
62
|
-
* Converts a dash- or space-separated string to camelCase.
|
|
63
|
-
* Not using regexp for better performance, because this function is used in parser.
|
|
64
|
-
*/
|
|
65
|
-
function camelCase(str) {
|
|
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
|
-
const nextChar = str.charCodeAt(i + 1);
|
|
71
|
-
if (nextChar >= 97 && nextChar <= 122) {
|
|
72
|
-
result += String.fromCharCode(nextChar - 32);
|
|
73
|
-
i++;
|
|
74
|
-
} else {
|
|
75
|
-
result += str[i + 1];
|
|
76
|
-
i++;
|
|
77
|
-
}
|
|
78
|
-
} else if (str[i] !== "-" && str[i] !== " ") result += str[i];
|
|
79
|
-
return result;
|
|
80
|
-
}
|
|
81
|
-
const resolveValue = (value) => typeof value === "function" ? value() : value;
|
|
82
|
-
|
|
83
60
|
//#endregion
|
|
84
61
|
//#region src/config.ts
|
|
85
62
|
const defaultParserOptions = { delimiters: ["=", ":"] };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/parser",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.3",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc parser",
|
|
@@ -46,6 +46,9 @@
|
|
|
46
46
|
"publishConfig": {
|
|
47
47
|
"access": "public"
|
|
48
48
|
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@clerc/utils": "1.0.3"
|
|
51
|
+
},
|
|
49
52
|
"devDependencies": {
|
|
50
53
|
"@types/minimist": "^1.2.5",
|
|
51
54
|
"@types/nopt": "^3.0.32",
|
|
@@ -55,7 +58,6 @@
|
|
|
55
58
|
"mri": "^1.2.0",
|
|
56
59
|
"nopt": "^9.0.0",
|
|
57
60
|
"type-flag": "^4.0.3",
|
|
58
|
-
"yargs-parser": "^22.0.0"
|
|
59
|
-
"@clerc/utils": "1.0.1"
|
|
61
|
+
"yargs-parser": "^22.0.0"
|
|
60
62
|
}
|
|
61
63
|
}
|