UNPKG

1.45 kBTypeScriptView Raw
1declare namespace list {
2 type List = {
3 /**
4 * Safely splits comma-separated values (such as those for `transition-*`
5 * and `background` properties).
6 *
7 * ```js
8 * Once (root, { list }) {
9 * list.comma('black, linear-gradient(white, black)')
10 * //=> ['black', 'linear-gradient(white, black)']
11 * }
12 * ```
13 *
14 * @param str Comma-separated values.
15 * @return Split values.
16 */
17 comma(str: string): string[]
18
19 default: List
20
21 /**
22 * Safely splits space-separated values (such as those for `background`,
23 * `border-radius`, and other shorthand properties).
24 *
25 * ```js
26 * Once (root, { list }) {
27 * list.space('1px calc(10% + 1px)') //=> ['1px', 'calc(10% + 1px)']
28 * }
29 * ```
30 *
31 * @param str Space-separated values.
32 * @return Split values.
33 */
34 space(str: string): string[]
35
36 /**
37 * Safely splits values.
38 *
39 * ```js
40 * Once (root, { list }) {
41 * list.split('1px calc(10% + 1px)', [' ', '\n', '\t']) //=> ['1px', 'calc(10% + 1px)']
42 * }
43 * ```
44 *
45 * @param string separated values.
46 * @param separators array of separators.
47 * @param last boolean indicator.
48 * @return Split values.
49 */
50 split(string: string, separators: string[], last: boolean): string[]
51 }
52}
53
54// eslint-disable-next-line @typescript-eslint/no-redeclare
55declare const list: list.List
56
57export = list