var tokenizerUtils = require('../tokenizer/utils'); var findIdentifierEnd = tokenizerUtils.findIdentifierEnd; var findNumberEnd = tokenizerUtils.findNumberEnd; var findDecimalNumberEnd = tokenizerUtils.findDecimalNumberEnd; var isHex = tokenizerUtils.isHex; var tokenizerConst = require('../tokenizer/const'); var SYMBOL_TYPE = tokenizerConst.SYMBOL_TYPE; var IDENTIFIER = tokenizerConst.TYPE.Identifier; var PLUSSIGN = tokenizerConst.TYPE.PlusSign; var HYPHENMINUS = tokenizerConst.TYPE.HyphenMinus; var NUMBERSIGN = tokenizerConst.TYPE.NumberSign; var PERCENTAGE = { '%': true }; // https://www.w3.org/TR/css-values-3/#lengths var LENGTH = { // absolute length units 'px': true, 'mm': true, 'cm': true, 'in': true, 'pt': true, 'pc': true, 'q': true, // relative length units 'em': true, 'ex': true, 'ch': true, 'rem': true, // viewport-percentage lengths 'vh': true, 'vw': true, 'vmin': true, 'vmax': true, 'vm': true }; var ANGLE = { 'deg': true, 'grad': true, 'rad': true, 'turn': true }; var TIME = { 's': true, 'ms': true }; var FREQUENCY = { 'hz': true, 'khz': true }; // https://www.w3.org/TR/css-values-3/#resolution (https://drafts.csswg.org/css-values/#resolution) var RESOLUTION = { 'dpi': true, 'dpcm': true, 'dppx': true, 'x': true // https://github.com/w3c/csswg-drafts/issues/461 }; // https://drafts.csswg.org/css-grid/#fr-unit var FLEX = { 'fr': true }; // https://www.w3.org/TR/css3-speech/#mixing-props-voice-volume var DECIBEL = { 'db': true }; // https://www.w3.org/TR/css3-speech/#voice-props-voice-pitch var SEMITONES = { 'st': true }; function consumeFunction(token, addTokenToMatch, getNextToken) { var length = 1; var cursor; do { cursor = getNextToken(length++); } while (cursor !== null && cursor.node !== token.node); if (cursor === null) { return false; } while (true) { // consume tokens until cursor if (addTokenToMatch() === cursor) { break; } } return true; } // TODO: implement // can be used wherever , , ,