@luxass/utils 2.7.2 → 2.7.5
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/{guards-O1HGJraI.js → guards.mjs} +1 -2
- package/dist/{index.d.ts → index.d.mts} +6 -6
- package/dist/{index.js → index.mjs} +7 -8
- package/dist/{number-BS9T5WGO.js → number.mjs} +1 -2
- package/dist/{path-CFkUYi0a.d.ts → path.d.mts} +0 -34
- package/dist/{path-UEx_WP0U.js → path.mjs} +5 -6
- package/dist/{string-BlwTLoKD.js → string.mjs} +5 -5
- package/dist/types.mjs +1 -0
- package/package.json +40 -41
- package/dist/guards.d.ts +0 -2
- package/dist/guards.js +0 -3
- package/dist/number.d.ts +0 -2
- package/dist/number.js +0 -3
- package/dist/object.d.ts +0 -2
- package/dist/object.js +0 -3
- package/dist/path.d.ts +0 -2
- package/dist/path.js +0 -3
- package/dist/string.d.ts +0 -2
- package/dist/string.js +0 -3
- package/dist/types.d.ts +0 -2
- package/dist/types.js +0 -1
- package/dist/{guards-SWdmRZ5e.d.ts → guards.d.mts} +0 -0
- package/dist/{number-Culbli-Y.d.ts → number.d.mts} +0 -0
- package/dist/{object-BtzfqVfB.d.ts → object.d.mts} +0 -0
- package/dist/{object-DWHqMFiC.js → object.mjs} +1 -2
- /package/dist/{string-BgrFQWVx.d.ts → string.d.mts} +0 -0
- /package/dist/{types-CdpK0-xy.d.ts → types.d.mts} +0 -0
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { isNotNull, isNotNullish, isNotUndefined, isTruthy } from "./guards
|
|
2
|
-
import { clamp } from "./number
|
|
3
|
-
import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object
|
|
4
|
-
import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path
|
|
5
|
-
import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string
|
|
6
|
-
import { ElementOf, InferArguments, Prettify, RemoveIndexSignature } from "./types
|
|
1
|
+
import { isNotNull, isNotNullish, isNotUndefined, isTruthy } from "./guards.mjs";
|
|
2
|
+
import { clamp } from "./number.mjs";
|
|
3
|
+
import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object.mjs";
|
|
4
|
+
import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path.mjs";
|
|
5
|
+
import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.mjs";
|
|
6
|
+
import { ElementOf, InferArguments, Prettify, RemoveIndexSignature } from "./types.mjs";
|
|
7
7
|
import pRetry from "p-retry";
|
|
8
8
|
|
|
9
9
|
//#region src/common.d.ts
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import { clamp } from "./number
|
|
4
|
-
import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object
|
|
5
|
-
import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path
|
|
1
|
+
import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.mjs";
|
|
2
|
+
import { isNotNull, isNotNullish, isNotUndefined, isTruthy } from "./guards.mjs";
|
|
3
|
+
import { clamp } from "./number.mjs";
|
|
4
|
+
import { getChangedKeys, getOwnProperty, hasOwnProperty, omit } from "./object.mjs";
|
|
5
|
+
import { appendTrailingSlash, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash } from "./path.mjs";
|
|
6
6
|
import pRetry from "p-retry";
|
|
7
|
-
|
|
8
7
|
//#region src/common.ts
|
|
9
8
|
var InvariantError = class extends Error {
|
|
9
|
+
message;
|
|
10
10
|
constructor(message, ...positionals) {
|
|
11
11
|
super(message);
|
|
12
12
|
this.message = message;
|
|
@@ -25,6 +25,5 @@ var InvariantError = class extends Error {
|
|
|
25
25
|
function invariant(predicate, message, ...positionals) {
|
|
26
26
|
if (!predicate) throw new InvariantError(message, ...positionals);
|
|
27
27
|
}
|
|
28
|
-
|
|
29
28
|
//#endregion
|
|
30
|
-
export { InvariantError, appendTrailingSlash, capitalize, clamp, dedent, dedentRaw, formatStr, getChangedKeys, getOwnProperty, hasOwnProperty, invariant, isNotNull, isNotNullish, isNotUndefined, isTruthy, omit, prependLeadingSlash, pRetry as promiseRetry, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, trimLeadingSlash, trimTrailingSlash };
|
|
29
|
+
export { InvariantError, appendTrailingSlash, capitalize, clamp, dedent, dedentRaw, formatStr, getChangedKeys, getOwnProperty, hasOwnProperty, invariant, isNotNull, isNotNullish, isNotUndefined, isTruthy, omit, prependLeadingSlash, pRetry as promiseRetry, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase, trimLeadingSlash, trimTrailingSlash };
|
|
@@ -61,40 +61,6 @@ declare function appendTrailingSlash(path: string | undefined): string;
|
|
|
61
61
|
* ```
|
|
62
62
|
*/
|
|
63
63
|
declare function prependLeadingSlash(path: string | undefined): string;
|
|
64
|
-
/**
|
|
65
|
-
* Joins URL paths together, handling trailing and leading slashes appropriately
|
|
66
|
-
* @param {string} base - The base URL path
|
|
67
|
-
* @param {...string} segments - Additional URL segments to join
|
|
68
|
-
* @returns {string} The joined URL path
|
|
69
|
-
*
|
|
70
|
-
* @example
|
|
71
|
-
* ```ts
|
|
72
|
-
* import { joinURL } from "@luxass/utils/path";
|
|
73
|
-
*
|
|
74
|
-
* // Basic path joining
|
|
75
|
-
* joinURL("api", "users") // "api/users"
|
|
76
|
-
* joinURL("api/", "users") // "api/users"
|
|
77
|
-
* joinURL("api", "/users") // "api/users"
|
|
78
|
-
* joinURL("api/", "/users") // "api/users"
|
|
79
|
-
*
|
|
80
|
-
* // URL joining with protocol
|
|
81
|
-
* joinURL("https://api.example.com", "v1/users") // "https://api.example.com/v1/users"
|
|
82
|
-
* joinURL("https://api.example.com/", "/v1/users") // "https://api.example.com/v1/users"
|
|
83
|
-
*
|
|
84
|
-
* // Multiple slash normalization
|
|
85
|
-
* joinURL("api//v1/", "//users///") // "api/v1/users/"
|
|
86
|
-
* joinURL("base///", "///path") // "base/path"
|
|
87
|
-
*
|
|
88
|
-
* // Root path handling
|
|
89
|
-
* joinURL("/", "users") // "/users"
|
|
90
|
-
* joinURL("api", "/") // "api/"
|
|
91
|
-
*
|
|
92
|
-
* // Empty and undefined handling
|
|
93
|
-
* joinURL("", "users") // "users"
|
|
94
|
-
* joinURL("api", "") // "api"
|
|
95
|
-
* joinURL("", "") // "/"
|
|
96
|
-
* ```
|
|
97
|
-
*/
|
|
98
64
|
declare function joinURL(base: string, ...segments: string[]): string;
|
|
99
65
|
//#endregion
|
|
100
66
|
export { appendTrailingSlash, joinURL, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash };
|
|
@@ -107,12 +107,12 @@ function prependLeadingSlash(path) {
|
|
|
107
107
|
* joinURL("", "") // "/"
|
|
108
108
|
* ```
|
|
109
109
|
*/
|
|
110
|
+
function normalizeURLPath(path) {
|
|
111
|
+
return path.replace(/([^:])\/+/g, "$1/").replace(/^\/+/, "/");
|
|
112
|
+
}
|
|
110
113
|
function joinURL(base, ...segments) {
|
|
111
114
|
if (!base && !segments) return "/";
|
|
112
115
|
if (!segments || segments.length === 0) return base || "/";
|
|
113
|
-
const normalize = (s) => {
|
|
114
|
-
return s.replace(/([^:])\/+/g, "$1/").replace(/^\/+/, "/");
|
|
115
|
-
};
|
|
116
116
|
let path = base;
|
|
117
117
|
for (const seg of segments) {
|
|
118
118
|
if (!seg || seg === ".") continue;
|
|
@@ -123,8 +123,7 @@ function joinURL(base, ...segments) {
|
|
|
123
123
|
else path += pathTrailing || segLeading ? seg : `/${seg}`;
|
|
124
124
|
} else path += seg;
|
|
125
125
|
}
|
|
126
|
-
return
|
|
126
|
+
return normalizeURLPath(path) || "/";
|
|
127
127
|
}
|
|
128
|
-
|
|
129
128
|
//#endregion
|
|
130
|
-
export { appendTrailingSlash, joinURL, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash };
|
|
129
|
+
export { appendTrailingSlash, joinURL, prependLeadingSlash, trimLeadingSlash, trimTrailingSlash };
|
|
@@ -144,10 +144,10 @@ function dedentRaw(strings, ...values) {
|
|
|
144
144
|
}
|
|
145
145
|
/** @internal */
|
|
146
146
|
function internal_dedent(strings, values, raw = false) {
|
|
147
|
-
const
|
|
147
|
+
const rawStrings = typeof strings === "string" ? [strings] : raw ? strings.raw : strings;
|
|
148
148
|
let result = "";
|
|
149
|
-
for (let i = 0; i <
|
|
150
|
-
const next =
|
|
149
|
+
for (let i = 0; i < rawStrings.length; i++) {
|
|
150
|
+
const next = rawStrings[i];
|
|
151
151
|
result += next;
|
|
152
152
|
if (i < values.length) result += values[i];
|
|
153
153
|
}
|
|
@@ -190,6 +190,7 @@ function serializePositional(positional, flag) {
|
|
|
190
190
|
if (json === "{}" || json === "[]" || /^\[object .+?\]$/.test(json)) return positional;
|
|
191
191
|
return json;
|
|
192
192
|
}
|
|
193
|
+
return positional;
|
|
193
194
|
}
|
|
194
195
|
/**
|
|
195
196
|
* Formats a string by replacing placeholders with positional values
|
|
@@ -223,6 +224,5 @@ function formatStr(message, ...positionals) {
|
|
|
223
224
|
formattedMessage = formattedMessage.replace(/%{2}/g, "%");
|
|
224
225
|
return formattedMessage;
|
|
225
226
|
}
|
|
226
|
-
|
|
227
227
|
//#endregion
|
|
228
|
-
export { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
228
|
+
export { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/types.mjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/package.json
CHANGED
|
@@ -1,67 +1,66 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/utils",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.5",
|
|
4
4
|
"description": "A collection of utilities for JavaScript/TypeScript",
|
|
5
|
-
"
|
|
5
|
+
"keywords": [
|
|
6
|
+
"utils"
|
|
7
|
+
],
|
|
8
|
+
"homepage": "https://github.com/luxass/utils",
|
|
9
|
+
"bugs": {
|
|
10
|
+
"url": "https://github.com/luxass/utils/issues"
|
|
11
|
+
},
|
|
12
|
+
"license": "MIT",
|
|
6
13
|
"author": {
|
|
7
14
|
"name": "Lucas Nørgård",
|
|
8
15
|
"email": "lucasnrgaard@gmail.com",
|
|
9
16
|
"url": "https://luxass.dev"
|
|
10
17
|
},
|
|
11
|
-
"packageManager": "pnpm@10.16.0",
|
|
12
|
-
"license": "MIT",
|
|
13
|
-
"homepage": "https://github.com/luxass/utils",
|
|
14
18
|
"repository": {
|
|
15
19
|
"type": "git",
|
|
16
20
|
"url": "git+https://github.com/luxass/utils.git"
|
|
17
21
|
},
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
},
|
|
21
|
-
"keywords": [
|
|
22
|
-
"utils"
|
|
22
|
+
"files": [
|
|
23
|
+
"dist"
|
|
23
24
|
],
|
|
25
|
+
"type": "module",
|
|
24
26
|
"sideEffects": false,
|
|
27
|
+
"types": "./dist/index.d.mts",
|
|
25
28
|
"exports": {
|
|
26
|
-
".": "./dist/index.
|
|
27
|
-
"./guards": "./dist/guards.
|
|
28
|
-
"./number": "./dist/number.
|
|
29
|
-
"./object": "./dist/object.
|
|
30
|
-
"./path": "./dist/path.
|
|
31
|
-
"./string": "./dist/string.
|
|
32
|
-
"./types": "./dist/types.
|
|
29
|
+
".": "./dist/index.mjs",
|
|
30
|
+
"./guards": "./dist/guards.mjs",
|
|
31
|
+
"./number": "./dist/number.mjs",
|
|
32
|
+
"./object": "./dist/object.mjs",
|
|
33
|
+
"./path": "./dist/path.mjs",
|
|
34
|
+
"./string": "./dist/string.mjs",
|
|
35
|
+
"./types": "./dist/types.mjs",
|
|
33
36
|
"./package.json": "./package.json"
|
|
34
37
|
},
|
|
35
|
-
"
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
"
|
|
39
|
-
"
|
|
40
|
-
|
|
38
|
+
"dependencies": {
|
|
39
|
+
"p-retry": "8.0.0"
|
|
40
|
+
},
|
|
41
|
+
"devDependencies": {
|
|
42
|
+
"@types/node": "25.9.2",
|
|
43
|
+
"oxfmt": "0.54.0",
|
|
44
|
+
"oxlint": "1.69.0",
|
|
45
|
+
"oxlint-tsgolint": "0.23.0",
|
|
46
|
+
"publint": "0.3.21",
|
|
47
|
+
"tsdown": "0.22.2",
|
|
48
|
+
"tsnapi": "0.3.3",
|
|
49
|
+
"typescript": "6.0.3",
|
|
50
|
+
"vitest": "4.1.8"
|
|
51
|
+
},
|
|
41
52
|
"engines": {
|
|
42
|
-
"node": ">=
|
|
53
|
+
"node": ">=24"
|
|
43
54
|
},
|
|
44
55
|
"scripts": {
|
|
45
56
|
"build": "tsdown",
|
|
46
57
|
"dev": "tsdown --watch",
|
|
47
58
|
"test": "vitest --run",
|
|
48
59
|
"test:watch": "vitest",
|
|
49
|
-
"lint": "
|
|
60
|
+
"lint": "oxlint",
|
|
61
|
+
"lint:fix": "oxlint --fix",
|
|
62
|
+
"fmt": "oxfmt",
|
|
63
|
+
"fmt:check": "oxfmt --check",
|
|
50
64
|
"typecheck": "tsc --noEmit"
|
|
51
|
-
},
|
|
52
|
-
"dependencies": {
|
|
53
|
-
"p-retry": "^7.0.0"
|
|
54
|
-
},
|
|
55
|
-
"devDependencies": {
|
|
56
|
-
"@luxass/eslint-config": "^5.3.1",
|
|
57
|
-
"@types/node": "^22.18.3",
|
|
58
|
-
"@vitest/coverage-v8": "3.2.4",
|
|
59
|
-
"eslint": "^9.35.0",
|
|
60
|
-
"eslint-plugin-format": "^1.0.1",
|
|
61
|
-
"publint": "^0.3.12",
|
|
62
|
-
"tsdown": "^0.15.1",
|
|
63
|
-
"typescript": "^5.9.2",
|
|
64
|
-
"vitest": "^3.2.4",
|
|
65
|
-
"vitest-package-exports": "^0.1.1"
|
|
66
65
|
}
|
|
67
|
-
}
|
|
66
|
+
}
|
package/dist/guards.d.ts
DELETED
package/dist/guards.js
DELETED
package/dist/number.d.ts
DELETED
package/dist/number.js
DELETED
package/dist/object.d.ts
DELETED
package/dist/object.js
DELETED
package/dist/path.d.ts
DELETED
package/dist/path.js
DELETED
package/dist/string.d.ts
DELETED
|
@@ -1,2 +0,0 @@
|
|
|
1
|
-
import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-BgrFQWVx.js";
|
|
2
|
-
export { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.js
DELETED
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-BlwTLoKD.js";
|
|
2
|
-
|
|
3
|
-
export { capitalize, dedent, dedentRaw, formatStr, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/types.d.ts
DELETED
package/dist/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { };
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|