@azizbecha/strkit
Version:
strkit is a utility library offering a collection of essential string functions including validation, case conversion, truncation, and more. Ideal for both JavaScript and TypeScript developers to simplify string operations in their applications.
28 lines • 1.01 kB
JavaScript
(function (factory) {
if (typeof module === "object" && typeof module.exports === "object") {
var v = factory(require, exports);
if (v !== undefined) module.exports = v;
}
else if (typeof define === "function" && define.amd) {
define(["require", "exports"], factory);
}
})(function (require, exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.default = endsWith;
/**
* Checks if a string ends with the specified suffix.
*
* @param str - The string to check.
* @param suffix - The suffix to check for.
* @returns A boolean indicating whether the string ends with the specified suffix.
*
* @example
* endsWith("hello world", "world"); // Output: true
* endsWith("hello world", "hello"); // Output: false
*/
function endsWith(str, suffix) {
return str.lastIndexOf(suffix) === str.length - suffix.length;
}
});
//# sourceMappingURL=endsWith.js.map