MCPcopy
hub / github.com/webpack/webpack / consumeAFunction

Function consumeAFunction

lib/css/syntax.js:2797–2826  ·  view source on GitHub ↗
(ts)

Source from the content-addressed store, hash-verified

2795 * @returns {FunctionNode | undefined} the consumed function node
2796 */
2797const consumeAFunction = (ts) => {
2798 const { input } = ts;
2799 // Assert (spec): the next token is a <function-token>.
2800 // Consume a token from input, and let function be a new function with its name equal the returned token’s value, and a value set to an empty list.
2801 const tFn = ts.consume();
2802 const fn = /** @type {FunctionNode} */ (
2803 _mkContainer(T_FUNCTION, tFn.start, tFn.end)
2804 );
2805 _setName(fn, input.slice(tFn.start, tFn.end - 1), tFn.start, tFn.end - 1);
2806 const val = _list();
2807 _setValue(fn, val);
2808
2809 // Process input
2810 for (;;) {
2811 const t = ts.next();
2812
2813 if (t.type === TT_EOF || t.type === TT_RIGHT_PARENTHESIS) {
2814 // <eof-token>
2815 // <)-token>
2816 // Discard a token from input. Return function.
2817 ts.discard();
2818 _setEnd(fn, t.end);
2819 return fn;
2820 }
2821
2822 // anything else
2823 // Consume a component value from input and append the result to function’s value.
2824 val.push(consumeAComponentValue(ts, t));
2825 }
2826};
2827
2828// Identifier escape / unescape — operate on the raw text of an
2829// `<ident-token>` (or any source slice that may carry CSS escape sequences).

Callers 1

consumeAComponentValueFunction · 0.85

Calls 7

_listFunction · 0.85
consumeAComponentValueFunction · 0.85
consumeMethod · 0.80
sliceMethod · 0.80
discardMethod · 0.80
nextMethod · 0.45
pushMethod · 0.45

Tested by

no test coverage detected