mirror of
https://github.com/nodejs/node.git
synced 2025-05-19 16:31:13 +00:00

Simplify a few particularly quirky bits of code, and add whitespace for readability. PR-URL: https://github.com/nodejs/node/pull/25629 Reviewed-By: Denys Otrishko <shishugi@gmail.com> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Gus Caplan <me@gus.host> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Sakthipriyan Vairamani <thechargingvolcano@gmail.com>
38 lines
759 B
JavaScript
38 lines
759 B
JavaScript
'use strict';
|
|
|
|
const {
|
|
ERR_MANIFEST_TDZ,
|
|
} = require('internal/errors').codes;
|
|
const { Manifest } = require('internal/policy/manifest');
|
|
let manifest;
|
|
|
|
module.exports = Object.freeze({
|
|
__proto__: null,
|
|
setup(src, url) {
|
|
if (src === null) {
|
|
manifest = null;
|
|
return;
|
|
}
|
|
|
|
const json = JSON.parse(src, (_, o) => {
|
|
if (o && typeof o === 'object') {
|
|
Reflect.setPrototypeOf(o, null);
|
|
Object.freeze(o);
|
|
}
|
|
return o;
|
|
});
|
|
manifest = new Manifest(json, url);
|
|
},
|
|
|
|
get manifest() {
|
|
if (typeof manifest === 'undefined') {
|
|
throw new ERR_MANIFEST_TDZ();
|
|
}
|
|
return manifest;
|
|
},
|
|
|
|
assertIntegrity(moduleURL, content) {
|
|
this.manifest.matchesIntegrity(moduleURL, content);
|
|
}
|
|
});
|