source: trip-planner-front/node_modules/postcss/lib/list.js

Last change on this file was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 1.1 KB
Line 
1'use strict'
2
3let list = {
4 split(string, separators, last) {
5 let array = []
6 let current = ''
7 let split = false
8
9 let func = 0
10 let quote = false
11 let escape = false
12
13 for (let letter of string) {
14 if (escape) {
15 escape = false
16 } else if (letter === '\\') {
17 escape = true
18 } else if (quote) {
19 if (letter === quote) {
20 quote = false
21 }
22 } else if (letter === '"' || letter === "'") {
23 quote = letter
24 } else if (letter === '(') {
25 func += 1
26 } else if (letter === ')') {
27 if (func > 0) func -= 1
28 } else if (func === 0) {
29 if (separators.includes(letter)) split = true
30 }
31
32 if (split) {
33 if (current !== '') array.push(current.trim())
34 current = ''
35 split = false
36 } else {
37 current += letter
38 }
39 }
40
41 if (last || current !== '') array.push(current.trim())
42 return array
43 },
44
45 space(string) {
46 let spaces = [' ', '\n', '\t']
47 return list.split(string, spaces)
48 },
49
50 comma(string) {
51 return list.split(string, [','], true)
52 }
53}
54
55module.exports = list
56list.default = list
Note: See TracBrowser for help on using the repository browser.