@verifyhash/slugify-lite 0.1.0 → 0.1.1
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/LICENSE +1 -1
- package/README.md +10 -0
- package/index.d.ts +52 -0
- package/package.json +4 -2
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -5,6 +5,16 @@ string into a clean URL slug: `"Héllo, World!"` → `"hello-world"`. One Common
|
|
|
5
5
|
file (`index.js`), no install step, no I/O, no runtime `require` of anything —
|
|
6
6
|
drop it into any project and `require` it.
|
|
7
7
|
|
|
8
|
+
## Install
|
|
9
|
+
|
|
10
|
+
```bash
|
|
11
|
+
npm install @verifyhash/slugify-lite
|
|
12
|
+
```
|
|
13
|
+
|
|
14
|
+
Published as [`@verifyhash/slugify-lite`](https://www.npmjs.com/package/@verifyhash/slugify-lite);
|
|
15
|
+
source lives in the [verifyhash/libs](https://github.com/verifyhash/libs) monorepo.
|
|
16
|
+
Zero runtime dependencies — you can also vendor the folder directly.
|
|
17
|
+
|
|
8
18
|
## Who it's for
|
|
9
19
|
|
|
10
20
|
JavaScript/Node developers who need slugs for URLs, filenames, anchor IDs, or
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type declarations for @verifyhash/slugify-lite — zero-dependency,
|
|
3
|
+
* zero-network string -> URL slug: Latin-1/accent transliteration via a
|
|
4
|
+
* pinned in-repo map, custom separator, word-boundary maxLength truncation,
|
|
5
|
+
* and custom replacement overrides.
|
|
6
|
+
*
|
|
7
|
+
* The module's export IS the slugify function (CommonJS `export =`), with
|
|
8
|
+
* `.slugify` and `.default` self-references for destructuring / ESM-interop
|
|
9
|
+
* imports, and `.charMap` exposing the built-in transliteration table.
|
|
10
|
+
*
|
|
11
|
+
* Honest limit: only common accented Latin characters are romanized;
|
|
12
|
+
* non-Latin scripts (Cyrillic, Greek, Arabic, CJK, emoji, …) are stripped,
|
|
13
|
+
* not transliterated.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
declare const slugify: slugify.SlugifyFunction;
|
|
17
|
+
|
|
18
|
+
declare namespace slugify {
|
|
19
|
+
/** Options for slugify(). */
|
|
20
|
+
interface SlugifyOptions {
|
|
21
|
+
/** Character(s) used to join words (default '-'). */
|
|
22
|
+
separator?: string;
|
|
23
|
+
/** Lowercase the result (default true). */
|
|
24
|
+
lowercase?: boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Maximum slug length; truncation happens on a word boundary — never
|
|
27
|
+
* mid-word, never leaving a trailing separator.
|
|
28
|
+
*/
|
|
29
|
+
maxLength?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Custom single-character -> string replacement map, merged OVER the
|
|
32
|
+
* built-in transliteration map.
|
|
33
|
+
*/
|
|
34
|
+
replacements?: Record<string, string>;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
interface SlugifyFunction {
|
|
38
|
+
/**
|
|
39
|
+
* Convert a string to a URL slug, e.g. 'Héllo, World!' -> 'hello-world'.
|
|
40
|
+
* null/undefined input returns ''; any other non-string is String()-coerced.
|
|
41
|
+
*/
|
|
42
|
+
(input: string | null | undefined, options?: SlugifyOptions): string;
|
|
43
|
+
/** Self-reference so `const { slugify } = require('@verifyhash/slugify-lite')` works. */
|
|
44
|
+
slugify: SlugifyFunction;
|
|
45
|
+
/** ESM-interop self-reference (`import slugify from '@verifyhash/slugify-lite'`). */
|
|
46
|
+
default: SlugifyFunction;
|
|
47
|
+
/** Frozen copy of the built-in transliteration map (single char -> ASCII). */
|
|
48
|
+
readonly charMap: Readonly<Record<string, string>>;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
export = slugify;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@verifyhash/slugify-lite",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.1",
|
|
4
4
|
"description": "Zero-dependency, zero-network string-to-URL-slug library for Node.js: Latin-1/accent transliteration via a pinned in-repo map, custom separator, word-boundary maxLength truncation, and custom replacement overrides.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"slug",
|
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
"zero-dependency"
|
|
13
13
|
],
|
|
14
14
|
"main": "index.js",
|
|
15
|
+
"types": "index.d.ts",
|
|
15
16
|
"scripts": {
|
|
16
17
|
"test": "node test/index.test.js"
|
|
17
18
|
},
|
|
@@ -19,7 +20,8 @@
|
|
|
19
20
|
"files": [
|
|
20
21
|
"index.js",
|
|
21
22
|
"README.md",
|
|
22
|
-
"LICENSE"
|
|
23
|
+
"LICENSE",
|
|
24
|
+
"index.d.ts"
|
|
23
25
|
],
|
|
24
26
|
"publishConfig": {
|
|
25
27
|
"access": "public"
|