1.0.1 • Published 10 months ago

utiljs-pro v1.0.1

Weekly downloads
-
License
MIT
Repository
-
Last release
10 months ago

utiljs-pro

Package Size

To install:

# npm
npm install utiljs-pro

# bun
bun add utiljs-pro

# yarn
yarn add utiljs-pro

# pnpm
pnpm add utiljs-pro
// isPromise
const promise = new Promise(res => setTimeout(() => res(1), 50)) as Promise<number> | number

if (isPromise(obj)) { // true
    obj; // hovering on obj shows the type as Promise<number>
    const d = await obj; // now hovering on d shows the type as number
} else {
    obj; // hovering on obj shows the type as number
}
// isAsyncFunction
const asyncFn = (async () => { }) as unknown as (() => Promise<number>) | (() => number)
if (isAsyncFunction<number, () => Promise<number>>(asyncFn)) { // true
    const p = asyncFn(); // hovering on function shows the type as (() => Promise<number>) and on p as Promise<number>
    const d = await p; // now hovering on d shows the type as Promise<number>
} else {
    const d = asyncFn(); // hovering on function shows the type as (() => number) and on d as number
}
1.0.1

10 months ago

1.0.0

10 months ago

0.2.6

10 months ago

0.2.5

11 months ago

0.2.2

12 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.1.6

12 months ago

0.1.5

12 months ago

0.1.1

12 months ago