chatgpt-api/src/utils.ts

9 wiersze
322 B
TypeScript
Czysty Zwykły widok Historia

2023-05-24 06:15:59 +00:00
export const extractJSONObjectFromString = (text: string): string | undefined =>
text.match(/\{(.|\n)*\}/gm)?.[0]
export const extractJSONArrayFromString = (text: string): string | undefined =>
text.match(/\[(.|\n)*\]/gm)?.[0]
2023-06-07 01:03:39 +00:00
export const sleep = (ms: number) =>
new Promise((resolve) => setTimeout(resolve, ms))