@rmacshane-lw/slugify-lite 1.0.0 → 3.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/.prettierrc ADDED
@@ -0,0 +1,6 @@
1
+ {
2
+ "singleQuote": true,
3
+ "useTabs": true,
4
+ "arrowParens": "always",
5
+ "trailingComma": "all"
6
+ }
package/README.md CHANGED
@@ -2,7 +2,27 @@
2
2
 
3
3
  A tiny utility that converts strings into URL-friendly slugs.
4
4
 
5
+ **Note:** This is just an AI generated package that is used for me to test npm package management. Use at your own risk.
6
+
5
7
  ## Installation
6
8
 
7
9
  ```bash
8
10
  npm install slugify-lite
11
+ ```
12
+
13
+ ## Usage
14
+ ### Slugify
15
+ ```typescript
16
+ import { slugify } from '@rmacshane-lw/slugify-lite';
17
+
18
+ const slug = slugify('Hello World');
19
+ console.log(slug); # hello-world
20
+ ```
21
+
22
+ ### Version
23
+ ```typescript
24
+ import { version } from '@rmacshane-lw/slugify-lite';
25
+
26
+ const version = version();
27
+ console.log(version); # x.x.x
28
+ ```
package/index.d.ts ADDED
@@ -0,0 +1,12 @@
1
+ /**
2
+ * A tiny function to slugify strings for URLs
3
+ * @param text - The text to convert into a URL-friendly slug
4
+ * @returns A URL-friendly string with spaces replaced by hyphens and special characters removed
5
+ */
6
+ export function slugify(text: string): string;
7
+
8
+ /**
9
+ * Returns the version of the package for testing
10
+ * @returns The version of the package
11
+ */
12
+ export function version(): string;
package/index.js CHANGED
@@ -1,10 +1,14 @@
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
-
1
+ import { createRequire } from 'module';
2
+ const require = createRequire(import.meta.url);
3
+ const pkg = require('./package.json');
4
+
5
+ export const slugify = (text) =>
6
+ text
7
+ .toString()
8
+ .toLowerCase()
9
+ .trim()
10
+ .replace(/[^a-z0-9 -]/g, '') // remove invalid chars
11
+ .replace(/\s+/g, '-') // collapse whitespace and replace by -
12
+ .replace(/-+/g, '-'); // collapse dashes
13
+
14
+ export const version = () => pkg.version;
package/package.json CHANGED
@@ -1,9 +1,10 @@
1
1
  {
2
2
  "name": "@rmacshane-lw/slugify-lite",
3
- "version": "1.0.0",
4
- "description": "A tiny function to slugify strings for URLs",
3
+ "version": "3.0.0",
4
+ "description": "A tiny function to slugify strings for URLs - This is a test package for me to test npm version management - Use at your own risk!",
5
5
  "main": "index.js",
6
6
  "type": "module",
7
+ "types": "index.d.ts",
7
8
  "publishConfig": {
8
9
  "access": "public"
9
10
  },
package/test.mjs CHANGED
@@ -1,4 +1,7 @@
1
- import { slugify } from './index.js';
1
+ import { slugify, version } from './index.js';
2
2
 
3
- console.log(slugify("Hello World! This is cool."));
3
+ console.log(slugify('Hello World! This is cool.'));
4
4
  // Output: "hello-world-this-is-cool"
5
+
6
+ console.log(version());
7
+ // Output: "x.x.x"