@luxass/utils 1.3.0 → 1.4.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-C8IOUSBw.js} +9 -15
- package/dist/{string-Bsjh7sy7.cjs → string-CkqQ4Tys.cjs} +9 -15
- package/dist/string.cjs +1 -1
- package/dist/{string.d-DNAFYlGi.d.cts → string.d-DbrXP95T.d.cts} +10 -10
- package/dist/{string.d-CkCHrMO0.d.ts → string.d-Dv6EVJz4.d.ts} +10 -10
- package/dist/string.d.cts +1 -1
- package/dist/string.d.ts +1 -1
- package/dist/string.js +1 -1
- package/package.json +1 -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-CkqQ4Tys.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-DbrXP95T.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-Dv6EVJz4.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-C8IOUSBw.js";
|
|
4
4
|
|
|
5
5
|
export { capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
@@ -93,21 +93,15 @@ 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
|
-
* // "This is a test.\nThis is another line."
|
|
107
|
-
* ```
|
|
108
|
-
*/
|
|
109
|
-
function dedent(str) {
|
|
110
|
-
const lines = ((typeof str === "string" ? str : str[0]) ?? "").split("\n");
|
|
96
|
+
function dedent(strings, ...values) {
|
|
97
|
+
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
|
98
|
+
let result = "";
|
|
99
|
+
for (let i = 0; i < raw.length; i++) {
|
|
100
|
+
const next = raw[i];
|
|
101
|
+
result += next;
|
|
102
|
+
if (i < values.length) result += values[i];
|
|
103
|
+
}
|
|
104
|
+
const lines = result.split("\n");
|
|
111
105
|
const whitespaceLines = lines.map((line) => FULL_WHITESPACE_RE.test(line));
|
|
112
106
|
const commonIndent = lines.reduce((min, line, idx) => {
|
|
113
107
|
if (whitespaceLines[idx]) return min;
|
|
@@ -95,21 +95,15 @@ 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
|
-
* // "This is a test.\nThis is another line."
|
|
109
|
-
* ```
|
|
110
|
-
*/
|
|
111
|
-
function dedent(str) {
|
|
112
|
-
const lines = ((typeof str === "string" ? str : str[0]) ?? "").split("\n");
|
|
98
|
+
function dedent(strings, ...values) {
|
|
99
|
+
const raw = typeof strings === "string" ? [strings] : strings.raw;
|
|
100
|
+
let result = "";
|
|
101
|
+
for (let i = 0; i < raw.length; i++) {
|
|
102
|
+
const next = raw[i];
|
|
103
|
+
result += next;
|
|
104
|
+
if (i < values.length) result += values[i];
|
|
105
|
+
}
|
|
106
|
+
const lines = result.split("\n");
|
|
113
107
|
const whitespaceLines = lines.map((line) => FULL_WHITESPACE_RE.test(line));
|
|
114
108
|
const commonIndent = lines.reduce((min, line, idx) => {
|
|
115
109
|
if (whitespaceLines[idx]) return min;
|
package/dist/string.cjs
CHANGED
|
@@ -73,18 +73,18 @@ 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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* ```
|
|
78
|
+
* @example ```ts
|
|
79
|
+
dedent`
|
|
80
|
+
This is a test.
|
|
81
|
+
This is another line.
|
|
82
|
+
`
|
|
83
|
+
// "This is a test.\nThis is another line."
|
|
84
|
+
```
|
|
86
85
|
*/
|
|
87
|
-
declare function dedent(
|
|
86
|
+
declare function dedent(literals: string): string;
|
|
87
|
+
declare function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
88
88
|
|
|
89
89
|
//#endregion
|
|
90
90
|
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
@@ -73,18 +73,18 @@ 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
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
* ```
|
|
78
|
+
* @example ```ts
|
|
79
|
+
dedent`
|
|
80
|
+
This is a test.
|
|
81
|
+
This is another line.
|
|
82
|
+
`
|
|
83
|
+
// "This is a test.\nThis is another line."
|
|
84
|
+
```
|
|
86
85
|
*/
|
|
87
|
-
declare function dedent(
|
|
86
|
+
declare function dedent(literals: string): string;
|
|
87
|
+
declare function dedent(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
88
88
|
|
|
89
89
|
//#endregion
|
|
90
90
|
export { capitalize as capitalize$1, dedent as dedent$1, toCamelCase as toCamelCase$1, toKebabCase as toKebabCase$1, toPascalCase as toPascalCase$1, toSnakeCase as toSnakeCase$1 };
|
package/dist/string.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-
|
|
1
|
+
import { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-DbrXP95T.cjs";
|
|
2
2
|
export { capitalize, dedent, 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-
|
|
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-Dv6EVJz4.js";
|
|
2
2
|
export { capitalize, dedent, 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, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-C8IOUSBw.js";
|
|
2
2
|
|
|
3
3
|
export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|