Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pixiedevpraveen/utiljs-pro
TypeScript friendly Utility functions for Developers.
https://github.com/pixiedevpraveen/utiljs-pro
bun bun-test deno functions javascript jsr npm utility
Last synced: 10 days ago
JSON representation
TypeScript friendly Utility functions for Developers.
- Host: GitHub
- URL: https://github.com/pixiedevpraveen/utiljs-pro
- Owner: pixiedevpraveen
- License: mit
- Created: 2024-10-26T17:18:45.000Z (11 days ago)
- Default Branch: master
- Last Pushed: 2024-10-26T18:24:30.000Z (11 days ago)
- Last Synced: 2024-10-26T19:20:21.603Z (11 days ago)
- Topics: bun, bun-test, deno, functions, javascript, jsr, npm, utility
- Language: TypeScript
- Homepage: https://praveenyadav.vercel.app/articles/utiljs-pro
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# utiljs-pro
![Package Size](https://deno.bundlejs.com/badge?q=utiljs-pro)
[![JSR](https://jsr.io/badges/@praveen/utiljs-pro)](https://jsr.io/@praveen/utiljs-pro)
[![JSR Score](https://jsr.io/badges/@praveen/utiljs-pro/score)](https://jsr.io/@praveen/utiljs-pro/score)TypeScript friendly Utility functions for Developers.
To install:
```bash
# npm
npm install utiljs-pro# bun
bun add utiljs-pro# yarn
yarn add utiljs-pro# pnpm
pnpm add utiljs-pro# CDN
https://unpkg.com/[email protected]/build/index.js
``````ts
// isPromise
const promise = new Promise(res => setTimeout(() => res(1), 50)) as Promise | numberif (isPromise(obj)) { // true
obj; // hovering on obj shows the type as Promise
const d = await obj; // now hovering on d shows the type as number
} else {
obj; // hovering on obj shows the type as number
}```
```ts
// isAsyncFunction
const asyncFn = (async () => { }) as unknown as (() => Promise) | (() => number)
if (isAsyncFunction Promise>(asyncFn)) { // true
const p = asyncFn(); // hovering on function shows the type as (() => Promise) and on p as Promise
const d = await p; // now hovering on d shows the type as Promise
} else {
const d = asyncFn(); // hovering on function shows the type as (() => number) and on d as number
}
```