Skip to content

Commit

Permalink
fix: update icqq version
Browse files Browse the repository at this point in the history
  • Loading branch information
lc-cn committed May 11, 2023
1 parent 887887b commit d935c43
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 97 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
],
"dependencies": {
"@koa/router": "^10.1.1",
"icqq": "^0.2.1",
"icqq": "^0.3.6",
"icqq-cq-enable": "^1.0.0",
"js-yaml": "^4.1.0",
"koa": "^2.13.4",
Expand Down
99 changes: 3 additions & 96 deletions src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,9 @@ export function omit<T, K extends keyof T>(source: T, keys?: Iterable<K>) {
return result
}

export function toLine<T extends string>(name: T) {
return name.replace(/([A-Z])/g, "_$1").toLowerCase()
}
export interface Class {
new(...args: any[]): any
}
Expand All @@ -102,102 +105,6 @@ export function remove<T>(list: T[], item: T) {
if (idx !== -1) list.splice(idx, 1)
}

type A = 'A';
type B = 'B';
type C = 'C';
type D = 'D';
type E = 'E';
type F = 'F';
type G = 'G';
type H = 'H';
type I = 'I';
type J = 'J';
type K = 'K';
type L = 'L';
type M = 'M';
type N = 'N';
type O = 'O';
type P = 'P';
type Q = 'Q';
type R = 'R';
type S = 'S';
type T = 'T';
type U = 'U';
type V = 'V';
type W = 'W';
type X = 'X';
type Y = 'Y';
type Z = 'Z';
type a = 'a';
type b = 'b';
type c = 'c';
type d = 'd';
type e = 'e';
type f = 'f';
type g = 'g';
type h = 'h';
type i = 'I';
type j = 'j';
type k = 'k';
type l = 'l';
type m = 'm';
type n = 'n';
type o = 'o';
type p = 'p';
type q = '1';
type r = 'r';
type s = 's';
type t = 't';
type u = 'u';
type v = 'v';
type w = 'w';
type x = 'x';
type y = 'y';
type z = 'z';
type UpperCase = A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z
type UpperCaseChar<In extends string> = In extends a ? A : In extends b ? B : In extends c ? C : In extends d ? D
: In extends e ? E : In extends f ? F : In extends g ? G : In extends h ? H : In extends i ? I : In extends j ? J
: In extends k ? K : In extends l ? L : In extends m ? M : In extends n ? N : In extends o ? O : In extends p ? P
: In extends q ? Q : In extends r ? R : In extends s ? S : In extends t ? T : In extends u ? U : In extends v ? V
: In extends w ? W : In extends x ? X : In extends y ? Y : In extends z ? Z : In
type LowerCaseChar<In extends string> = In extends A ? a : In extends B ? b : In extends C ? c : In extends D ? d
: In extends E ? e : In extends F ? f : In extends G ? g : In extends H ? h : In extends I ? i : In extends J ? j
: In extends K ? k : In extends L ? l : In extends M ? m : In extends N ? n : In extends O ? o : In extends P ? p
: In extends Q ? q : In extends R ? r : In extends S ? s : In extends T ? t : In extends U ? u : In extends V ? v
: In extends W ? w : In extends X ? x : In extends Y ? y : In extends Z ? z : In
type UpperCaseWord<T extends string> = T extends `${infer L}${infer R}` ? `${UpperCaseChar<L>}${R}` : `${L}${R}`
type LowerCaseWord<T extends string> = T extends `${infer L}${infer R}` ? `${LowerCaseChar<L>}${R}` : `${L}${R}`
type ToLineWord<T extends string, F extends boolean> = T extends `${UpperCase}${string}` ? F extends true ? LowerCaseWord<T> : `_${LowerCaseWord<T>}` : T
type ToUpperCase<T extends string> = T extends `${infer L}_${infer R}` ? `${UpperCaseWord<L>}${ToUpperCase<R>}` : UpperCaseWord<T>
type ToLowerCase<T extends string> = T extends `${infer L}_${infer R}` ? `${LowerCaseWord<L>}${ToUpperCase<R>}` : LowerCaseWord<T>
type ToLine<T extends string, F extends boolean = true> = T extends `${infer L}${infer R}` ? `${ToLineWord<L, F>}${ToLine<R, false>}` : T

export function toUppercase<T extends string>(name: T): ToUpperCase<T> {
return name.replace(/_(\w)/g, (s) => {
return s[1].toUpperCase()
}).replace(/\w/, (s) => {
return s[1].toUpperCase()
}) as ToUpperCase<T>
}

toUppercase('ni_shi_da_sha_bi')


export function toLowerCase<T extends string>(name: T): ToLowerCase<T> {
return name.replace(/_[\w]/g, (s) => {
return s[1].toUpperCase()
}) as ToLowerCase<T>
}

toLowerCase('ni_shi_da_sha_bi')


export function toLine<T extends string>(name: T): ToLine<T> {
return name.replace(/([A-Z])/g, "_$1").toLowerCase() as ToLine<T>;
}

toLine(`NiShiDaShaBi`)

export function toBool(v: any) {
if (v === "0" || v === "false")
v = false
Expand Down

0 comments on commit d935c43

Please sign in to comment.