is-bun-module
Advanced tools
Comparing version
@@ -5,3 +5,3 @@ { | ||
"description": "Is this specifier a Bun core module or supported Node one?", | ||
"version": "1.3.0", | ||
"version": "2.0.0", | ||
"license": "MIT", | ||
@@ -11,14 +11,8 @@ "files": [ | ||
], | ||
"main": "./dist/cjs/index.js", | ||
"module": "./dist/esm/index.mjs", | ||
"main": "./dist/generic.js", | ||
"exports": { | ||
".": { | ||
"import": { | ||
"types": "./dist/esm/index.d.mts", | ||
"default": "./dist/esm/index.mjs" | ||
}, | ||
"require": { | ||
"types": "./dist/cjs/index.d.ts", | ||
"default": "./dist/cjs/index.js" | ||
} | ||
"bun": "./dist/bun.mjs", | ||
"types": "./dist/generic.d.ts", | ||
"default": "./dist/generic.js" | ||
}, | ||
@@ -28,3 +22,6 @@ "./package.json": "./package.json" | ||
"homepage": "https://github.com/SunsetTechuila/is-bun-module", | ||
"repository": "github:SunsetTechuila/is-bun-module", | ||
"repository": { | ||
"type": "git", | ||
"url": "git+https://github.com/SunsetTechuila/is-bun-module.git" | ||
}, | ||
"bugs": { | ||
@@ -42,33 +39,35 @@ "url": "https://github.com/SunsetTechuila/is-bun-module/issues" | ||
"scripts": { | ||
"build": "bun --bun tsup", | ||
"check-all": "bun --bun concurrently --kill-others=failure 'bun run test' 'bun lint' 'bun type-check' 'bun format:check'", | ||
"build": "bun tsup", | ||
"check-all": "bun concurrently --kill-others=failure 'bun run test' 'bun lint' 'bun type-check' 'bun format:check'", | ||
"precheck-all": "bun run build", | ||
"test": "bun test", | ||
"format": "bun format:base --write", | ||
"format:check": "bun format:base --check", | ||
"format:base": "bun --bun prettier . --cache", | ||
"lint": "bun --bun eslint . --cache", | ||
"type-check": "bun --bun tsc", | ||
"publish": "bun --bun semantic-release" | ||
"format:base": "bun prettier . --cache", | ||
"lint": "bun eslint . --cache", | ||
"type-check": "bun tsc", | ||
"get-bun-blogs": "bun scripts/getBunBlogs.ts", | ||
"publish": "bun semantic-release", | ||
"prepare": "bun husky" | ||
}, | ||
"dependencies": { | ||
"semver": "^7.6.3" | ||
"semver": "^7.7.1" | ||
}, | ||
"devDependencies": { | ||
"@commitlint/cli": "^19.6.0", | ||
"@commitlint/config-conventional": "^19.6.0", | ||
"@eslint/js": "^9.15.0", | ||
"@semantic-release/exec": "^6.0.3", | ||
"@types/bun": "^1.1.14", | ||
"@types/eslint__js": "^8.42.3", | ||
"@commitlint/cli": "^19.8.0", | ||
"@commitlint/config-conventional": "^19.8.0", | ||
"@eslint/js": "^9.22.0", | ||
"@semantic-release/exec": "^7.0.3", | ||
"@types/bun": "^1.2.5", | ||
"@types/semver": "^7.5.8", | ||
"concurrently": "^9.1.0", | ||
"eslint": "^9.15.0", | ||
"eslint-config-prettier": "^9.1.0", | ||
"concurrently": "^9.1.2", | ||
"eslint": "^9.22.0", | ||
"eslint-config-prettier": "^10.1.1", | ||
"husky": "^9.1.7", | ||
"prettier": "^3.4.0", | ||
"semantic-release": "^24.2.0", | ||
"tsup": "^8.3.5", | ||
"typescript": "^5.7.2", | ||
"typescript-eslint": "^8.16.0" | ||
"prettier": "^3.5.3", | ||
"semantic-release": "^24.2.3", | ||
"tsup": "^8.4.0", | ||
"typescript": "~5.8.2", | ||
"typescript-eslint": "^8.26.1" | ||
} | ||
} |
# is-bun-module | ||
## How to use | ||
A utility library to check if a module is a Bun built-in module or a Node.js module implemented in Bun. | ||
To check if a specifier is a [Bun module](https://bun.sh/docs/runtime/bun-apis): | ||
## API | ||
### Module Checking Functions | ||
#### `isBunModule(moduleName, bunVersion?)` | ||
Checks if a specifier is a [Bun module](https://bun.sh/docs/runtime/bun-apis). | ||
```typescript | ||
@@ -14,12 +20,56 @@ import { isBunModule } from "is-bun-module"; | ||
To check if a specifier is a Node module [supported by Bun](https://bun.sh/docs/runtime/nodejs-apis): | ||
#### `isBunImplementedNodeModule(moduleName, bunVersion?)` | ||
Checks if a specifier is a Node module [implemented in 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 | ||
import { isBunImplementedNodeModule } from "is-bun-module"; | ||
isBunImplementedNodeModule("fs"); // true | ||
isBunImplementedNodeModule("node:fs"); // true | ||
isBunImplementedNodeModule("node:notNodeModule"); // false | ||
isBunImplementedNodeModule("node:http2", "1.0.0"); // false, added in 1.0.13 | ||
``` | ||
#### `isBunBuiltin(moduleName, bunVersion?)` | ||
Checks if a specifier is either a Bun module or a Node.js module implemented in Bun. | ||
```typescript | ||
import { isBunBuiltin } from "is-bun-module"; | ||
isBunBuiltin("bun"); // true | ||
isBunBuiltin("fs"); // true | ||
isBunBuiltin("notBunModule"); // false | ||
``` | ||
### Module Listing Functions | ||
#### `getBunModules(bunVersion?)` | ||
Returns an array of all Bun modules available in the specified version. | ||
```typescript | ||
import { getBunModules } from "is-bun-module"; | ||
getBunModules(); // ["bun", "bun:ffi", ...] | ||
getBunModules("1.0.0"); // Returns modules available in version 1.0.0 | ||
``` | ||
#### `getBunImplementedNodeModules(bunVersion?)` | ||
Returns an array of all Node.js modules implemented in Bun for the specified version. | ||
```typescript | ||
import { getBunImplementedNodeModules } from "is-bun-module"; | ||
getBunImplementedNodeModules(); // ["fs", "path", ...] | ||
getBunImplementedNodeModules("1.0.0"); // Returns implemented Node.js modules in version 1.0.0 | ||
``` | ||
#### `getBunBuiltinModules(bunVersion?)` | ||
Returns an array of all builtin modules (both Bun modules and implemented Node.js modules). | ||
```typescript | ||
import { getBunBuiltinModules } from "is-bun-module"; | ||
getBunBuiltinModules(); // ["bun", "bun:ffi", "fs", "path", ...] | ||
``` | ||
## Notes | ||
@@ -26,0 +76,0 @@ |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No repository
Supply chain riskPackage does not have a linked source code repository. Without this field, a package will have no reference to the location of the source code use to generate the package.
Found 1 instance in 1 package
21943
86.69%15
-6.25%8
14.29%494
118.58%80
166.67%0
-100%1
Infinity%Updated