stash-connector
Version:
Module to handle and work with Atlassian Stash projects and repositories throug REST API. Admin your repositories and projects in Stash easy. This project is not an Atlassian official project but use the Atlassian Stash REST API
64 lines • 2.54 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.StrUtils = void 0;
var StrUtils = /** @class */ (function () {
function StrUtils() {
}
/**
* Method to replace data from a string
* @param {string} str String to replace the data
* @param {string} replace String to replace
* @param {string} replacement String to replacement
*
* @returns {string} Returns the the String with data replaced
*/
StrUtils.replace = function (str, replace, replacement) {
return str.split(replace).join(replacement);
};
/**
* Method to count the ocurrences into the String
* @param {string} str Source to check
* @param {string} strToCheck String to check if exists on str
*
* @returns {number} true if "strToCheck" exists on "str", false in otherwise
*/
StrUtils.count = function (str, strToCheck) {
return (str.match(new RegExp(strToCheck, 'g')) || []).length;
};
/**
* Method to check if a String contains other String
* @param {string} str Source to check
* @param {string} strToCheck String to check if exists on str
*
* @returns {boolean} true if "strToCheck" exists on "str", false in otherwise
*/
StrUtils.contains = function (str, strToCheck) {
return str.indexOf(strToCheck) !== -1;
};
/**
* Method to check if a String contains other String ignoring letter case
* @param {string} str Source to check
* @param {string} strToCheck String to check if exists on str
*
* @returns {boolean} true if "strToCheck" exists on "str", false in otherwise
*/
StrUtils.containsIgnorecase = function (str, strToCheck) {
return str.toLowerCase().indexOf(strToCheck.toLowerCase()) !== -1;
};
StrUtils.normalize = function (value, toUpper) {
if (!value) {
return '';
}
var normalized = value.toLowerCase();
normalized = normalized.replace(/[é]/g, 'e');
normalized = normalized.replace(/[ú]/g, 'u');
normalized = normalized.replace(/[í]/g, 'i');
normalized = normalized.replace(/[á]/g, 'a');
normalized = normalized.replace(/[ó]/g, 'o');
normalized = normalized.replace(/[^a-zA-Z0-9\s]/g, '').trim();
return toUpper ? normalized.toUpperCase() : normalized;
};
return StrUtils;
}());
exports.StrUtils = StrUtils;
//# sourceMappingURL=strUtils.js.map