source: node_modules/yaml/dist/compose/util-contains-newline.js@ d24f17c

main
Last change on this file since d24f17c was d24f17c, checked in by Aleksandar Panovski <apano77@…>, 15 months ago

Initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict';
2
3function containsNewline(key) {
4 if (!key)
5 return null;
6 switch (key.type) {
7 case 'alias':
8 case 'scalar':
9 case 'double-quoted-scalar':
10 case 'single-quoted-scalar':
11 if (key.source.includes('\n'))
12 return true;
13 if (key.end)
14 for (const st of key.end)
15 if (st.type === 'newline')
16 return true;
17 return false;
18 case 'flow-collection':
19 for (const it of key.items) {
20 for (const st of it.start)
21 if (st.type === 'newline')
22 return true;
23 if (it.sep)
24 for (const st of it.sep)
25 if (st.type === 'newline')
26 return true;
27 if (containsNewline(it.key) || containsNewline(it.value))
28 return true;
29 }
30 return false;
31 default:
32 return true;
33 }
34}
35
36exports.containsNewline = containsNewline;
Note: See TracBrowser for help on using the repository browser.