1 | ;
|
2 |
|
3 | const _ = require('lodash');
|
4 |
|
5 | /**
|
6 | * Get the index of a declaration's value
|
7 | *
|
8 | * @param {import('postcss').Declaration} decl
|
9 | *
|
10 | * @returns {number}
|
11 | */
|
12 | module.exports = function (decl) {
|
13 | return [
|
14 | _.get(decl, 'raws.prop.prefix'),
|
15 | _.get(decl, 'raws.prop.raw', decl.prop),
|
16 | _.get(decl, 'raws.prop.suffix'),
|
17 | _.get(decl, 'raws.between', ':'),
|
18 | _.get(decl, 'raws.value.prefix'),
|
19 | ].reduce((count, str) => {
|
20 | if (str) {
|
21 | return count + str.length;
|
22 | }
|
23 |
|
24 | return count;
|
25 | }, 0);
|
26 | };
|