@clerc/utils 0.39.0 → 0.40.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 CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _clerc_core from '@clerc/core';
2
- import { Command, I18N, Commands, CommandType, TranslateFn, RootType, Root } from '@clerc/core';
2
+ import { I18N, Commands, CommandType, TranslateFn, Command, RootType, Root } 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>;
@@ -17,10 +17,9 @@ declare const gracefulFlagName: (n: string) => string;
17
17
  declare const gracefulVersion: (v: string) => string;
18
18
  declare const arrayEquals: <T>(arr1: T[], arr2: T[]) => boolean;
19
19
  declare const arrayStartsWith: <T>(arr: T[], start: T[]) => boolean;
20
- declare const generateCommandsFromCommandArray: <C extends Command>(commands: C[]) => Dict<C>;
21
20
  declare const semanticArray: (arr: string[], { add, t }: I18N) => string;
22
21
  declare function resolveCommandStrict(commands: Commands, name: CommandType | string[], t: TranslateFn): [Command<string | RootType> | undefined, string[] | RootType | undefined];
23
22
  declare function resolveSubcommandsByParent(commands: Commands, parent: string | string[], depth?: number): Command<string, _clerc_core.CommandOptions<string[], MaybeArray<string | typeof Root>, _clerc_core.Flags>>[];
24
23
  declare const resolveRootCommands: (commands: Commands) => Command<string, _clerc_core.CommandOptions<string[], MaybeArray<string | typeof Root>, _clerc_core.Flags>>[];
25
24
 
26
- export { CamelCase, Dict, Equals, KebabCase, MaybeArray, ToArray, arrayEquals, arrayStartsWith, camelCase, generateCommandsFromCommandArray, gracefulFlagName, gracefulVersion, kebabCase, resolveCommandStrict, resolveRootCommands, resolveSubcommandsByParent, semanticArray, toArray };
25
+ export { CamelCase, Dict, Equals, KebabCase, MaybeArray, ToArray, arrayEquals, arrayStartsWith, camelCase, gracefulFlagName, gracefulVersion, kebabCase, resolveCommandStrict, resolveRootCommands, resolveSubcommandsByParent, semanticArray, toArray };
package/dist/index.js CHANGED
@@ -1 +1 @@
1
- import{Root as s,resolveFlattenCommands as d}from"@clerc/core";const y={en:{"utils.and":"%s and %s"},"zh-CN":{"utils.and":"%s \u548C %s"}},m=e=>Array.isArray(e)?e:[e],A=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),u=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),C=e=>e.length<=1?`-${e}`:`--${u(e)}`,p=e=>e.length===0?"":e.startsWith("v")?e:`v${e}`,i=(e,t)=>t.length!==e.length?!1:e.every((n,r)=>n===t[r]),f=(e,t)=>t.length>e.length?!1:i(e.slice(0,t.length),t),v=e=>{const t={};for(const n of e)t[n.name]=n;return t},b=(e,{add:t,t:n})=>(t(y),e.length<=1?e[0]:n("utils.and",e.slice(0,-1).join(", "),e[e.length-1]));function N(e,t,n){if(t===s)return[e[s],s];const r=m(t),a=d(e,n);let o,l;return a.forEach((h,c)=>{c===s||l===s||i(r,c)&&(o=h,l=c)}),[o,l]}function g(e,t,n=1/0){const r=t===""?[]:Array.isArray(t)?t:t.split(" ");return Object.values(e).filter(a=>{const o=a.name.split(" ");return f(o,r)&&o.length-r.length<=n})}const $=e=>g(e,"",1);export{i as arrayEquals,f as arrayStartsWith,A as camelCase,v as generateCommandsFromCommandArray,C as gracefulFlagName,p as gracefulVersion,u as kebabCase,N as resolveCommandStrict,$ as resolveRootCommands,g as resolveSubcommandsByParent,b as semanticArray,m as toArray};
1
+ import{Root as o,resolveFlattenCommands as y}from"@clerc/core";const d={en:{"utils.and":"%s and %s"},"zh-CN":{"utils.and":"%s \u548C %s"}},u=e=>Array.isArray(e)?e:[e],A=e=>e.replace(/[\W_]([a-z\d])?/gi,(t,n)=>n?n.toUpperCase():""),m=e=>e.replace(/([A-Z])/g,(t,n)=>`-${n.toLowerCase()}`),C=e=>e.length<=1?`-${e}`:`--${m(e)}`,p=e=>e.length===0?"":e.startsWith("v")?e:`v${e}`,i=(e,t)=>t.length!==e.length?!1:e.every((n,r)=>n===t[r]),f=(e,t)=>t.length>e.length?!1:i(e.slice(0,t.length),t),v=(e,{add:t,t:n})=>(t(d),e.length<=1?e[0]:n("utils.and",e.slice(0,-1).join(", "),e[e.length-1]));function b(e,t,n){if(t===o)return[e[o],o];const r=u(t),l=y(e,n);let s,a;return l.forEach((h,c)=>{c===o||a===o||i(r,c)&&(s=h,a=c)}),[s,a]}function g(e,t,n=1/0){const r=t===""?[]:Array.isArray(t)?t:t.split(" ");return Object.values(e).filter(l=>{const s=l.name.split(" ");return f(s,r)&&s.length-r.length<=n})}const N=e=>g(e,"",1);export{i as arrayEquals,f as arrayStartsWith,A as camelCase,C as gracefulFlagName,p as gracefulVersion,m as kebabCase,b as resolveCommandStrict,N as resolveRootCommands,g as resolveSubcommandsByParent,v as semanticArray,u as toArray};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clerc/utils",
3
- "version": "0.39.0",
3
+ "version": "0.40.0",
4
4
  "author": "Ray <i@mk1.io> (https://github.com/so1ve)",
5
5
  "description": "Clerc utils",
6
6
  "keywords": [