MCPcopy
hub / github.com/webpack/webpack / walk

Function walk

test/walkHtmlTokens.unittest.js:832–869  ·  view source on GitHub ↗
(html)

Source from the content-addressed store, hash-verified

830 * @returns {[string, ...EXPECTED_ANY[]][]} token stream
831 */
832 const walk = (html) => {
833 /** @type {[string, ...EXPECTED_ANY[]][]} */
834 const out = [];
835 walkHtmlTokens(html, 0, {
836 openTag: (input, start, end, ns, ne, selfClosing) => {
837 out.push(["open", input.slice(ns, ne), selfClosing]);
838 return end;
839 },
840 closeTag: (input, start, end, ns, ne) => {
841 out.push(["close", input.slice(ns, ne)]);
842 return end;
843 },
844 attribute: (input, ns, ne, vs, ve, qt) => {
845 out.push([
846 "attr",
847 input.slice(ns, ne),
848 vs === -1 ? null : input.slice(vs, ve),
849 qt
850 ]);
851 if (vs === -1) return ne;
852 if (qt !== QUOTE_NONE) return ve + 1;
853 return ve;
854 },
855 comment: (input, start, end) => {
856 out.push(["comment", input.slice(start, end)]);
857 return end;
858 },
859 doctype: (input, start, end) => {
860 out.push(["doctype", input.slice(start, end)]);
861 return end;
862 },
863 text: (input, start, end) => {
864 out.push(["text", input.slice(start, end)]);
865 return end;
866 }
867 });
868 return out;
869 };
870
871 /**
872 * @param {string} html input

Callers 1

Calls 3

walkHtmlTokensFunction · 0.85
sliceMethod · 0.80
pushMethod · 0.45

Tested by

no test coverage detected