@luxass/utils 1.4.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 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-CkqQ4Tys.cjs');
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-DbrXP95T.cjs";
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-Dv6EVJz4.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-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-C8IOUSBw.js";
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 };
@@ -94,10 +94,18 @@ function toSnakeCase(str) {
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
96
  function dedent(strings, ...values) {
97
- const raw = typeof strings === "string" ? [strings] : strings.raw;
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;
98
106
  let result = "";
99
- for (let i = 0; i < raw.length; i++) {
100
- const next = raw[i];
107
+ for (let i = 0; i < _raw.length; i++) {
108
+ const next = _raw[i];
101
109
  result += next;
102
110
  if (i < values.length) result += values[i];
103
111
  }
@@ -114,4 +122,4 @@ function dedent(strings, ...values) {
114
122
  }
115
123
 
116
124
  //#endregion
117
- export { capitalize, dedent, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
125
+ export { capitalize, dedent, dedentRaw, toCamelCase, toKebabCase, toPascalCase, toSnakeCase };
@@ -96,10 +96,18 @@ function toSnakeCase(str) {
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
98
  function dedent(strings, ...values) {
99
- const raw = typeof strings === "string" ? [strings] : strings.raw;
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;
100
108
  let result = "";
101
- for (let i = 0; i < raw.length; i++) {
102
- const next = raw[i];
109
+ for (let i = 0; i < _raw.length; i++) {
110
+ const next = _raw[i];
103
111
  result += next;
104
112
  if (i < values.length) result += values[i];
105
113
  }
@@ -128,6 +136,12 @@ Object.defineProperty(exports, 'dedent', {
128
136
  return dedent;
129
137
  }
130
138
  });
139
+ Object.defineProperty(exports, 'dedentRaw', {
140
+ enumerable: true,
141
+ get: function () {
142
+ return dedentRaw;
143
+ }
144
+ });
131
145
  Object.defineProperty(exports, 'toCamelCase', {
132
146
  enumerable: true,
133
147
  get: function () {
package/dist/string.cjs CHANGED
@@ -1,7 +1,8 @@
1
- const require_string = require('./string-CkqQ4Tys.cjs');
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
@@ -76,15 +76,31 @@ declare function toSnakeCase(str: string): string;
76
76
  * @param {TemplateStringsArray | string} literals - The string to dedent
77
77
  * @returns {string} The dedented string
78
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
- ```
79
+ * dedent`
80
+ * This is a test.
81
+ * This is another line.
82
+ * `
83
+ * // "This is a test.\nThis is another line."
84
+ * ```
85
85
  */
86
86
  declare function dedent(literals: string): string;
87
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 as capitalize$1, dedent as dedent$1, toCamelCase as toCamelCase$1, toKebabCase as toKebabCase$1, toPascalCase as toPascalCase$1, toSnakeCase as toSnakeCase$1 };
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 };
@@ -76,15 +76,31 @@ declare function toSnakeCase(str: string): string;
76
76
  * @param {TemplateStringsArray | string} literals - The string to dedent
77
77
  * @returns {string} The dedented string
78
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
- ```
79
+ * dedent`
80
+ * This is a test.
81
+ * This is another line.
82
+ * `
83
+ * // "This is a test.\nThis is another line."
84
+ * ```
85
85
  */
86
86
  declare function dedent(literals: string): string;
87
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, 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-DbrXP95T.cjs";
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-Dv6EVJz4.js";
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-C8IOUSBw.js";
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.4.0",
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",