@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.
- package/dist/cjs/predicate/isTimeoutError.js +5 -0
- package/dist/cjs/toPascalCase.js +9 -6
- package/dist/cjs/types/errors.js +2 -0
- package/dist/mjs/predicate/isTimeoutError.js +1 -0
- package/dist/mjs/toPascalCase.js +9 -6
- package/dist/mjs/types/errors.js +1 -0
- package/dist/types/predicate/isTimeoutError.d.ts +2 -0
- package/dist/types/types/errors.d.ts +3 -0
- package/package.json +9 -9
package/dist/cjs/toPascalCase.js
CHANGED
|
@@ -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
|
-
|
|
8
|
-
|
|
9
|
-
|
|
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
|
-
|
|
16
|
+
words = words.map(replaceCustomWords);
|
|
14
17
|
}
|
|
15
18
|
}
|
|
16
|
-
return
|
|
19
|
+
return words.join('');
|
|
17
20
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const isTimeoutError = (error) => error instanceof DOMException && error.name === 'TimeoutError';
|
package/dist/mjs/toPascalCase.js
CHANGED
|
@@ -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
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
13
|
+
words = words.map(replaceCustomWords);
|
|
11
14
|
}
|
|
12
15
|
}
|
|
13
|
-
return
|
|
16
|
+
return words.join('');
|
|
14
17
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
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.
|
|
104
|
-
"lint-staged": "^16.2.
|
|
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.
|
|
109
|
-
"validate-package-exports": "^0.
|
|
108
|
+
"typescript": "^5.9.3",
|
|
109
|
+
"validate-package-exports": "^0.14.0",
|
|
110
110
|
"vitest": "^3.2.4"
|
|
111
111
|
},
|
|
112
112
|
"pnpm": {
|