1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-01 04:17:33 -04:00
notes/node_modules/postcss-less/dist/find-extend-rule.js
Patrick Marsceill b7b0d0d7bf
Initial commit
2017-03-09 13:16:08 -05:00

37 lines
902 B
JavaScript

'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findExtendRule;
var extendRuleKeyWords = ['&', ':', 'extend'];
var extendRuleKeyWordsCount = extendRuleKeyWords.length;
function findExtendRule(tokens) {
var start = arguments.length <= 1 || arguments[1] === undefined ? 0 : arguments[1];
var stack = [];
var len = tokens.length;
var end = start;
while (end < len) {
var token = tokens[end];
if (extendRuleKeyWords.indexOf(token[1]) >= 0) {
stack.push(token[1]);
} else if (token[0] !== 'space') {
break;
}
end++;
}
for (var index = 0; index < extendRuleKeyWordsCount; index++) {
if (stack[index] !== extendRuleKeyWords[index]) {
return null;
}
}
return tokens.slice(start, end);
}
module.exports = exports['default'];