2023-06-11 02:59:33 +00:00
|
|
|
import { customAlphabet, urlAlphabet } from 'nanoid'
|
|
|
|
|
|
|
|
import * as types from './types'
|
|
|
|
|
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))
|
2023-06-11 02:59:33 +00:00
|
|
|
|
|
|
|
export const defaultIDGeneratorFn: types.IDGeneratorFunction =
|
|
|
|
customAlphabet(urlAlphabet)
|