@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,7 +1,7 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
3
  "configKey": "nuxid",
4
- "version": "1.5.6",
4
+ "version": "1.5.8",
5
5
  "builder": {
6
6
  "@nuxt/module-builder": "1.0.2",
7
7
  "unbuild": "3.6.1"
@@ -1,5 +1,6 @@
1
- import pluralize from "pluralize";
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
- const slugify = slugifyModule.default;
2
+ import { transliterate } from "./transliterate.js";
3
+ const nonAlphanumericPattern = /[^a-z0-9]+/gi;
4
4
  export function slug(value, separator = "-") {
5
- if (!slugify) {
6
- throw new Error("Slugify is unavailable.");
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
- return slugify(value, {
9
- separator,
10
- locale: defaultLocale()
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
- export declare function transliterate(value: string): string;
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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ciwergrp/nuxid",
3
- "version": "1.5.6",
3
+ "version": "1.5.8",
4
4
  "description": "All-in-one essential modules for Nuxt",
5
5
  "repository": {
6
6
  "type": "git",