Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
stringHelpers.tokenizeWithPunctuation(_verseObject.text).map( text => {
let verseObject;
if (stringHelpers.word.test(text)) { // if the text has word characters, its a word object
const wordIndex = verseObjects.length - nonWordVerseObjectCount;
let occurrence = stringHelpers.occurrenceInString(_verseObjectsWithTextString, wordIndex, text);
const occurrences = stringHelpers.occurrencesInString(_verseObjectsWithTextString, text);
if (occurrence > occurrences) occurrence = occurrences;
verseObject = {
tag: "w",
type: "word",
text,
occurrence,
occurrences
};
} else { // the text does not have word characters
nonWordVerseObjectCount ++;
verseObject = {
type: "text",
text: text
};
}