@rmacshane-lw/slugify-lite 2.0.0 → 4.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
@@ -11,10 +11,18 @@ npm install slugify-lite
11
11
  ```
12
12
 
13
13
  ## Usage
14
-
14
+ ### Slugify
15
15
  ```typescript
16
16
  import { slugify } from '@rmacshane-lw/slugify-lite';
17
17
 
18
18
  const slug = slugify('Hello World');
19
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
20
28
  ```
package/index.d.ts CHANGED
@@ -3,4 +3,10 @@
3
3
  * @param text - The text to convert into a URL-friendly slug
4
4
  * @returns A URL-friendly string with spaces replaced by hyphens and special characters removed
5
5
  */
6
- export function slugify(text: string): string;
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,13 @@
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 { readFileSync } from 'fs';
2
+ const pkg = JSON.parse(readFileSync(new URL('./package.json', import.meta.url)));
3
+
4
+ export const slugify = (text) =>
5
+ text
6
+ .toString()
7
+ .toLowerCase()
8
+ .trim()
9
+ .replace(/[^a-z0-9 -]/g, '') // remove invalid chars
10
+ .replace(/\s+/g, '-') // collapse whitespace and replace by -
11
+ .replace(/-+/g, '-'); // collapse dashes
12
+
13
+ export const version = () => pkg.version;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rmacshane-lw/slugify-lite",
3
- "version": "2.0.0",
3
+ "version": "4.0.0",
4
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",
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"