Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 | 3x 7x 7x 7x 35x 14x 21x 3x | const validateTypes = require("./validateTypes");
/**
* Get the index of a declaration's value
*
* @param {import('postcss').Declaration} decl
* @returns {number}
*/
function declarationValueIndex(decl) {
const raws = decl.raws;
const prop = raws.prop;
return [
validateTypes.isObject(prop) && "prefix" in prop && prop.prefix,
(validateTypes.isObject(prop) && "raw" in prop && prop.raw) || decl.prop,
validateTypes.isObject(prop) && "suffix" in prop && prop.suffix,
raws.between || ":",
raws.value && "prefix" in raws.value && raws.value.prefix
].reduce((/** @type {number} */ count, str) => {
if (validateTypes.isString(str)) {
return count + str.length;
}
return count;
}, 0);
}
module.exports = declarationValueIndex;
|