MCPcopy
hub / github.com/webpack/webpack / parse

Method parse

lib/schemes/HttpUriPlugin.js:249–270  ·  view source on GitHub ↗

* Parses the provided source and updates the parser state. * @param {string} content content of the lockfile * @returns {Lockfile} lockfile

(content)

Source from the content-addressed store, hash-verified

247 * @returns {Lockfile} lockfile
248 */
249 static parse(content) {
250 // TODO handle merge conflicts
251 const data = JSON.parse(content);
252 if (data.version !== 1) {
253 throw new Error(`Unsupported lockfile version ${data.version}`);
254 }
255 const lockfile = new Lockfile();
256 for (const key of Object.keys(data)) {
257 if (key === "version") continue;
258 const entry = data[key];
259 lockfile.entries.set(
260 key,
261 typeof entry === "string"
262 ? entry
263 : {
264 resolved: key,
265 ...entry
266 }
267 );
268 }
269 return lockfile;
270 }
271
272 /**
273 * Returns a string representation.

Callers 2

readLockfileMethod · 0.45
runWriteMethod · 0.45

Calls 2

keysMethod · 0.65
setMethod · 0.45

Tested by

no test coverage detected