Skip to content

Commit

Permalink
chore: build
Browse files Browse the repository at this point in the history
  • Loading branch information
mesqueeb committed Jan 24, 2022
1 parent 4087566 commit 09d0471
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 4 deletions.
13 changes: 11 additions & 2 deletions dist/index.es.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ function getPartsAndIndexes(string, splitRegex) {
result.prefixes.push(prefix);
lastWordEndIndex = match.index + word.length;
}
const tail = string.slice(lastWordEndIndex).trim();
if (tail) {
result.parts.push('');
result.prefixes.push(tail);
}
return result;
}
/**
Expand All @@ -34,7 +39,8 @@ function splitAndPrefix(string, options) {
const hasSpaces = normalString.includes(' ');
const split = hasSpaces ? spaceSplit : magicSplit;
const partsAndIndexes = getPartsAndIndexes(normalString, split);
return partsAndIndexes.parts.map((_part, i) => {
return partsAndIndexes.parts
.map((_part, i) => {
let foundPrefix = partsAndIndexes.prefixes[i] || '';
let part = _part;
if (keepSpecialCharacters === false) {
Expand All @@ -54,6 +60,8 @@ function splitAndPrefix(string, options) {
// console.log(`foundPrefix → `, foundPrefix)
return foundPrefix + part;
}
if (!foundPrefix && !part)
return '';
if (!hasSpaces) {
// return the found prefix OR fall back to a given prefix
return (foundPrefix || prefix) + part;
Expand All @@ -65,7 +73,8 @@ function splitAndPrefix(string, options) {
return ' ' + part;
}
return (foundPrefix || prefix) + part;
});
})
.filter(Boolean);
}
/**
* Capitalises a single word
Expand Down
13 changes: 11 additions & 2 deletions dist/index.umd.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@
result.prefixes.push(prefix);
lastWordEndIndex = match.index + word.length;
}
const tail = string.slice(lastWordEndIndex).trim();
if (tail) {
result.parts.push('');
result.prefixes.push(tail);
}
return result;
}
/**
Expand All @@ -40,7 +45,8 @@
const hasSpaces = normalString.includes(' ');
const split = hasSpaces ? spaceSplit : magicSplit;
const partsAndIndexes = getPartsAndIndexes(normalString, split);
return partsAndIndexes.parts.map((_part, i) => {
return partsAndIndexes.parts
.map((_part, i) => {
let foundPrefix = partsAndIndexes.prefixes[i] || '';
let part = _part;
if (keepSpecialCharacters === false) {
Expand All @@ -60,6 +66,8 @@
// console.log(`foundPrefix → `, foundPrefix)
return foundPrefix + part;
}
if (!foundPrefix && !part)
return '';
if (!hasSpaces) {
// return the found prefix OR fall back to a given prefix
return (foundPrefix || prefix) + part;
Expand All @@ -71,7 +79,8 @@
return ' ' + part;
}
return (foundPrefix || prefix) + part;
});
})
.filter(Boolean);
}
/**
* Capitalises a single word
Expand Down

0 comments on commit 09d0471

Please sign in to comment.