File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -5,7 +5,7 @@ import { styleText } from "node:util";
55
66// Import Internal Dependencies
77import { AbstractPrompt , type AbstractPromptOptions } from "./abstract.ts" ;
8- import { stringLength , withResolvers } from "../utils.ts" ;
8+ import { stringLength } from "../utils.ts" ;
99import { SYMBOLS } from "../constants.ts" ;
1010
1111export interface ConfirmOptions extends AbstractPromptOptions {
@@ -128,7 +128,7 @@ export class ConfirmPrompt extends AbstractPrompt<boolean> {
128128 this . write ( SYMBOLS . HideCursor ) ;
129129
130130 try {
131- const { resolve, promise } = withResolvers < boolean > ( ) ;
131+ const { resolve, promise } = Promise . withResolvers < boolean > ( ) ;
132132 const questionQuery = this . #getQuestionQuery( ) ;
133133
134134 this . write ( questionQuery ) ;
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { styleText } from "node:util";
44
55// Import Internal Dependencies
66import { AbstractPrompt , type AbstractPromptOptions } from "./abstract.ts" ;
7- import { stringLength , withResolvers } from "../utils.ts" ;
7+ import { stringLength } from "../utils.ts" ;
88import { SYMBOLS } from "../constants.ts" ;
99import { isValid , type PromptValidator , resultError } from "../validators.ts" ;
1010import { type Choice } from "../types.ts" ;
@@ -370,7 +370,7 @@ export class MultiselectPrompt<T extends string> extends AbstractPrompt<T> {
370370
371371 render ( { initialRender : true } ) ;
372372
373- const { promise, resolve } = withResolvers < T [ ] > ( ) ;
373+ const { promise, resolve } = Promise . withResolvers < T [ ] > ( ) ;
374374 this . #boundKeyPressEvent = this . #onKeypress. bind ( this , resolve , render ) ;
375375 this . stdin . on ( "keypress" , this . #boundKeyPressEvent) ;
376376
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { styleText } from "node:util";
44
55// Import Internal Dependencies
66import { AbstractPrompt , type AbstractPromptOptions } from "./abstract.ts" ;
7- import { stringLength , withResolvers } from "../utils.ts" ;
7+ import { stringLength } from "../utils.ts" ;
88import { SYMBOLS } from "../constants.ts" ;
99import { isValid , type PromptValidator , resultError } from "../validators.ts" ;
1010
@@ -55,7 +55,7 @@ export class QuestionPrompt extends AbstractPrompt<string> {
5555 }
5656
5757 #question( ) : Promise < string > {
58- const { resolve, promise } = withResolvers < string > ( ) ;
58+ const { resolve, promise } = Promise . withResolvers < string > ( ) ;
5959
6060 const questionQuery = this . #getQuestionQuery( ) ;
6161
Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ import { styleText } from "node:util";
44
55// Import Internal Dependencies
66import { AbstractPrompt , type AbstractPromptOptions } from "./abstract.ts" ;
7- import { stringLength , withResolvers } from "../utils.ts" ;
7+ import { stringLength } from "../utils.ts" ;
88import { SYMBOLS } from "../constants.ts" ;
99import { isValid , type PromptValidator , resultError } from "../validators.ts" ;
1010import { type Choice } from "../types.ts" ;
@@ -310,7 +310,7 @@ export class SelectPrompt<T extends string> extends AbstractPrompt<T> {
310310
311311 render ( { initialRender : true } ) ;
312312
313- const { resolve, promise } = withResolvers < T > ( ) ;
313+ const { resolve, promise } = Promise . withResolvers < T > ( ) ;
314314 this . #boundKeyPressEvent = this . #onKeypress. bind ( this , resolve , render ) ;
315315 this . stdin . on ( "keypress" , this . #boundKeyPressEvent) ;
316316
Original file line number Diff line number Diff line change @@ -44,13 +44,3 @@ export function stringLength(
4444 return length ;
4545}
4646
47- export function withResolvers < T > ( ) {
48- let resolve ! : ( value : T | PromiseLike < T > ) => void ;
49- let reject ! : ( reason ?: unknown ) => void ;
50- const promise = new Promise < T > ( ( res , rej ) => {
51- resolve = res ;
52- reject = rej ;
53- } ) ;
54-
55- return { promise, resolve, reject } ;
56- }
You can’t perform that action at this time.
0 commit comments