MCPcopy
hub / github.com/css/csso / readChunk

Function readChunk

lib/compress.js:7–44  ·  view source on GitHub ↗
(input, specialComments)

Source from the content-addressed store, hash-verified

5import restructure from './restructure/index.js';
6
7function readChunk(input, specialComments) {
8 const children = new List();
9 let nonSpaceTokenInBuffer = false;
10 let protectedComment;
11
12 input.nextUntil(input.head, (node, item, list) => {
13 if (node.type === 'Comment') {
14 if (!specialComments || node.value.charAt(0) !== '!') {
15 list.remove(item);
16 return;
17 }
18
19 if (nonSpaceTokenInBuffer || protectedComment) {
20 return true;
21 }
22
23 list.remove(item);
24 protectedComment = node;
25
26 return;
27 }
28
29 if (node.type !== 'WhiteSpace') {
30 nonSpaceTokenInBuffer = true;
31 }
32
33 children.insert(list.remove(item));
34 });
35
36 return {
37 comment: protectedComment,
38 stylesheet: {
39 type: 'StyleSheet',
40 loc: null,
41 children
42 }
43 };
44}
45
46function compressChunk(ast, firstAtrulesAllowed, num, options) {
47 options.logger(`Compress block #${num}`, null, true);

Callers 1

compressFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…