@luxass/utils 1.5.0 → 1.6.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/index.cjs +3 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/{string-Ki9Q9jVP.cjs → string-CxNDb3Ui.cjs} +22 -0
- package/dist/{string-DgqE1XDy.js → string-bY1lSRQs.js} +17 -1
- package/dist/string.cjs +2 -1
- package/dist/{string.d-olvwSa1o.d.cts → string.d-BSY3kSBV.d.ts} +15 -2
- package/dist/{string.d-BgvLaGcg.d.ts → string.d-Dm-Z_ZP2.d.cts} +15 -2
- package/dist/string.d.cts +2 -2
- package/dist/string.d.ts +2 -2
- package/dist/string.js +2 -2
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
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-CxNDb3Ui.cjs');
|
|
4
4
|
|
|
5
5
|
exports.capitalize = require_string.capitalize
|
|
6
6
|
exports.clamp = require_number.clamp
|
|
7
7
|
exports.dedent = require_string.dedent
|
|
8
|
+
exports.dedentRaw = require_string.dedentRaw
|
|
8
9
|
exports.isNotNull = require_guards.isNotNull
|
|
9
10
|
exports.isNotNullish = require_guards.isNotNullish
|
|
10
11
|
exports.isNotUndefined = require_guards.isNotUndefined
|
|
11
12
|
exports.isTruthy = require_guards.isTruthy
|
|
13
|
+
exports.sanitizeIdentifier = require_string.sanitizeIdentifier
|
|
12
14
|
exports.toCamelCase = require_string.toCamelCase
|
|
13
15
|
exports.toKebabCase = require_string.toKebabCase
|
|
14
16
|
exports.toPascalCase = require_string.toPascalCase
|
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, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-Dm-Z_ZP2.cjs";
|
|
4
4
|
import { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish } from "./types.d-fcYBBT6c.cjs";
|
|
5
|
-
export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish, capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
5
|
+
export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish, capitalize, clamp, dedent, dedentRaw, isNotNull, isNotNullish, isNotUndefined, isTruthy, sanitizeIdentifier, 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, dedentRaw$1 as dedentRaw, sanitizeIdentifier$1 as sanitizeIdentifier, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-BSY3kSBV.js";
|
|
4
4
|
import { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish } from "./types.d-BcKIY6l3.js";
|
|
5
|
-
export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish, capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
5
|
+
export { Arrayable, Awaitable, ElementOf, InferArguments, Nullable, Nullish, capitalize, clamp, dedent, dedentRaw, isNotNull, isNotNullish, isNotUndefined, isTruthy, sanitizeIdentifier, 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, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-bY1lSRQs.js";
|
|
4
4
|
|
|
5
|
-
export { capitalize, clamp, dedent, isNotNull, isNotNullish, isNotUndefined, isTruthy, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
5
|
+
export { capitalize, clamp, dedent, dedentRaw, isNotNull, isNotNullish, isNotUndefined, isTruthy, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
@@ -122,6 +122,22 @@ function internal_dedent(strings, values, raw = false) {
|
|
|
122
122
|
const lastNonWhitespaceLine = whitespaceLines.lastIndexOf(false);
|
|
123
123
|
return lines.slice(firstNonWhitespaceLine >= 0 ? firstNonWhitespaceLine : 0, lastNonWhitespaceLine >= 0 ? lastNonWhitespaceLine + 1 : lines.length).map((line) => line.slice(commonIndent)).join("\n");
|
|
124
124
|
}
|
|
125
|
+
/**
|
|
126
|
+
* Ensures a string is a valid JavaScript identifier by prefixing with an underscore if necessary
|
|
127
|
+
* @param {string} str - The string to sanitize
|
|
128
|
+
* @returns {string} A valid JavaScript identifier
|
|
129
|
+
* @example
|
|
130
|
+
* ```ts
|
|
131
|
+
* sanitizeIdentifier("validName") // "validName"
|
|
132
|
+
* sanitizeIdentifier("123invalid") // "_123invalid"
|
|
133
|
+
* sanitizeIdentifier("$valid") // "$valid"
|
|
134
|
+
* sanitizeIdentifier("_valid") // "_valid"
|
|
135
|
+
* ```
|
|
136
|
+
*/
|
|
137
|
+
function sanitizeIdentifier(str) {
|
|
138
|
+
const cleaned = str.replace(/[^\w$]/g, "");
|
|
139
|
+
return /^[A-Z_$]/i.test(cleaned) ? cleaned : `_${cleaned}`;
|
|
140
|
+
}
|
|
125
141
|
|
|
126
142
|
//#endregion
|
|
127
143
|
Object.defineProperty(exports, 'capitalize', {
|
|
@@ -142,6 +158,12 @@ Object.defineProperty(exports, 'dedentRaw', {
|
|
|
142
158
|
return dedentRaw;
|
|
143
159
|
}
|
|
144
160
|
});
|
|
161
|
+
Object.defineProperty(exports, 'sanitizeIdentifier', {
|
|
162
|
+
enumerable: true,
|
|
163
|
+
get: function () {
|
|
164
|
+
return sanitizeIdentifier;
|
|
165
|
+
}
|
|
166
|
+
});
|
|
145
167
|
Object.defineProperty(exports, 'toCamelCase', {
|
|
146
168
|
enumerable: true,
|
|
147
169
|
get: function () {
|
|
@@ -120,6 +120,22 @@ function internal_dedent(strings, values, raw = false) {
|
|
|
120
120
|
const lastNonWhitespaceLine = whitespaceLines.lastIndexOf(false);
|
|
121
121
|
return lines.slice(firstNonWhitespaceLine >= 0 ? firstNonWhitespaceLine : 0, lastNonWhitespaceLine >= 0 ? lastNonWhitespaceLine + 1 : lines.length).map((line) => line.slice(commonIndent)).join("\n");
|
|
122
122
|
}
|
|
123
|
+
/**
|
|
124
|
+
* Ensures a string is a valid JavaScript identifier by prefixing with an underscore if necessary
|
|
125
|
+
* @param {string} str - The string to sanitize
|
|
126
|
+
* @returns {string} A valid JavaScript identifier
|
|
127
|
+
* @example
|
|
128
|
+
* ```ts
|
|
129
|
+
* sanitizeIdentifier("validName") // "validName"
|
|
130
|
+
* sanitizeIdentifier("123invalid") // "_123invalid"
|
|
131
|
+
* sanitizeIdentifier("$valid") // "$valid"
|
|
132
|
+
* sanitizeIdentifier("_valid") // "_valid"
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
function sanitizeIdentifier(str) {
|
|
136
|
+
const cleaned = str.replace(/[^\w$]/g, "");
|
|
137
|
+
return /^[A-Z_$]/i.test(cleaned) ? cleaned : `_${cleaned}`;
|
|
138
|
+
}
|
|
123
139
|
|
|
124
140
|
//#endregion
|
|
125
|
-
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
141
|
+
export { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.cjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
const require_string = require('./string-
|
|
1
|
+
const require_string = require('./string-CxNDb3Ui.cjs');
|
|
2
2
|
|
|
3
3
|
exports.capitalize = require_string.capitalize
|
|
4
4
|
exports.dedent = require_string.dedent
|
|
5
5
|
exports.dedentRaw = require_string.dedentRaw
|
|
6
|
+
exports.sanitizeIdentifier = require_string.sanitizeIdentifier
|
|
6
7
|
exports.toCamelCase = require_string.toCamelCase
|
|
7
8
|
exports.toKebabCase = require_string.toKebabCase
|
|
8
9
|
exports.toPascalCase = require_string.toPascalCase
|
|
@@ -101,6 +101,19 @@ declare namespace dedent {
|
|
|
101
101
|
*/
|
|
102
102
|
|
|
103
103
|
declare function dedentRaw(literals: string): string;
|
|
104
|
-
declare function dedentRaw(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
104
|
+
declare function dedentRaw(strings: TemplateStringsArray, ...values: unknown[]): string; /**
|
|
105
|
+
* Ensures a string is a valid JavaScript identifier by prefixing with an underscore if necessary
|
|
106
|
+
* @param {string} str - The string to sanitize
|
|
107
|
+
* @returns {string} A valid JavaScript identifier
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* sanitizeIdentifier("validName") // "validName"
|
|
111
|
+
* sanitizeIdentifier("123invalid") // "_123invalid"
|
|
112
|
+
* sanitizeIdentifier("$valid") // "$valid"
|
|
113
|
+
* sanitizeIdentifier("_valid") // "_valid"
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
declare function sanitizeIdentifier(str: string): string;
|
|
105
118
|
//#endregion
|
|
106
|
-
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
119
|
+
export { capitalize as capitalize$1, dedent as dedent$1, dedentRaw as dedentRaw$1, sanitizeIdentifier as sanitizeIdentifier$1, toCamelCase as toCamelCase$1, toKebabCase as toKebabCase$1, toPascalCase as toPascalCase$1, toSnakeCase as toSnakeCase$1 };
|
|
@@ -101,6 +101,19 @@ declare namespace dedent {
|
|
|
101
101
|
*/
|
|
102
102
|
|
|
103
103
|
declare function dedentRaw(literals: string): string;
|
|
104
|
-
declare function dedentRaw(strings: TemplateStringsArray, ...values: unknown[]): string;
|
|
104
|
+
declare function dedentRaw(strings: TemplateStringsArray, ...values: unknown[]): string; /**
|
|
105
|
+
* Ensures a string is a valid JavaScript identifier by prefixing with an underscore if necessary
|
|
106
|
+
* @param {string} str - The string to sanitize
|
|
107
|
+
* @returns {string} A valid JavaScript identifier
|
|
108
|
+
* @example
|
|
109
|
+
* ```ts
|
|
110
|
+
* sanitizeIdentifier("validName") // "validName"
|
|
111
|
+
* sanitizeIdentifier("123invalid") // "_123invalid"
|
|
112
|
+
* sanitizeIdentifier("$valid") // "$valid"
|
|
113
|
+
* sanitizeIdentifier("_valid") // "_valid"
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
116
|
+
|
|
117
|
+
declare function sanitizeIdentifier(str: string): string;
|
|
105
118
|
//#endregion
|
|
106
|
-
export { capitalize
|
|
119
|
+
export { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.d.cts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-
|
|
2
|
-
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
1
|
+
import { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string.d-Dm-Z_ZP2.cjs";
|
|
2
|
+
export { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
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-
|
|
2
|
-
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
1
|
+
import { capitalize$1 as capitalize, dedent$1 as dedent, dedentRaw$1 as dedentRaw, sanitizeIdentifier$1 as sanitizeIdentifier, toCamelCase$1 as toCamelCase, toKebabCase$1 as toKebabCase, toPascalCase$1 as toPascalCase, toSnakeCase$1 as toSnakeCase } from "./string.d-BSY3kSBV.js";
|
|
2
|
+
export { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
package/dist/string.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-
|
|
1
|
+
import { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase } from "./string-bY1lSRQs.js";
|
|
2
2
|
|
|
3
|
-
export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|
|
3
|
+
export { capitalize, dedent, dedentRaw, sanitizeIdentifier, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
|