MCPcopy Index your code
hub / github.com/nodejs/node / setupWebStorage

Function setupWebStorage

lib/internal/process/pre_execution.js:434–463  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

432}
433
434function setupWebStorage() {
435 if (getEmbedderOptions().noBrowserGlobals ||
436 !getOptionValue('--experimental-webstorage')) {
437 return;
438 }
439
440 // https://html.spec.whatwg.org/multipage/webstorage.html#webstorage
441 exposeLazyInterfaces(globalThis, 'internal/webstorage', ['Storage']);
442
443 // localStorage is non-enumerable when --localstorage-file is not provided
444 // to avoid breaking {...globalThis} operations.
445 const localStorageFile = getOptionValue('--localstorage-file');
446 let lazyLocalStorage;
447 ObjectDefineProperty(globalThis, 'localStorage', {
448 __proto__: null,
449 enumerable: localStorageFile !== '',
450 configurable: true,
451 get() {
452 lazyLocalStorage ??= require('internal/webstorage').localStorage;
453 return lazyLocalStorage;
454 },
455 set(value) {
456 lazyLocalStorage = value;
457 },
458 });
459
460 defineReplaceableLazyAttribute(globalThis, 'internal/webstorage', [
461 'sessionStorage',
462 ]);
463}
464
465function setupCodeCoverage() {
466 // Resolve the coverage directory to an absolute path, and

Callers 1

prepareExecutionFunction · 0.85

Calls 4

getEmbedderOptionsFunction · 0.85
getOptionValueFunction · 0.85
exposeLazyInterfacesFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…