Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/sunsettechuila/is-bun-module
Is this specifier a Bun core module or supported Node one?
https://github.com/sunsettechuila/is-bun-module
bun bun-js bunjs javascript module node nodejs typescript
Last synced: about 2 months ago
JSON representation
Is this specifier a Bun core module or supported Node one?
- Host: GitHub
- URL: https://github.com/sunsettechuila/is-bun-module
- Owner: SunsetTechuila
- License: mit
- Created: 2024-05-28T19:18:08.000Z (7 months ago)
- Default Branch: master
- Last Pushed: 2024-09-08T17:12:38.000Z (4 months ago)
- Last Synced: 2024-11-07T10:02:35.413Z (about 2 months ago)
- Topics: bun, bun-js, bunjs, javascript, module, node, nodejs, typescript
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/is-bun-module
- Size: 281 KB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# is-bun-module
## How to use
To check if a specifier is a [Bun module](https://bun.sh/docs/runtime/bun-apis):
```typescript
import { isBunModule } from "is-bun-module";
isBunModule("bun"); // true
isBunModule("bun:test", "1.0.0"); // true
isBunModule("notBunModule"); // false
```To check if a specifier is a Node module [supported by Bun](https://bun.sh/docs/runtime/nodejs-apis):
```typescript
import { isSupportedNodeModule } from "is-bun-module";
isSupportedNodeModule("fs"); // true
isSupportedNodeModule("node:fs"); // true
isSupportedNodeModule("node:notNodeModule"); // false
isSupportedNodeModule("node:http2", "1.0.0"); // false, added in 1.0.13
```## Notes
- **Only Bun v1.0.0+ is supported**
- You can also pass `latest` as Bun version
- Inspired by [is-core-module](https://github.com/inspect-js/is-core-module) and made for [eslint-import-resolver-typescript](https://github.com/import-js/eslint-import-resolver-typescript)
- Runtime-independent