UNPKG

everyutil

Version:

A comprehensive library of lightweight, reusable utility functions for JavaScript and TypeScript, designed to streamline common programming tasks such as string manipulation, array processing, date handling, and more.

23 lines (22 loc) 733 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.slugifyAdvanced = void 0; /** * Slugifies a string, supporting emoji, camelCase, kebab-case, and locale-aware slugs. * * Example: slugifyAdvanced("HelloWorld_😀 Test") → "hello-world-😀-test" * * @author @dailker * @param {string} str - The input string to slugify. * @returns {string} The slugified string. */ function slugifyAdvanced(str) { return str .normalize('NFKD') .replace(/([a-z])([A-Z])/g, '$1-$2') .replace(/[\s_]+/g, '-') .replace(/[^\p{L}\p{N}\p{Emoji}-]+/gu, '') .replace(/-+/g, '-') .toLowerCase(); } exports.slugifyAdvanced = slugifyAdvanced;