mirror of
https://github.com/mermaid-js/mermaid.git
synced 2024-08-28 21:16:07 +02:00
Add utilty function to check for substring in array
This commit is contained in:
parent
7f0d4fff1b
commit
957244583c
1 changed files with 17 additions and 0 deletions
17
src/utils.js
17
src/utils.js
|
@ -139,3 +139,20 @@ var cloneCssStyles = function(svg, classes){
|
|||
};
|
||||
|
||||
exports.cloneCssStyles = cloneCssStyles;
|
||||
|
||||
|
||||
/**
|
||||
* @function isSubstringInArray
|
||||
* Detects whether a substring in present in a given array
|
||||
* @param {string} str The substring to detect
|
||||
* @param {array} arr The array to search
|
||||
* @returns {number} the array index containing the substring or -1 if not present
|
||||
**/
|
||||
var isSubstringInArray = function (str, arr) {
|
||||
for (var i = 0; i < arr.length; i++) {
|
||||
if (arr[i].match(str)) return i;
|
||||
}
|
||||
return -1;
|
||||
};
|
||||
|
||||
exports.isSubstringInArray = isSubstringInArray;
|
Loading…
Reference in a new issue