Source: utils/is.js

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.Is = void 0;
const base_1 = require("./base");
const keywords_1 = __importDefault(require("./keywords"));
/**
 * Detects keywords
 */
class Is extends base_1.Base {
    /**
     * Detects `import`
     * @param lineItem Comma separated line item in string
     * @returns `true` if found
     */
    isImport = (lineItem) => lineItem.includes(keywords_1.default.importKey);
    /**
     * Checks single line comment
     * @param lineItem Comma separated line item in string
     * @returns `true` if found
     */
    isSingleLineComment(lineItem) {
        var splittedLines = lineItem.split("\r\n");
        for (let i = 0; i < splittedLines.length; i++)
            if (splittedLines[i].trim().startsWith(keywords_1.default.singleLineComment))
                return true;
        return false;
    }
    /**
     * @deprecated Out of scope in `v1.0.0`
     * @param lineItem Comma separated line item in string
     * @returns `true` if found
     */
    isMultiLineCommentStart(lineItem) {
        if (lineItem.includes(keywords_1.default.multiLineCommentStart))
            return true;
        return false;
    }
    /**
     * @deprecated Out of scope in `v1.0.0`
     * @param lineItem Comma separated line item in string
     * @returns `true` if found
     */
    isMultiLineCommentEnd(lineItem) {
        if (lineItem.includes(keywords_1.default.multiLineCommentEnd))
            return true;
        return false;
    }
    /**
     * Checks whether load contains relative JPaths
     * @param lineItem Comma separated line item in string
     * @returns `true` if found
     */
    isRelativeJPath(lineItem) {
        let splitByColon = lineItem.split(":");
        let relativeJPathKeys = [];
        for (let i = 0; i < splitByColon.length; i++) {
            if (splitByColon[i].trim().startsWith(keywords_1.default.relativeJPath))
                relativeJPathKeys.push(splitByColon[i].trim());
        }
        if (relativeJPathKeys.length === 0)
            return {
                Result: false,
                Keys: relativeJPathKeys
            };
        else
            return {
                Result: true,
                Keys: relativeJPathKeys
            };
    }
    isRuntimeKeysPresent(content) {
        let runtimeValsList = content.match(keywords_1.default.decodedRuntimeKeys);
        if (runtimeValsList !== undefined) {
            this.decodedRuntimeKeyList = runtimeValsList?.filter((value, index, array) => { return array.indexOf(value) === index; });
            return true;
        }
        else
            return false;
    }
}
exports.Is = Is;