@webdeveric/utils 0.73.0 → 0.74.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.
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isTimeoutError = void 0;
4
+ const isTimeoutError = (error) => error instanceof DOMException && error.name === 'TimeoutError';
5
+ exports.isTimeoutError = isTimeoutError;
@@ -2,16 +2,19 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.toPascalCase = toPascalCase;
4
4
  const capitalize_js_1 = require("./capitalize.js");
5
- const getType_js_1 = require("./getType.js");
6
5
  function toPascalCase(text, customWords) {
7
- const words = String(text).match(/[A-Z][a-z']+|\d+|[a-z']+/g);
8
- let fixedWords = words?.map((word) => (0, capitalize_js_1.capitalize)(word.replace(/'/g, '')));
9
- if (fixedWords && customWords && (0, getType_js_1.getType)(customWords) === 'Object') {
6
+ let words = String(text)
7
+ .replaceAll(/['.]/g, '')
8
+ .replaceAll(/[^a-z0-9]/gi, ' ')
9
+ .split(/(\s+)|(?<=\d)(?=[a-z])|(?<=[a-z])(?=\d)/i)
10
+ .filter((word) => word?.trim().length)
11
+ .map(capitalize_js_1.capitalize);
12
+ if (words && customWords && typeof customWords === 'object') {
10
13
  const replacements = new Map(Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]));
11
14
  if (replacements.size) {
12
15
  const replaceCustomWords = (word) => replacements.get(word.toLowerCase()) ?? word;
13
- fixedWords = fixedWords.map(replaceCustomWords);
16
+ words = words.map(replaceCustomWords);
14
17
  }
15
18
  }
16
- return (fixedWords ? fixedWords.join('') : '');
19
+ return words.join('');
17
20
  }
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
@@ -0,0 +1 @@
1
+ export const isTimeoutError = (error) => error instanceof DOMException && error.name === 'TimeoutError';
@@ -1,14 +1,17 @@
1
1
  import { capitalize } from './capitalize.js';
2
- import { getType } from './getType.js';
3
2
  export function toPascalCase(text, customWords) {
4
- const words = String(text).match(/[A-Z][a-z']+|\d+|[a-z']+/g);
5
- let fixedWords = words?.map((word) => capitalize(word.replace(/'/g, '')));
6
- if (fixedWords && customWords && getType(customWords) === 'Object') {
3
+ let words = String(text)
4
+ .replaceAll(/['.]/g, '')
5
+ .replaceAll(/[^a-z0-9]/gi, ' ')
6
+ .split(/(\s+)|(?<=\d)(?=[a-z])|(?<=[a-z])(?=\d)/i)
7
+ .filter((word) => word?.trim().length)
8
+ .map(capitalize);
9
+ if (words && customWords && typeof customWords === 'object') {
7
10
  const replacements = new Map(Object.entries(customWords).map(([key, value]) => [key.toLowerCase(), value]));
8
11
  if (replacements.size) {
9
12
  const replaceCustomWords = (word) => replacements.get(word.toLowerCase()) ?? word;
10
- fixedWords = fixedWords.map(replaceCustomWords);
13
+ words = words.map(replaceCustomWords);
11
14
  }
12
15
  }
13
- return (fixedWords ? fixedWords.join('') : '');
16
+ return words.join('');
14
17
  }
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,2 @@
1
+ import type { TimeoutError } from '../types/errors.js';
2
+ export declare const isTimeoutError: (error: unknown) => error is TimeoutError;
@@ -0,0 +1,3 @@
1
+ export type TimeoutError = DOMException & {
2
+ name: 'TimeoutError';
3
+ };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@webdeveric/utils",
3
3
  "description": "Just another collection of utilities.",
4
- "version": "0.73.0",
4
+ "version": "0.74.1",
5
5
  "publishConfig": {
6
6
  "access": "public"
7
7
  },
@@ -66,7 +66,7 @@
66
66
  "url": "https://github.com/webdeveric/utils/issues"
67
67
  },
68
68
  "homepage": "https://github.com/webdeveric/utils/#readme",
69
- "packageManager": "pnpm@10.17.1+sha512.17c560fca4867ae9473a3899ad84a88334914f379be46d455cbf92e5cf4b39d34985d452d2583baf19967fa76cb5c17bc9e245529d0b98745721aa7200ecaf7a",
69
+ "packageManager": "pnpm@10.19.0+sha512.c9fc7236e92adf5c8af42fd5bf1612df99c2ceb62f27047032f4720b33f8eacdde311865e91c411f2774f618d82f320808ecb51718bfa82c060c4ba7c76a32b8",
70
70
  "scripts": {
71
71
  "clean": "rimraf ./dist/",
72
72
  "prebuild": "pnpm clean",
@@ -87,26 +87,26 @@
87
87
  "devDependencies": {
88
88
  "@commitlint/config-conventional": "^20.0.0",
89
89
  "@commitlint/types": "^20.0.0",
90
- "@types/node": "^22.18.6",
90
+ "@types/node": "^22.18.12",
91
91
  "@vitest/coverage-v8": "^3.2.4",
92
92
  "@webdeveric/eslint-config-ts": "^0.11.0",
93
93
  "@webdeveric/prettier-config": "^0.3.0",
94
- "commitlint": "^20.0.0",
94
+ "commitlint": "^20.1.0",
95
95
  "commitlint-plugin-cspell": "^0.3.0",
96
96
  "conventional-changelog-conventionalcommits": "^9.1.0",
97
- "cspell": "^9.2.1",
97
+ "cspell": "^9.2.2",
98
98
  "eslint": "^8.57.1",
99
99
  "eslint-config-prettier": "^10.1.8",
100
100
  "eslint-import-resolver-typescript": "^4.4.4",
101
101
  "eslint-plugin-import": "^2.32.0",
102
102
  "husky": "^9.1.7",
103
- "jsdom": "^27.0.0",
104
- "lint-staged": "^16.2.1",
103
+ "jsdom": "^27.0.1",
104
+ "lint-staged": "^16.2.6",
105
105
  "prettier": "^3.6.2",
106
106
  "rimraf": "^6.0.1",
107
107
  "semantic-release": "^24.2.9",
108
- "typescript": "^5.9.2",
109
- "validate-package-exports": "^0.13.0",
108
+ "typescript": "^5.9.3",
109
+ "validate-package-exports": "^0.14.0",
110
110
  "vitest": "^3.2.4"
111
111
  },
112
112
  "pnpm": {