@rmacshane-lw/slugify-lite 2.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 +6 -0
- package/README.md +9 -1
- package/index.d.ts +7 -1
- package/index.js +14 -10
- package/package.json +1 -1
- package/test.mjs +5 -2
package/.prettierrc
ADDED
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,14 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rmacshane-lw/slugify-lite",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.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(
|
|
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"
|