-
Notifications
You must be signed in to change notification settings - Fork 107
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
51e12bc
commit a0bca41
Showing
6 changed files
with
93 additions
and
83 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import { KEYS } from './utils'; | ||
|
||
export type InferSetType<T> = T extends Set<infer U> ? U : never; | ||
|
||
/** | ||
* The state of the prompt | ||
*/ | ||
export type ClackState = 'initial' | 'active' | 'cancel' | 'submit' | 'error'; | ||
|
||
/** | ||
* Typed event emitter for clack | ||
*/ | ||
export interface ClackEvents { | ||
initial: (value?: any) => void; | ||
active: (value?: any) => void; | ||
cancel: (value?: any) => void; | ||
submit: (value?: any) => void; | ||
error: (value?: any) => void; | ||
cursor: (key?: InferSetType<typeof KEYS>) => void; | ||
key: (key?: string) => void; | ||
value: (value?: string) => void; | ||
confirm: (value?: boolean) => void; | ||
finalize: () => void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
export function diffLines(a: string, b: string) { | ||
if (a === b) return; | ||
|
||
const aLines = a.split('\n'); | ||
const bLines = b.split('\n'); | ||
const diff: number[] = []; | ||
|
||
for (let i = 0; i < Math.max(aLines.length, bLines.length); i++) { | ||
if (aLines[i] !== bLines[i]) diff.push(i); | ||
} | ||
|
||
return diff; | ||
} |