(code, params, options = kEmptyObject)
| 319 | } |
| 320 | |
| 321 | function compileFunction(code, params, options = kEmptyObject) { |
| 322 | validateString(code, 'code'); |
| 323 | validateObject(options, 'options'); |
| 324 | if (params !== undefined) { |
| 325 | validateStringArray(params, 'params'); |
| 326 | } |
| 327 | const { |
| 328 | filename = '', |
| 329 | columnOffset = 0, |
| 330 | lineOffset = 0, |
| 331 | cachedData = undefined, |
| 332 | produceCachedData = false, |
| 333 | parsingContext = undefined, |
| 334 | contextExtensions = [], |
| 335 | importModuleDynamically, |
| 336 | } = options; |
| 337 | |
| 338 | validateString(filename, 'options.filename'); |
| 339 | validateInt32(columnOffset, 'options.columnOffset'); |
| 340 | validateInt32(lineOffset, 'options.lineOffset'); |
| 341 | if (cachedData !== undefined) |
| 342 | validateBuffer(cachedData, 'options.cachedData'); |
| 343 | validateBoolean(produceCachedData, 'options.produceCachedData'); |
| 344 | if (parsingContext !== undefined) { |
| 345 | if ( |
| 346 | typeof parsingContext !== 'object' || |
| 347 | parsingContext === null || |
| 348 | !isContext(parsingContext) |
| 349 | ) { |
| 350 | throw new ERR_INVALID_ARG_TYPE( |
| 351 | 'options.parsingContext', |
| 352 | 'Context', |
| 353 | parsingContext, |
| 354 | ); |
| 355 | } |
| 356 | } |
| 357 | validateArray(contextExtensions, 'options.contextExtensions'); |
| 358 | ArrayPrototypeForEach(contextExtensions, (extension, i) => { |
| 359 | const name = `options.contextExtensions[${i}]`; |
| 360 | validateObject(extension, name, kValidateObjectAllowNullable); |
| 361 | }); |
| 362 | |
| 363 | const hostDefinedOptionId = |
| 364 | getHostDefinedOptionId(importModuleDynamically, filename); |
| 365 | |
| 366 | return internalCompileFunction( |
| 367 | code, filename, lineOffset, columnOffset, |
| 368 | cachedData, produceCachedData, parsingContext, contextExtensions, |
| 369 | params, hostDefinedOptionId, importModuleDynamically, |
| 370 | ).function; |
| 371 | } |
| 372 | |
| 373 | const measureMemoryModes = { |
| 374 | summary: constants.measureMemory.mode.SUMMARY, |
no test coverage detected
searching dependent graphs…