UNPKG

stringzy

Version:

A versatile string manipulation library providing a range of text utilities for JavaScript and Node.js applications.

14 lines (13 loc) 356 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.toSlug = toSlug; function toSlug(text) { if (typeof text !== "string") { throw new Error("Invalid argument. Expected a string."); } return text .toLowerCase() .trim() .replace(/[\s]+/g, "-") .replace(/[^\w-]+/g, ""); }