UNPKG

@mikezimm/fps-core-v7

Version:

Library of reusable core interfaces, types and constants migrated from fps-library-v2

103 lines 4.28 kB
/** * 2024-09-03: Migrated from fps-Pnp2/src/services/sp */ import { BannerHelpTricks, CommonUITricks, FPSFetchTricks, OtherMiscTricks } from "../../banner/components/SingleHelpPage/interfaces/ITrickRow"; import { BeakerModeTricksWHeading } from '../../banner/components/SingleHelpPage/interfaces/ITrickRow'; export function check4This(test, exactCase = false) { // If text does not exist, then return true. if (!test) return true; const compareThis = exactCase === true ? window.location.search : window.location.search.toLowerCase(); const withThis = exactCase === true ? test : test.toLowerCase(); if (compareThis.indexOf(withThis) > -1) { return true; /** * This branch can never execute. Its condition is a duplicate or covered by previous conditions in the if-else-if chain.eslintno-dupe-else-if (method) String.indexOf(searchString: string, position?: number | undefined): number Returns the position of the first occurrence of a substring. @param searchString — The substring to search for in the string @param position — The index at which to begin searching the String object. If omitted, search starts at the beginning of the string. */ // eslint-disable-next-line no-dupe-else-if } else if (test.indexOf(`=false`) > -1 && compareThis.indexOf(withThis) > -1) { // have way to supress this log even if showAllConsole=true below https://github.com/mikezimm/Compliance/issues/178 return false; } else if (compareThis.indexOf(Check4.showAllConsole_Eq_true.toLowerCase()) > -1) { return true; } else { return false; } } export function check4Gulp() { return check4This(Check4.editMode_Eq_true); } // 2025-11-18: Added for easier options in webpart export function check4EditOrThis(test, exactCase = false) { if (check4This(Check4.editMode_Eq_true) === true) return true; if (check4This(test, exactCase) === true) return true; return false; } export function check4GulpOrThis(test, exactCase = false) { if (check4This(Check4.debugMode_Eq_true) === true) return true; if (check4This(test, exactCase) === true) return true; return false; } export function check4EditOrDebug() { if (check4This(Check4.debugMode_Eq_true) === true) return true; if (check4This(Check4.editMode_Eq_true) === true) return true; return false; } export const Check4FPSFetchTricks = convertTricksRowsToCheck4Object(FPSFetchTricks); export const Check4BeakerModeTricks = convertTricksRowsToCheck4Object(BeakerModeTricksWHeading); export const FullPageBGParams = convertTricksRowsToParamArray(BeakerModeTricksWHeading); export const Check4CommonUITricks = convertTricksRowsToCheck4Object(CommonUITricks); export const Check4BannerHelpTricks = convertTricksRowsToCheck4Object(BannerHelpTricks); export const Check4OtherMiscTricks = convertTricksRowsToCheck4Object(OtherMiscTricks); export const Check4 = { ...Check4FPSFetchTricks, ...Check4CommonUITricks, ...Check4BannerHelpTricks, ...Check4BeakerModeTricks, ...Check4OtherMiscTricks, }; /** * Takes the array of Tricks objects and returns a key/value pair of the Check4 like: * { * showFPS_Eq_true: `showFPS=true`, * } * @param trickRow * @returns */ export function convertTricksRowsToCheck4Object(trickRow) { const result = trickRow .filter(item => item.op !== 'heading') // Remove heading rows .reduce((acc, item) => { acc[`${item.param}_Eq_${item.value}`] = `${item.param}=${item.value}`; return acc; }, {}); return result; } /** * Takes the array of Tricks objects and returns an array of params like: [ `showFPS=true` ] * @param trickRow * @returns */ export function convertTricksRowsToParamArray(trickRow) { const result = trickRow .filter(item => item.op !== 'heading') // Remove heading rows .map((item) => { const str = `${item.param}=${item.value}`; return str; }); return result; } //# sourceMappingURL=CheckSearch.js.map