Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 6c8a81d

Browse filesBrowse files
deokjinkimRafaelGSS
authored andcommitted
vm: refactor to use validate function
Throwing error after checking type is repeated. So replace it with validate function. PR-URL: #46176 Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 6e7f9fb commit 6c8a81d
Copy full SHA for 6c8a81d

File tree

Expand file treeCollapse file tree

1 file changed

+7
-16
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-16
lines changed
Open diff view settings
Collapse file

‎lib/internal/vm/module.js‎

Copy file name to clipboardExpand all lines: lib/internal/vm/module.js
+7-16Lines changed: 7 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ const {
2020
const { isContext } = internalBinding('contextify');
2121
const {
2222
isModuleNamespaceObject,
23-
isArrayBufferView,
2423
} = require('internal/util/types');
2524
const {
2625
customInspectSymbol,
@@ -40,6 +39,7 @@ const {
4039
} = require('internal/errors').codes;
4140
const {
4241
validateBoolean,
42+
validateBuffer,
4343
validateFunction,
4444
validateInt32,
4545
validateObject,
@@ -275,25 +275,16 @@ class SourceTextModule extends Module {
275275
validateInt32(lineOffset, 'options.lineOffset');
276276
validateInt32(columnOffset, 'options.columnOffset');
277277

278-
if (initializeImportMeta !== undefined &&
279-
typeof initializeImportMeta !== 'function') {
280-
throw new ERR_INVALID_ARG_TYPE(
281-
'options.initializeImportMeta', 'function', initializeImportMeta);
278+
if (initializeImportMeta !== undefined) {
279+
validateFunction(initializeImportMeta, 'options.initializeImportMeta');
282280
}
283281

284-
if (importModuleDynamically !== undefined &&
285-
typeof importModuleDynamically !== 'function') {
286-
throw new ERR_INVALID_ARG_TYPE(
287-
'options.importModuleDynamically', 'function',
288-
importModuleDynamically);
282+
if (importModuleDynamically !== undefined) {
283+
validateFunction(importModuleDynamically, 'options.importModuleDynamically');
289284
}
290285

291-
if (cachedData !== undefined && !isArrayBufferView(cachedData)) {
292-
throw new ERR_INVALID_ARG_TYPE(
293-
'options.cachedData',
294-
['Buffer', 'TypedArray', 'DataView'],
295-
cachedData
296-
);
286+
if (cachedData !== undefined) {
287+
validateBuffer(cachedData, 'options.cachedData');
297288
}
298289

299290
super({

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.