MCPcopy
hub / github.com/webpack/webpack / leadingWs

Function leadingWs

lib/html/syntax.js:5143–5152  ·  view source on GitHub ↗
(
		/** @type {CharToken} */ t,
		/** @type {boolean} */ insert
	)

Source from the content-addressed store, hash-verified

5141 // leading whitespace when `insert`, returns the non-whitespace remainder
5142 // token (or null when the token was entirely whitespace).
5143 const leadingWs = (
5144 /** @type {CharToken} */ t,
5145 /** @type {boolean} */ insert
5146 ) => {
5147 const m = /^[\t\n\f\r ]+/.exec(t.data);
5148 const ws = m ? m[0] : "";
5149 if (ws && insert) insertCharacters(ws, t.start, t.start + ws.length);
5150 if (ws.length === t.data.length) return null;
5151 return { ...t, data: t.data.slice(ws.length), start: t.start + ws.length };
5152 };
5153
5154 const isAllWs = (/** @type {string} */ s) => {
5155 for (let i = 0; i < s.length; i++) {

Callers 1

buildHtmlAstFunction · 0.85

Calls 3

insertCharactersFunction · 0.85
execMethod · 0.80
sliceMethod · 0.80

Tested by

no test coverage detected