GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — vm: refactor to use validate function · nodejs/node@6c8a81d

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options
  • lib/internal/vm
    • module.js
Expand file treeCollapse file tree
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)
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.