Skip to content

Commit 47a1925

Browse files
committed
feat(builtins): builtinModules
Signed-off-by: Lexus Drumgold <[email protected]>
1 parent 723fdb4 commit 47a1925

File tree

7 files changed

+114
-32
lines changed

7 files changed

+114
-32
lines changed

__tests__/setup/chai.ts

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,7 @@
55
*/
66

77
import chai from 'chai'
8-
import chaiEach from 'chai-each'
9-
import chaiQuantifiers from 'chai-quantifiers'
108

119
// configure chai
1210
chai.config.includeStack = true
1311
chai.config.truncateThreshold = 0
14-
15-
/**
16-
* initialize chai plugins.
17-
*
18-
* @see https://github.com/jamesthomasonjr/chai-each
19-
* @see https://github.com/funny-bytes/chai-quantifiers
20-
*/
21-
chai.use(chaiEach)
22-
chai.use(chaiQuantifiers)

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,8 +98,6 @@
9898
"@vitest/ui": "0.28.3",
9999
"add-stream": "1.0.0",
100100
"chai": "4.3.7",
101-
"chai-each": "0.0.1",
102-
"chai-quantifiers": "1.0.17",
103101
"conventional-changelog": "3.1.25",
104102
"conventional-changelog-core": "4.2.4",
105103
"conventional-changelog-writer": "5.0.1",
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
/**
2+
* @file Type Tests - builtinModules
3+
* @module builtin-modules/tests/unit-d/builtinModules
4+
*/
5+
6+
import type testSubject from '../builtin-modules'
7+
8+
describe('unit-d:builtinModules', () => {
9+
it('should equal type of string[]', () => {
10+
expectTypeOf<typeof testSubject>().toEqualTypeOf<string[]>()
11+
})
12+
})
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/**
2+
* @file Unit Tests - builtinModules
3+
* @module builtin-modules/tests/unit/builtinModules
4+
*/
5+
6+
import module from 'node:module'
7+
import testSubject from '../builtin-modules'
8+
9+
describe('unit:builtinModules', () => {
10+
it('should be superset of module.builtinModules', () => {
11+
expect(testSubject).to.include.members(module.builtinModules)
12+
})
13+
})

src/builtin-modules.ts

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
/**
2+
* @file builtinModules
3+
* @module builtin-modules/builtinModules
4+
*/
5+
6+
/**
7+
* Names of modules provided by Node.js.
8+
*
9+
* Possible use cases:
10+
*
11+
* - Check if a module can be imported using the [`node:`][1] protocol
12+
* - Check if a module is maintained by Node.js
13+
*
14+
* [1]: https://nodejs.org/api/esm.html#node-imports
15+
*
16+
* @const {string[]} builtinModules
17+
*/
18+
const builtinModules: string[] = [
19+
'_http_agent',
20+
'_http_client',
21+
'_http_common',
22+
'_http_incoming',
23+
'_http_outgoing',
24+
'_http_server',
25+
'_stream_duplex',
26+
'_stream_passthrough',
27+
'_stream_readable',
28+
'_stream_transform',
29+
'_stream_wrap',
30+
'_stream_writable',
31+
'_tls_common',
32+
'_tls_wrap',
33+
'assert',
34+
'assert/strict',
35+
'async_hooks',
36+
'buffer',
37+
'child_process',
38+
'cluster',
39+
'console',
40+
'constants',
41+
'crypto',
42+
'dgram',
43+
'diagnostics_channel',
44+
'dns',
45+
'dns/promises',
46+
'domain',
47+
'events',
48+
'fs',
49+
'fs/promises',
50+
'http',
51+
'http2',
52+
'https',
53+
'inspector',
54+
'inspector/promises',
55+
'module',
56+
'net',
57+
'os',
58+
'path',
59+
'path/posix',
60+
'path/win32',
61+
'perf_hooks',
62+
'process',
63+
'punycode',
64+
'querystring',
65+
'readline',
66+
'readline/promises',
67+
'repl',
68+
'stream',
69+
'stream/consumers',
70+
'stream/promises',
71+
'stream/web',
72+
'string_decoder',
73+
'sys',
74+
'timers',
75+
'timers/promises',
76+
'tls',
77+
'trace_events',
78+
'tty',
79+
'url',
80+
'util',
81+
'util/types',
82+
'v8',
83+
'vm',
84+
'worker_threads',
85+
'zlib'
86+
]
87+
88+
export default builtinModules

src/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
* @module builtin-modules
44
*/
55

6-
export {}
6+
export { default as builtinModules } from './builtin-modules'

yarn.lock

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1169,8 +1169,6 @@ __metadata:
11691169
"@vitest/ui": "npm:0.28.3"
11701170
add-stream: "npm:1.0.0"
11711171
chai: "npm:4.3.7"
1172-
chai-each: "npm:0.0.1"
1173-
chai-quantifiers: "npm:1.0.17"
11741172
conventional-changelog: "npm:3.1.25"
11751173
conventional-changelog-core: "npm:4.2.4"
11761174
conventional-changelog-writer: "npm:5.0.1"
@@ -2928,22 +2926,6 @@ __metadata:
29282926
languageName: node
29292927
linkType: hard
29302928

2931-
"chai-each@npm:0.0.1":
2932-
version: 0.0.1
2933-
resolution: "chai-each@npm:0.0.1"
2934-
checksum: 545be493fb9eace3aea28ef9556a0433dd1467bd0bf96d1bb50212c0f12b833ae033fd50b56b6ca739a58868fab060ef794bca14da3b36347f4f8574d66fc2a8
2935-
languageName: node
2936-
linkType: hard
2937-
2938-
"chai-quantifiers@npm:1.0.17":
2939-
version: 1.0.17
2940-
resolution: "chai-quantifiers@npm:1.0.17"
2941-
peerDependencies:
2942-
chai: ^4.x.x
2943-
checksum: 9e1c4af526998af9a862917c426ac0ff48560f1ab03ff97ef67ed65b88b2dad0d2af8a2f9315a55fbc434d77b1f82ecf5aa16b15453fa33dcad7f4a5266cb3ca
2944-
languageName: node
2945-
linkType: hard
2946-
29472929
"chai@npm:4.3.7, chai@npm:^4.3.7":
29482930
version: 4.3.7
29492931
resolution: "chai@npm:4.3.7"

0 commit comments

Comments
 (0)