Commit 113f6e8

Ole Bergen <54313166+olebergen@users.noreply.github.com>
2022-06-13 16:50:57
Make options optional (#437)
* Make options optional * Make options optional
v6
1 parent c488737
Changed files (1)
src/question.ts
@@ -14,11 +14,14 @@
 
 import { createInterface } from 'node:readline'
 
-export async function question(query: string, options: { choices: string[] }) {
+export async function question(
+  query: string,
+  { choices }: { choices?: string[] } = {}
+) {
   let completer = undefined
-  if (Array.isArray(options?.choices)) {
+  if (Array.isArray(choices)) {
     completer = function completer(line: string) {
-      const completions = options.choices
+      const completions = choices
       const hits = completions.filter((c) => c.startsWith(line))
       return [hits.length ? hits : completions, line]
     }