mirror of
https://github.com/sbrow/strings.git
synced 2025-12-29 23:17:39 -05:00
style: Ran prettier.
This commit is contained in:
19
lib/index.js
19
lib/index.js
@@ -14,26 +14,19 @@ 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.afterLast = exports.afterFirst = exports.endsWith = exports.startsWith = void 0;
|
||||
exports.beforeFirstWord = exports.beforeFirst = exports.afterLast = exports.afterFirst = exports.endsWith = exports.startsWith = void 0;
|
||||
const utils_1 = require("./utils");
|
||||
__exportStar(require("./trim"), exports);
|
||||
function escapeRegExp(str) {
|
||||
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); // $& means the whole matched string
|
||||
return str.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
||||
}
|
||||
exports.startsWith = (0, utils_1.curry)((needle, haystack) => haystack.indexOf(needle) === 0);
|
||||
exports.endsWith = (0, utils_1.curry)((needle, haystack) => (new RegExp(`${escapeRegExp(needle)}$`)).test(haystack));
|
||||
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));
|
||||
// export const beforeFirst = curry(
|
||||
// /**
|
||||
// *
|
||||
// * @param {String} separator
|
||||
// * @param {String} str
|
||||
// * @returns {String}
|
||||
// */
|
||||
// (separator, str) => str.substring(0, str.indexOf(separator)),
|
||||
// );
|
||||
// export const beforeFirstWord = beforeFirst(' ');
|
||||
exports.beforeFirst = (0, utils_1.curry)((separator, str) => str.substring(0, str.indexOf(separator)));
|
||||
// @todo Test
|
||||
exports.beforeFirstWord = (0, exports.beforeFirst)(" ");
|
||||
// /**
|
||||
// * @param {String} str
|
||||
// * @return {String}
|
||||
|
||||
Reference in New Issue
Block a user