fix: re-built code.

This commit is contained in:
Spencer Brower
2023-06-15 13:43:40 -04:00
parent 559217ac60
commit f46b68c709
8 changed files with 41 additions and 35 deletions

View File

@@ -14,8 +14,9 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.beforeFirstWord = exports.beforeFirst = exports.afterLast = exports.afterFirst = exports.endsWith = exports.startsWith = void 0;
exports.removeFirstWord = exports.afterFirstWord = exports.beforeFirstWord = exports.beforeFirst = exports.afterLast = exports.afterFirst = exports.endsWith = exports.startsWith = void 0;
const utils_1 = require("./utils");
__exportStar(require("./shorten"), exports);
__exportStar(require("./trim"), exports);
function escapeRegExp(str) {
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
@@ -24,35 +25,14 @@ exports.startsWith = (0, utils_1.curry)((needle, haystack) => haystack.indexOf(n
exports.endsWith = (0, utils_1.curry)((needle, haystack) => new RegExp(`${escapeRegExp(needle)}$`).test(haystack));
exports.afterFirst = (0, utils_1.curry)((separator, str) => str.substring(str.indexOf(separator) + 1, str.length));
exports.afterLast = (0, utils_1.curry)((separator, str) => str.substring(str.lastIndexOf(separator) + 1, str.length));
exports.beforeFirst = (0, utils_1.curry)((separator, str) => str.substring(0, str.indexOf(separator)));
exports.beforeFirst = (0, utils_1.curry)((separator, str) => {
const index = str.indexOf(separator);
return index === -1
? str
: str.substring(0, index);
});
// @todo Test
exports.beforeFirstWord = (0, exports.beforeFirst)(" ");
// /**
// * @param {String} str
// * @return {String}
// */
// export function afterFirstWord(str) {
// return afterFirst(' ', str);
// }
// export const removeFirstWord = afterFirstWord;
// /**
// * @param {Number} maxChars
// * @param {String} str
// * @return {Boolean} False if str is longer than maxChars characters.
// */
// const shorterThan = curry((maxChars, str) => str.length <= maxChars);
// /**
// * @param {Number} maxChars The maximum length of the desired output string.
// * @param strategy a function that accepts a string and returns a shorter string.
// * @return {String} The input string, shortened to maxChars by strategy.
// */
// const shortenString = (maxChars, strategy) => until(shorterThan(maxChars), strategy);
// /**
// * @param {Number} maxChars
// * @param {String} str The string to remove words from.
// * @return {String} the shortened string.
// */
// export const removeWordsFromStartOfString = uncurryN(
// 2,
// (maxChars) => shortenString(maxChars, removeFirstWord),
// );
// @todo Test
exports.afterFirstWord = (0, exports.afterFirst)(" ");
exports.removeFirstWord = exports.afterFirstWord;