@clerc/utils 0.28.1 → 0.30.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/dist/index.d.ts +3 -3
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as _clerc_core from '@clerc/core';
|
|
2
|
-
import { Command } from '@clerc/core';
|
|
2
|
+
import { Command, I18N } from '@clerc/core';
|
|
3
3
|
|
|
4
4
|
type Equals<X, Y> = (<T>() => T extends X ? 1 : 2) extends (<T>() => T extends Y ? 1 : 2) ? true : false;
|
|
5
5
|
type Dict<T> = Record<string, T>;
|
|
@@ -14,13 +14,13 @@ type Enhance<T, E extends Dict<any> | Dict<any>[]> = GetLength<ToArray<E>> exten
|
|
|
14
14
|
declare const toArray: <T>(a: MaybeArray<T>) => T[];
|
|
15
15
|
type CamelCase<T extends string> = (T extends `${infer Prefix}-${infer Suffix}` | `${infer Prefix} ${infer Suffix}` ? `${Prefix}${Capitalize<CamelCase<Suffix>>}` : T);
|
|
16
16
|
declare const camelCase: <T extends string>(s: T) => CamelCase<T>;
|
|
17
|
-
type KebabCase<T extends string, A extends string = ""> = T extends `${infer
|
|
17
|
+
type KebabCase<T extends string, A extends string = ""> = T extends `${infer Prefix}${infer Suffix}` ? KebabCase<Suffix, `${A}${Prefix extends Lowercase<Prefix> ? "" : "-"}${Lowercase<Prefix>}`> : A;
|
|
18
18
|
declare const kebabCase: <T extends string>(s: T) => KebabCase<T, "">;
|
|
19
19
|
declare const gracefulFlagName: (n: string) => string;
|
|
20
20
|
declare const gracefulVersion: (v: string) => string;
|
|
21
21
|
declare const arrayEquals: <T>(arr1: T[], arr2: T[]) => boolean;
|
|
22
22
|
declare const arrayStartsWith: <T>(arr: T[], start: T[]) => boolean;
|
|
23
23
|
declare const generateCommandRecordFromCommandArray: <C extends Command<string, _clerc_core.CommandOptions<string[], MaybeArray<string | typeof _clerc_core.Root>, _clerc_core.Flags>>>(commands: C[]) => Dict<C>;
|
|
24
|
-
declare const semanticArray: (arr: string[]) => string;
|
|
24
|
+
declare const semanticArray: (arr: string[], { add, t }: I18N) => string;
|
|
25
25
|
|
|
26
26
|
export { CamelCase, Dict, Enhance, Equals, GetLength, GetTail, KebabCase, MaybeArray, ToArray, arrayEquals, arrayStartsWith, camelCase, generateCommandRecordFromCommandArray, gracefulFlagName, gracefulVersion, kebabCase, semanticArray, toArray };
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const a=e=>Array.isArray(e)?e:[e],c=e=>e.replace(/[-_ ](\w)/g,(t
|
|
1
|
+
const a={en:{"utils.and":"%s and %s"},"zh-CN":{"utils.and":"%s \u548C %s"}},l=e=>Array.isArray(e)?e:[e],c=e=>e.replace(/[-_ ](\w)/g,(n,t)=>t.toUpperCase()),s=e=>e.replace(/([A-Z])/g,(n,t)=>`-${t.toLowerCase()}`),g=e=>e.length<=1?`-${e}`:`--${s(e)}`,i=e=>e.length===0?"":e.startsWith("v")?e:`v${e}`,r=(e,n)=>n.length!==e.length?!1:e.every((t,o)=>t===n[o]),u=(e,n)=>n.length>e.length?!1:r(e.slice(0,n.length),n),h=e=>{const n={};for(const t of e)n[t.name]=t;return n},m=(e,{add:n,t})=>(n(a),e.length<=1?e[0]:t("utils.and",e.slice(0,-1).join(", "),e[e.length-1]));export{r as arrayEquals,u as arrayStartsWith,c as camelCase,h as generateCommandRecordFromCommandArray,g as gracefulFlagName,i as gracefulVersion,s as kebabCase,m as semanticArray,l as toArray};
|