@rmacshane-lw/slugify-lite 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md ADDED
@@ -0,0 +1,8 @@
1
+ # slugify-lite
2
+
3
+ A tiny utility that converts strings into URL-friendly slugs.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install slugify-lite
package/index.js ADDED
@@ -0,0 +1,10 @@
1
+ export function slugify(text) {
2
+ return text
3
+ .toString()
4
+ .toLowerCase()
5
+ .trim()
6
+ .replace(/[^a-z0-9 -]/g, '') // remove invalid chars
7
+ .replace(/\s+/g, '-') // collapse whitespace and replace by -
8
+ .replace(/-+/g, '-'); // collapse dashes
9
+ }
10
+
package/package.json ADDED
@@ -0,0 +1,29 @@
1
+ {
2
+ "name": "@rmacshane-lw/slugify-lite",
3
+ "version": "1.0.0",
4
+ "description": "A tiny function to slugify strings for URLs",
5
+ "main": "index.js",
6
+ "type": "module",
7
+ "publishConfig": {
8
+ "access": "public"
9
+ },
10
+ "scripts": {
11
+ "test": "echo \"Error: no test specified\" && exit 1"
12
+ },
13
+ "repository": {
14
+ "type": "git",
15
+ "url": "git+https://github.com/russellmacshane/slugify-lite.git"
16
+ },
17
+ "keywords": [
18
+ "slugify",
19
+ "string",
20
+ "url",
21
+ "utility"
22
+ ],
23
+ "author": "Russ MacShane",
24
+ "license": "ISC",
25
+ "bugs": {
26
+ "url": "https://github.com/russellmacshane/slugify-lite/issues"
27
+ },
28
+ "homepage": "https://github.com/russellmacshane/slugify-lite#readme"
29
+ }
package/test.mjs ADDED
@@ -0,0 +1,4 @@
1
+ import { slugify } from './index.js';
2
+
3
+ console.log(slugify("Hello World! This is cool."));
4
+ // Output: "hello-world-this-is-cool"