1
0
mirror of https://github.com/thangisme/notes.git synced 2024-11-05 15:27:27 -05:00
notes/node_modules/postcss-less/dist/tokenizer/find-end-of-expression.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2017-03-09 13:16:08 -05:00
'use strict';
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = findEndOfExpression;
var _globals = require('./globals');
function findEndOfExpression(css, length, i) {
var openedParenthesisBlocks = 0;
var openedCurlyBlocks = 0;
for (; i < length; ++i) {
var symbolCode = css[i].charCodeAt(0);
// find the on of escaped expression
if (!openedParenthesisBlocks && !openedCurlyBlocks && (symbolCode === _globals.semicolon || symbolCode === _globals.closedCurlyBracket)) {
return i - 1;
}
switch (symbolCode) {
case _globals.openedCurlyBracket:
openedCurlyBlocks++;
break;
case _globals.closedCurlyBracket:
openedCurlyBlocks--;
break;
case _globals.openedParenthesis:
openedParenthesisBlocks++;
break;
case _globals.closedParenthesis:
openedParenthesisBlocks--;
break;
default:
break;
}
}
return -1;
}
module.exports = exports['default'];