stylelint-use-nesting
Version:
Enforce nesting when it is possible in CSS
14 lines (12 loc) • 336 B
JavaScript
export default function is(value, ...keys) {
const length = keys.length;
const matches = keys.pop();
const subvalue = keys.reduce((result, key) => Object(result)[key], value);
return length
? [].concat(matches).some(
match => match instanceof RegExp
? match.test(subvalue)
: match === subvalue
)
: Boolean(value);
}