Skip to content

Instantly share code, notes, and snippets.

View roger-hamilton's full-sized avatar

Roger M Hamilton roger-hamilton

  • Faros Development LLC
  • Oklahoma City, OK
View GitHub Profile
@roger-hamilton
roger-hamilton / SqlParams.ts
Last active August 11, 2021 13:49
Sql Command parameter extraction
type WhiteSpace = ' ' | '\t' | '\n' | '\r' | '\f'
type Trim<S extends string> =
S extends `${WhiteSpace}${infer T}` ? Trim<T>
: S extends `${infer T}${WhiteSpace}` ? Trim<T>
: S
type SqlParamsUnion<T extends string, P extends string = '@'> =
T extends `${any}${P}${infer P}${WhiteSpace}${infer R}`
? Trim<P> | SqlParamsUnion<R>