@luxass/utils 1.3.0 → 1.5.0
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/index.cjs +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/{string-ClUTkZtT.js → string-DgqE1XDy.js} +18 -16
- package/dist/{string-Bsjh7sy7.cjs → string-Ki9Q9jVP.cjs} +23 -15
- package/dist/string.cjs +2 -1
- package/dist/{string.d-DNAFYlGi.d.cts → string.d-BgvLaGcg.d.ts} +21 -5
- package/dist/{string.d-CkCHrMO0.d.ts → string.d-olvwSa1o.d.cts} +21 -5
- package/dist/string.d.cts +2 -2
- package/dist/string.d.ts +2 -2
- package/dist/string.js +2 -2
- package/package.json +2 -1
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
const require_guards = require('./guards-DE5pQVvl.cjs');
|
|
2
2
|
const require_number = require('./number-DRbo8lb6.cjs');
|
|
3
|
-
const require_string = require('./string-
|
|
3
|
+
const require_string = require('./string-Ki9Q9jVP.cjs');
|
|
4
4
|
|
|
5
5
|
exports.capitalize = require_string.capitalize
|
|
6
6
|
exports.clamp = require_number.clamp
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNotNull, isNotNullish, isNotUndefined, isTruthy } from "./guards.d-DXUlpL_S.cjs";
|
|
2
2
|
import { clamp } from "./number.d-C1FAMQlq.cjs";
|
|
3
|
-
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-
|
|
3
|
+
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-olvwSa1o.cjs";
|
|
4
4
|
import { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish } from "./types.d-fcYBBT6c.cjs";
|
|
5
5
|
export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish, capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNotNull$1 as isNotNull, isNotNullish$1 as isNotNullish, isNotUndefined$1 as isNotUndefined, isTruthy$1 as isTruthy } from "./guards.d-n1BzCANy.js";
|
|
2
2
|
import { clamp$1 as clamp } from "./number.d-C2Xuq3Is.js";
|
|
3
|
-
import { capitalize$1 as capitalize, dedent$1 as dedent, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-
|
|
3
|
+
import { capitalize$1 as capitalize, dedent$1 as dedent, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-BgvLaGcg.js";
|
|
4
4
|
import { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish } from "./types.d-BcKIY6l3.js";
|
|
5
5
|
export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish, capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { isNotNull, isNotNullish, isNotUndefined, isTruthy } from "./guards-O1HGJraI.js";
|
|
2
2
|
import { clamp } from "./number-Bfr1z0Nr.js";
|
|
3
|
-
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-
|
|
3
|
+
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-DgqE1XDy.js";
|
|
4
4
|
|
|
5
5
|
export { capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
@@ -93,21 +93,23 @@ function toSnakeCase(str) {
|
|
|
93
93
|
if (!str) return "";
|
|
94
94
|
return str.trim().replace(/-/g, "_").replace(/\s+/g, " ").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/\s+/g, "_").replace(/_+/g, "_").toLowerCase();
|
|
95
95
|
}
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
96
|
+
function dedent(strings, ...values) {
|
|
97
|
+
return internal_dedent(strings, values, false);
|
|
98
|
+
}
|
|
99
|
+
dedent.raw = dedentRaw;
|
|
100
|
+
function dedentRaw(strings, ...values) {
|
|
101
|
+
return internal_dedent(strings, values, true);
|
|
102
|
+
}
|
|
103
|
+
/** @internal */
|
|
104
|
+
function internal_dedent(strings, values, raw = false) {
|
|
105
|
+
const _raw = typeof strings === "string" ? [strings] : raw ? strings.raw : strings;
|
|
106
|
+
let result = "";
|
|
107
|
+
for (let i = 0; i < _raw.length; i++) {
|
|
108
|
+
const next = _raw[i];
|
|
109
|
+
result += next;
|
|
110
|
+
if (i < values.length) result += values[i];
|
|
111
|
+
}
|
|
112
|
+
const lines = result.split("\n");
|
|
111
113
|
const whitespaceLines = lines.map((line) => FULL_WHITESPACE_RE.test(line));
|
|
112
114
|
const commonIndent = lines.reduce((min, line, idx) => {
|
|
113
115
|
if (whitespaceLines[idx]) return min;
|
|
@@ -120,4 +122,4 @@ function dedent(str) {
|
|
|
120
122
|
}
|
|
121
123
|
|
|
122
124
|
//#endregion
|
|
123
|
-
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
125
|
+
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
@@ -95,21 +95,23 @@ function toSnakeCase(str) {
|
|
|
95
95
|
if (!str) return "";
|
|
96
96
|
return str.trim().replace(/-/g, "_").replace(/\s+/g, " ").replace(/([A-Z]+)([A-Z][a-z])/g, "$1_$2").replace(/([a-z0-9])([A-Z])/g, "$1_$2").replace(/\s+/g, "_").replace(/_+/g, "_").toLowerCase();
|
|
97
97
|
}
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
98
|
+
function dedent(strings, ...values) {
|
|
99
|
+
return internal_dedent(strings, values, false);
|
|
100
|
+
}
|
|
101
|
+
dedent.raw = dedentRaw;
|
|
102
|
+
function dedentRaw(strings, ...values) {
|
|
103
|
+
return internal_dedent(strings, values, true);
|
|
104
|
+
}
|
|
105
|
+
/** @internal */
|
|
106
|
+
function internal_dedent(strings, values, raw = false) {
|
|
107
|
+
const _raw = typeof strings === "string" ? [strings] : raw ? strings.raw : strings;
|
|
108
|
+
let result = "";
|
|
109
|
+
for (let i = 0; i < _raw.length; i++) {
|
|
110
|
+
const next = _raw[i];
|
|
111
|
+
result += next;
|
|
112
|
+
if (i < values.length) result += values[i];
|
|
113
|
+
}
|
|
114
|
+
const lines = result.split("\n");
|
|
113
115
|
const whitespaceLines = lines.map((line) => FULL_WHITESPACE_RE.test(line));
|
|
114
116
|
const commonIndent = lines.reduce((min, line, idx) => {
|
|
115
117
|
if (whitespaceLines[idx]) return min;
|
|
@@ -134,6 +136,12 @@ Object.defineProperty(exports, 'dedent', {
|
|
|
134
136
|
return dedent;
|
|
135
137
|
}
|
|
136
138
|
});
|
|
139
|
+
Object.defineProperty(exports, 'dedentRaw', {
|
|
140
|
+
enumerable: true,
|
|
141
|
+
get: function () {
|
|
142
|
+
return dedentRaw;
|
|
143
|
+
}
|
|
144
|
+
});
|
|
137
145
|
Object.defineProperty(exports, 'toCamelCase', {
|
|
138
146
|
enumerable: true,
|
|
139
147
|
get: function () {
|
package/dist/string.cjs
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
const require_string = require('./string-
|
|
1
|
+
const require_string = require('./string-Ki9Q9jVP.cjs');
|
|
2
2
|
|
|
3
3
|
exports.capitalize = require_string.capitalize
|
|
4
4
|
exports.dedent = require_string.dedent
|
|
5
|
+
exports.dedentRaw = require_string.dedentRaw
|
|
5
6
|
exports.toCamelCase = require_string.toCamelCase
|
|
6
7
|
exports.toKebabCase = require_string.toKebabCase
|
|
7
8
|
exports.toPascalCase = require_string.toPascalCase
|
|
@@ -73,10 +73,9 @@ declare function toSnakeCase(str: string): string;
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Removes leading and trailing whitespace from each line of a string
|
|
76
|
-
* @param {TemplateStringsArray | string}
|
|
76
|
+
* @param {TemplateStringsArray | string} literals - The string to dedent
|
|
77
77
|
* @returns {string} The dedented string
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
78
|
+
* @example ```ts
|
|
80
79
|
* dedent`
|
|
81
80
|
* This is a test.
|
|
82
81
|
* This is another line.
|
|
@@ -84,7 +83,24 @@ declare function toSnakeCase(str: string): string;
|
|
|
84
83
|
* // "This is a test.\nThis is another line."
|
|
85
84
|
* ```
|
|
86
85
|
*/
|
|
87
|
-
declare function dedent(
|
|
86
|
+
declare function dedent(literals: string): string;
|
|
87
|
+
declare function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
88
|
+
declare namespace dedent {
|
|
89
|
+
var raw: typeof dedentRaw;
|
|
90
|
+
} /**
|
|
91
|
+
* Removes leading and trailing whitespace from each line of a string
|
|
92
|
+
* @param {TemplateStringsArray | string} literals - The string to dedent
|
|
93
|
+
* @returns {string} The dedented string
|
|
94
|
+
* @example ```ts
|
|
95
|
+
* dedent`
|
|
96
|
+
* This is a test.
|
|
97
|
+
* This is another line.
|
|
98
|
+
* `
|
|
99
|
+
* // "This is a test.\nThis is another line."
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
88
102
|
|
|
103
|
+
declare function dedentRaw(literals: string): string;
|
|
104
|
+
declare function dedentRaw(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
89
105
|
//#endregion
|
|
90
|
-
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
106
|
+
export { capitalize as capitalize$1, dedent as dedent$1, dedentRaw as dedentRaw$1, toCamelCase as toCamelCase$1, toKebabCase as toKebabCase$1, toPascalCase as toPascalCase$1, toSnakeCase as toSnakeCase$1 };
|
|
@@ -73,10 +73,9 @@ declare function toSnakeCase(str: string): string;
|
|
|
73
73
|
|
|
74
74
|
/**
|
|
75
75
|
* Removes leading and trailing whitespace from each line of a string
|
|
76
|
-
* @param {TemplateStringsArray | string}
|
|
76
|
+
* @param {TemplateStringsArray | string} literals - The string to dedent
|
|
77
77
|
* @returns {string} The dedented string
|
|
78
|
-
* @example
|
|
79
|
-
* ```ts
|
|
78
|
+
* @example ```ts
|
|
80
79
|
* dedent`
|
|
81
80
|
* This is a test.
|
|
82
81
|
* This is another line.
|
|
@@ -84,7 +83,24 @@ declare function toSnakeCase(str: string): string;
|
|
|
84
83
|
* // "This is a test.\nThis is another line."
|
|
85
84
|
* ```
|
|
86
85
|
*/
|
|
87
|
-
declare function dedent(
|
|
86
|
+
declare function dedent(literals: string): string;
|
|
87
|
+
declare function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
88
|
+
declare namespace dedent {
|
|
89
|
+
var raw: typeof dedentRaw;
|
|
90
|
+
} /**
|
|
91
|
+
* Removes leading and trailing whitespace from each line of a string
|
|
92
|
+
* @param {TemplateStringsArray | string} literals - The string to dedent
|
|
93
|
+
* @returns {string} The dedented string
|
|
94
|
+
* @example ```ts
|
|
95
|
+
* dedent`
|
|
96
|
+
* This is a test.
|
|
97
|
+
* This is another line.
|
|
98
|
+
* `
|
|
99
|
+
* // "This is a test.\nThis is another line."
|
|
100
|
+
* ```
|
|
101
|
+
*/
|
|
88
102
|
|
|
103
|
+
declare function dedentRaw(literals: string): string;
|
|
104
|
+
declare function dedentRaw(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
89
105
|
//#endregion
|
|
90
|
-
export { capitalize
|
|
106
|
+
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-
|
|
2
|
-
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
1
|
+
import { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-olvwSa1o.cjs";
|
|
2
|
+
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { capitalize$1 as capitalize, dedent$1 as dedent, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-
|
|
2
|
-
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
1
|
+
import { capitalize$1 as capitalize, dedent$1 as dedent, dedentRaw$1 as dedentRaw, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-BgvLaGcg.js";
|
|
2
|
+
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-
|
|
1
|
+
import { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-DgqE1XDy.js";
|
|
2
2
|
|
|
3
|
-
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
3
|
+
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@luxass/utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.0",
|
|
4
4
|
"description": "A collection of utilities for JavaScript/TypeScript",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"author": {
|
|
@@ -76,6 +76,7 @@
|
|
|
76
76
|
"devDependencies": {
|
|
77
77
|
"@luxass/eslint-config": "^4.18.1",
|
|
78
78
|
"@types/node": "^22.15.2",
|
|
79
|
+
"@vitest/coverage-v8": "3.1.2",
|
|
79
80
|
"eslint": "^9.25.1",
|
|
80
81
|
"eslint-plugin-format": "^1.0.1",
|
|
81
82
|
"publint": "^0.3.12",
|