@clerc/utils 1.0.0-beta.2 → 1.0.0-beta.21
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 +4 -1
- package/dist/index.js +3 -1
- package/package.json +1 -5
package/dist/index.d.ts
CHANGED
|
@@ -13,11 +13,13 @@ type IsAny<T> = 0 extends 1 & T ? true : false;
|
|
|
13
13
|
//#region src/types/index.d.ts
|
|
14
14
|
type ToArray<T> = T extends any[] ? T : [T];
|
|
15
15
|
type MaybeArray<T> = T | T[];
|
|
16
|
+
type MaybeGetter<T> = T | (() => T);
|
|
16
17
|
type PartialRequired<T, K$1 extends keyof T> = T & { [P in K$1]-?: T[P] };
|
|
17
18
|
type UnionToIntersection<U> = (U extends any ? (k: U) => void : never) extends ((k: infer I) => void) ? I : never;
|
|
18
19
|
type CamelCase<S extends string> = S extends `${infer Head} ${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S extends `${infer Head}-${infer Tail}` ? `${Head}${Capitalize<CamelCase<Tail>>}` : S;
|
|
19
20
|
//#endregion
|
|
20
21
|
//#region src/index.d.ts
|
|
22
|
+
declare const looseIsArray: <T>(arr: any) => arr is readonly T[];
|
|
21
23
|
declare const toArray: <T>(a: MaybeArray<T>) => T[];
|
|
22
24
|
/**
|
|
23
25
|
* Converts a dash- or space-separated string to camelCase.
|
|
@@ -30,5 +32,6 @@ declare const formatFlagName: (n: string) => string;
|
|
|
30
32
|
declare const formatVersion: (v: string) => string;
|
|
31
33
|
declare const isTruthy: <T>(item: T) => item is Exclude<T, false | null | undefined>;
|
|
32
34
|
declare const objectIsEmpty: (obj: Record<string, any>) => boolean;
|
|
35
|
+
declare const resolveValue: <T>(value: MaybeGetter<T>) => T;
|
|
33
36
|
//#endregion
|
|
34
|
-
export { CamelCase, DeepPrettify, IsAny, LiteralUnion, MaybeArray, PartialRequired, Prettify, ToArray, UnionToIntersection, camelCase, formatFlagName, formatVersion, isTruthy, joinWithAnd, kebabCase, objectIsEmpty, toArray };
|
|
37
|
+
export { CamelCase, DeepPrettify, IsAny, LiteralUnion, MaybeArray, MaybeGetter, PartialRequired, Prettify, ToArray, UnionToIntersection, camelCase, formatFlagName, formatVersion, isTruthy, joinWithAnd, kebabCase, looseIsArray, objectIsEmpty, resolveValue, toArray };
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
//#region src/index.ts
|
|
2
|
+
const looseIsArray = (arr) => Array.isArray(arr);
|
|
2
3
|
const toArray = (a) => Array.isArray(a) ? a : [a];
|
|
3
4
|
/**
|
|
4
5
|
* Converts a dash- or space-separated string to camelCase.
|
|
@@ -31,6 +32,7 @@ const formatFlagName = (n) => n.length <= 1 ? `-${n}` : `--${kebabCase(n)}`;
|
|
|
31
32
|
const formatVersion = (v) => v.length === 0 ? "" : v.startsWith("v") ? v : `v${v}`;
|
|
32
33
|
const isTruthy = Boolean;
|
|
33
34
|
const objectIsEmpty = (obj) => Object.keys(obj).length === 0;
|
|
35
|
+
const resolveValue = (value) => typeof value === "function" ? value() : value;
|
|
34
36
|
|
|
35
37
|
//#endregion
|
|
36
|
-
export { camelCase, formatFlagName, formatVersion, isTruthy, joinWithAnd, kebabCase, objectIsEmpty, toArray };
|
|
38
|
+
export { camelCase, formatFlagName, formatVersion, isTruthy, joinWithAnd, kebabCase, looseIsArray, objectIsEmpty, resolveValue, toArray };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clerc/utils",
|
|
3
|
-
"version": "1.0.0-beta.
|
|
3
|
+
"version": "1.0.0-beta.21",
|
|
4
4
|
"author": "Ray <i@mk1.io> (https://github.com/so1ve)",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Clerc utils",
|
|
@@ -47,9 +47,5 @@
|
|
|
47
47
|
},
|
|
48
48
|
"peerDependencies": {
|
|
49
49
|
"@clerc/core": "*"
|
|
50
|
-
},
|
|
51
|
-
"scripts": {
|
|
52
|
-
"build": "tsdown",
|
|
53
|
-
"watch": "tsdown --watch"
|
|
54
50
|
}
|
|
55
51
|
}
|