File size: 317 Bytes
e336208
f24ad59
 
 
 
 
e336208
 
 
 
 
 
 
f24ad59
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
export function parsePrompt(input?: any, throwIfEmpty?: boolean) {
  let res = ""
  try {
    res = decodeURIComponent(`${input || ""}` || "").trim()
  } catch (err) {}

  if (!res.length) {
    if (throwIfEmpty) {
      throw new Error(`please provide a prompt`)
    } else {
      return ""
    }
  }
  return res
}