@ciwergrp/nuxid 1.5.6 → 1.5.8
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/dist/module.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
1
|
+
import * as pluralizeModule from "pluralize";
|
|
2
2
|
import { studly } from "./case.js";
|
|
3
|
+
const pluralize = pluralizeModule.default ?? pluralizeModule;
|
|
3
4
|
export function plural(value, count) {
|
|
4
5
|
if (typeof count === "number") {
|
|
5
6
|
return pluralize(value, count);
|
|
@@ -1,12 +1,16 @@
|
|
|
1
|
-
import * as slugifyModule from "@sindresorhus/slugify";
|
|
2
1
|
import { defaultLocale } from "./locale.js";
|
|
3
|
-
|
|
2
|
+
import { transliterate } from "./transliterate.js";
|
|
3
|
+
const nonAlphanumericPattern = /[^a-z0-9]+/gi;
|
|
4
4
|
export function slug(value, separator = "-") {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
const locale = defaultLocale();
|
|
6
|
+
const normalized = transliterate(value, locale ? { locale } : void 0);
|
|
7
|
+
const lowerCased = locale ? normalized.toLocaleLowerCase(locale) : normalized.toLowerCase();
|
|
8
|
+
if (!separator) {
|
|
9
|
+
return lowerCased.replace(nonAlphanumericPattern, "");
|
|
7
10
|
}
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const escapedSeparator = escapeRegExp(separator);
|
|
12
|
+
return lowerCased.replace(nonAlphanumericPattern, separator).replace(new RegExp(`${escapedSeparator}{2,}`, "g"), separator).replace(new RegExp(`^${escapedSeparator}|${escapedSeparator}$`, "g"), "");
|
|
13
|
+
}
|
|
14
|
+
function escapeRegExp(value) {
|
|
15
|
+
return value.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
12
16
|
}
|
|
@@ -1,2 +1,3 @@
|
|
|
1
|
-
|
|
1
|
+
import type { Options as TransliterateOptions } from '@sindresorhus/transliterate';
|
|
2
|
+
export declare function transliterate(value: string, options?: TransliterateOptions): string;
|
|
2
3
|
export declare function ascii(value: string): string;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import transliterateLib from "@sindresorhus/transliterate";
|
|
2
|
-
export function transliterate(value) {
|
|
3
|
-
return transliterateLib(value);
|
|
2
|
+
export function transliterate(value, options) {
|
|
3
|
+
return transliterateLib(value, options);
|
|
4
4
|
}
|
|
5
5
|
export function ascii(value) {
|
|
6
6
|
const converted = transliterate(value);
|