Files
discordeno/packages/utils/src/utils.ts
Fleny 919474069d chore: Migrate ESLint and prettier to Biome (#3634)
* Migrate eslint and prettier to biomejs

This does NOT include examples/bigbot as it has its own formatter

* Update to biome 1.8.0

* Readd dotenv dev dependency to rest

During a merge it got lost
2024-07-13 13:05:02 -05:00

17 lines
629 B
TypeScript

/** Pause the execution for a given amount of milliseconds. */
export async function delay(ms: number): Promise<void> {
return new Promise(
(resolve): NodeJS.Timeout =>
setTimeout((): void => {
resolve()
}, ms),
)
}
// Typescript is not so good as we developers so we need this little utility function to help it out
// Taken from https://fettblog.eu/typescript-hasownproperty/
/** TS save way to check if a property exists in an object */
export function hasProperty<T extends {}, Y extends PropertyKey = string>(obj: T, prop: Y): obj is T & Record<Y, unknown> {
return obj.hasOwnProperty(prop)
}