1 |
|
2 | import { list } from 'postcss';
|
3 |
|
4 |
|
5 | export default function getArrayedString(string, useSingleValue) {
|
6 |
|
7 | const stringArray = getCommaSplitString(string).map(
|
8 | substring => matchWrappingParens.test(substring) ? getArrayedString(getStringWithoutWrappingParentheses(substring), false) : substring
|
9 | );
|
10 |
|
11 |
|
12 | const returnValue = useSingleValue && 1 === stringArray.length ? stringArray[0] : stringArray;
|
13 |
|
14 | return returnValue;
|
15 | }
|
16 |
|
17 |
|
18 | const getCommaSplitString = string => list.comma(string);
|
19 |
|
20 |
|
21 | const getStringWithoutWrappingParentheses = string => string.replace(matchWrappingParens, '$1');
|
22 |
|
23 |
|
24 | const matchWrappingParens = /^\((.*)\)$/g;
|