@blitz/textmate
Version:
TextMate Grammars for StackBlitz
29 lines (28 loc) • 1.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.isLanguageDefinition = exports.isGrammarDefinition = void 0;
/**
* Check if the provided definition is a `GrammarDefinition`.
*
* @param definition - definition to check for.
*/
const isGrammarDefinition = (definition) => {
var _a, _b;
// A grammar definition doesn't have a language and extensions property, but has a `scopeName` and `grammar` property.
return Boolean((definition === null || definition === void 0 ? void 0 : definition.scopeName) &&
((_a = definition === null || definition === void 0 ? void 0 : definition.grammar) === null || _a === void 0 ? void 0 : _a.base) &&
((_b = definition === null || definition === void 0 ? void 0 : definition.grammar) === null || _b === void 0 ? void 0 : _b.file) &&
!(definition === null || definition === void 0 ? void 0 : definition.language) &&
!(definition === null || definition === void 0 ? void 0 : definition.extensions));
};
exports.isGrammarDefinition = isGrammarDefinition;
/**
* Check if the provided definition is a `LanguageDefinition`.
*
* @param definition - definition to check for.
*/
const isLanguageDefinition = (definition) => {
// A language definition has a language and extensions property.
return Boolean((definition === null || definition === void 0 ? void 0 : definition.language) && (definition === null || definition === void 0 ? void 0 : definition.extensions));
};
exports.isLanguageDefinition = isLanguageDefinition;