@@ -4,26 +4,59 @@ import type { BunVersion } from "./shared";
44export type { BunVersion } ;
55export { MINIMUM_BUN_VERSION } from "./shared" ;
66
7+ /**
8+ * Checks if the given module name is a native Bun module.
9+ * @param moduleName - The name of the module to check
10+ * @param bunVersion - Optional. The Bun version to check against. Defaults to the current Bun version if available, otherwise "latest".
11+ * @returns `true` if the module is a Bun module, `false` otherwise
12+ */
713export function isBunModule ( moduleName : string , bunVersion ?: BunVersion ) : boolean {
814 return checkModule ( moduleName , bundledBunModules , bunVersion ?? "latest" ) ;
915}
1016
17+ /**
18+ * Checks if the given module name is a Node.js module implemented in Bun.
19+ * @param moduleName - The name of the module to check
20+ * @param bunVersion - Optional. The Bun version to check against. Defaults to the current Bun version if available, otherwise "latest".
21+ * @returns `true` if the module is a Node.js module implemented in Bun, `false` otherwise
22+ */
1123export function isBunImplementedNodeModule ( moduleName : string , bunVersion ?: BunVersion ) : boolean {
1224 return checkModule ( moduleName , implementedNodeModules , bunVersion ?? "latest" ) ;
1325}
1426
27+ /**
28+ * Checks if the given module name is a Bun builtin (either a Bun module or a Node.js module implemented in Bun).
29+ * @param moduleName - The name of the module to check
30+ * @param bunVersion - Optional. The Bun version to check against. Defaults to the current Bun version if available, otherwise "latest".
31+ * @returns `true` if the module is a Bun builtin, `false` otherwise
32+ */
1533export function isBunBuiltin ( moduleName : string , bunVersion ?: BunVersion ) : boolean {
1634 return isBunModule ( moduleName , bunVersion ) || isBunImplementedNodeModule ( moduleName , bunVersion ) ;
1735}
1836
37+ /**
38+ * Gets a list of all native Bun modules.
39+ * @param bunVersion - Optional. The Bun version to check against. Defaults to the current Bun version if available, otherwise "latest".
40+ * @returns An array of module names
41+ */
1942export function getBunModules ( bunVersion ?: BunVersion ) : string [ ] {
2043 return getModules ( bundledBunModules , bunVersion ?? "latest" ) ;
2144}
2245
46+ /**
47+ * Gets a list of all Node.js modules implemented in Bun.
48+ * @param bunVersion - Optional. The Bun version to check against. Defaults to the current Bun version if available, otherwise "latest".
49+ * @returns An array of module names
50+ */
2351export function getBunImplementedNodeModules ( bunVersion ?: BunVersion ) : string [ ] {
2452 return getModules ( implementedNodeModules , bunVersion ?? "latest" ) ;
2553}
2654
55+ /**
56+ * Gets a list of all Bun builtin modules (both Bun modules and Node.js modules implemented in Bun).
57+ * @param bunVersion - Optional. The Bun version to check against. Defaults to the current Bun version if available, otherwise "latest".
58+ * @returns An array of module names
59+ */
2760export function getBunBuiltinModules ( bunVersion ?: BunVersion ) : string [ ] {
2861 return [ ...getBunModules ( bunVersion ) , ...getBunImplementedNodeModules ( bunVersion ) ] ;
2962}
0 commit comments