@airtasker/form-schema-compiler
Version:
a form schema compiler
29 lines (22 loc) • 1.1 kB
JavaScript
;
exports.__esModule = true;
exports.isKeyword = exports.isOperator = exports.isPunctuation = undefined;
var _const = require("../const");
var returnTokenWhen = function returnTokenWhen(token, type, propKey, propValue) {
if (token && token.type === type && (!propKey || !propValue || token[propKey] === propValue)) {
return token;
}
return null;
};
var isPunctuation = exports.isPunctuation = function isPunctuation(token) {
var paren = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
return returnTokenWhen(token, _const.TYPES.Punctuation, "value", paren);
};
var isOperator = exports.isOperator = function isOperator(token) {
var operator = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
return returnTokenWhen(token, _const.TYPES.Operator, "value", operator);
};
var isKeyword = exports.isKeyword = function isKeyword(token) {
var keyword = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined;
return returnTokenWhen(token, _const.TYPES.Keyword, "value", keyword);
};