| function resolveEnd(end, offset, reqSpace, onError) { | |
| let comment = ''; | |
| if (end) { | |
| let hasSpace = false; | |
| let sep = ''; | |
| for (const token of end) { | |
| const { source, type } = token; | |
| switch (type) { | |
| case 'space': | |
| hasSpace = true; | |
| break; | |
| case 'comment': { | |
| if (reqSpace && !hasSpace) | |
| onError(token, 'MISSING_CHAR', 'Comments must be separated from other tokens by white space characters'); | |
| const cb = source.substring(1) || ' '; | |
| if (!comment) | |
| comment = cb; | |
| else | |
| comment += sep + cb; | |
| sep = ''; | |
| break; | |
| } | |
| case 'newline': | |
| if (comment) | |
| sep += source; | |
| hasSpace = true; | |
| break; | |
| default: | |
| onError(token, 'UNEXPECTED_TOKEN', `Unexpected ${type} at node end`); | |
| } | |
| offset += source.length; | |
| } | |
| } | |
| return { comment, offset }; | |
| } | |
| export { resolveEnd }; | |
Xet Storage Details
- Size:
- 1.24 kB
- Xet hash:
- eb496d14b17569eaa9c53c6cbe0681d343448a6ab215696a06f59142d809a3e6
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.