MCPcopy
hub / github.com/webpack/webpack / getParser

Method getParser

lib/NormalModuleFactory.js:1421–1437  ·  view source on GitHub ↗

* Returns parser. * @template {string} T * @param {T} type type * @param {ParserOptions} parserOptions parser options * @returns {ParserByType[T]} parser

(type, parserOptions = EMPTY_PARSER_OPTIONS)

Source from the content-addressed store, hash-verified

1419 * @returns {ParserByType[T]} parser
1420 */
1421 getParser(type, parserOptions = EMPTY_PARSER_OPTIONS) {
1422 let cache = this.parserCache.get(type);
1423
1424 if (cache === undefined) {
1425 cache = new WeakMap();
1426 this.parserCache.set(type, cache);
1427 }
1428
1429 let parser = cache.get(parserOptions);
1430
1431 if (parser === undefined) {
1432 parser = this.createParser(type, parserOptions);
1433 cache.set(parserOptions, parser);
1434 }
1435
1436 return /** @type {ParserByType[T]} */ (parser);
1437 }
1438
1439 /**
1440 * Creates a parser from the provided type.

Callers 2

constructorMethod · 0.95

Calls 3

createParserMethod · 0.95
getMethod · 0.45
setMethod · 0.45

Tested by

no test coverage detected