es-toolkit 1.25.2-dev.824 → 1.25.2-dev.825

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.
@@ -79,6 +79,7 @@ export { lowerFirst } from '../string/lowerFirst.mjs';
79
79
  export { pascalCase } from '../string/pascalCase.mjs';
80
80
  export { unescape } from '../string/unescape.mjs';
81
81
  export { upperFirst } from '../string/upperFirst.mjs';
82
+ export { invariant } from '../util/invariant.mjs';
82
83
  export { castArray } from './array/castArray.mjs';
83
84
  export { chunk } from './array/chunk.mjs';
84
85
  export { compact } from './array/compact.mjs';
@@ -79,6 +79,7 @@ export { lowerFirst } from '../string/lowerFirst.js';
79
79
  export { pascalCase } from '../string/pascalCase.js';
80
80
  export { unescape } from '../string/unescape.js';
81
81
  export { upperFirst } from '../string/upperFirst.js';
82
+ export { invariant } from '../util/invariant.js';
82
83
  export { castArray } from './array/castArray.js';
83
84
  export { chunk } from './array/chunk.js';
84
85
  export { compact } from './array/compact.js';
@@ -12,6 +12,7 @@ const toMerged = require('../_chunk/toMerged-wNz52b.js');
12
12
  const isPlainObject$1 = require('../_chunk/isPlainObject-octpoD.js');
13
13
  const isWeakSet$1 = require('../_chunk/isWeakSet-D8h8bS.js');
14
14
  const upperFirst = require('../_chunk/upperFirst-BUECmK.js');
15
+ const util_index = require('../util/index.js');
15
16
 
16
17
  function castArray(value) {
17
18
  if (arguments.length === 0) {
@@ -2443,6 +2444,7 @@ exports.lowerFirst = upperFirst.lowerFirst;
2443
2444
  exports.pascalCase = upperFirst.pascalCase;
2444
2445
  exports.unescape = upperFirst.unescape;
2445
2446
  exports.upperFirst = upperFirst.upperFirst;
2447
+ exports.invariant = util_index.invariant;
2446
2448
  exports.ary = ary;
2447
2449
  exports.attempt = attempt;
2448
2450
  exports.before = before;
@@ -81,6 +81,7 @@ export { lowerFirst } from '../string/lowerFirst.mjs';
81
81
  export { pascalCase } from '../string/pascalCase.mjs';
82
82
  export { unescape } from '../string/unescape.mjs';
83
83
  export { upperFirst } from '../string/upperFirst.mjs';
84
+ export { invariant } from '../util/invariant.mjs';
84
85
  export { castArray } from './array/castArray.mjs';
85
86
  export { chunk } from './array/chunk.mjs';
86
87
  export { compact } from './array/compact.mjs';
package/dist/index.d.mts CHANGED
@@ -148,3 +148,4 @@ export { trimStart } from './string/trimStart.mjs';
148
148
  export { unescape } from './string/unescape.mjs';
149
149
  export { upperCase } from './string/upperCase.mjs';
150
150
  export { upperFirst } from './string/upperFirst.mjs';
151
+ export { invariant } from './util/invariant.mjs';
package/dist/index.d.ts CHANGED
@@ -148,3 +148,4 @@ export { trimStart } from './string/trimStart.js';
148
148
  export { unescape } from './string/unescape.js';
149
149
  export { upperCase } from './string/upperCase.js';
150
150
  export { upperFirst } from './string/upperFirst.js';
151
+ export { invariant } from './util/invariant.js';
package/dist/index.js CHANGED
@@ -18,6 +18,7 @@ const predicate_index = require('./predicate/index.js');
18
18
  const isPlainObject = require('./_chunk/isPlainObject-octpoD.js');
19
19
  const upperFirst = require('./_chunk/upperFirst-BUECmK.js');
20
20
  const string_index = require('./string/index.js');
21
+ const util_index = require('./util/index.js');
21
22
 
22
23
 
23
24
 
@@ -173,3 +174,4 @@ exports.unescape = upperFirst.unescape;
173
174
  exports.upperCase = upperFirst.upperCase;
174
175
  exports.upperFirst = upperFirst.upperFirst;
175
176
  exports.startCase = string_index.startCase;
177
+ exports.invariant = util_index.invariant;
package/dist/index.mjs CHANGED
@@ -148,3 +148,4 @@ export { trimStart } from './string/trimStart.mjs';
148
148
  export { unescape } from './string/unescape.mjs';
149
149
  export { upperCase } from './string/upperCase.mjs';
150
150
  export { upperFirst } from './string/upperFirst.mjs';
151
+ export { invariant } from './util/invariant.mjs';
@@ -0,0 +1 @@
1
+ export { invariant } from './invariant.mjs';
@@ -0,0 +1 @@
1
+ export { invariant } from './invariant.js';
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
+
5
+ function invariant(condition, message) {
6
+ if (condition) {
7
+ return;
8
+ }
9
+ throw new Error(message);
10
+ }
11
+
12
+ exports.invariant = invariant;
@@ -0,0 +1 @@
1
+ export { invariant } from './invariant.mjs';
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
3
+ *
4
+ * @param {unknown} condition - The condition to evaluate.
5
+ * @param {string} [message] - The error message to throw if the condition is false.
6
+ * @returns {void} Returns void if the condition is true.
7
+ * @throws {Error} Throws an error if the condition is false.
8
+ *
9
+ * @example
10
+ * // This call will succeed without any errors
11
+ * invariant(true, 'This should not throw');
12
+ *
13
+ * // This call will fail and throw an error with the message 'This should throw'
14
+ * invariant(false, 'This should throw');
15
+ *
16
+ * // Example of using invariant with a condition
17
+ * invariant(condition, 'Expected condition is false');
18
+ *
19
+ * // Ensure that the value is neither null nor undefined
20
+ * invariant(value !== null && value !== undefined, 'Value should not be null or undefined');
21
+ *
22
+ * // Example of using invariant to check if a number is positive
23
+ * invariant(number > 0, 'Number must be positive');
24
+ */
25
+ declare function invariant(condition: unknown, message: string): asserts condition;
26
+
27
+ export { invariant };
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Asserts that a given condition is true. If the condition is false, an error is thrown with the provided message.
3
+ *
4
+ * @param {unknown} condition - The condition to evaluate.
5
+ * @param {string} [message] - The error message to throw if the condition is false.
6
+ * @returns {void} Returns void if the condition is true.
7
+ * @throws {Error} Throws an error if the condition is false.
8
+ *
9
+ * @example
10
+ * // This call will succeed without any errors
11
+ * invariant(true, 'This should not throw');
12
+ *
13
+ * // This call will fail and throw an error with the message 'This should throw'
14
+ * invariant(false, 'This should throw');
15
+ *
16
+ * // Example of using invariant with a condition
17
+ * invariant(condition, 'Expected condition is false');
18
+ *
19
+ * // Ensure that the value is neither null nor undefined
20
+ * invariant(value !== null && value !== undefined, 'Value should not be null or undefined');
21
+ *
22
+ * // Example of using invariant to check if a number is positive
23
+ * invariant(number > 0, 'Number must be positive');
24
+ */
25
+ declare function invariant(condition: unknown, message: string): asserts condition;
26
+
27
+ export { invariant };
@@ -0,0 +1,8 @@
1
+ function invariant(condition, message) {
2
+ if (condition) {
3
+ return;
4
+ }
5
+ throw new Error(message);
6
+ }
7
+
8
+ export { invariant };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "es-toolkit",
3
3
  "description": "A state-of-the-art, high-performance JavaScript utility library with a small bundle size and strong type annotations.",
4
- "version": "1.25.2-dev.824+a000c597",
4
+ "version": "1.25.2-dev.825+b4e384de",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -95,6 +95,16 @@
95
95
  "default": "./dist/string/index.js"
96
96
  }
97
97
  },
98
+ "./util": {
99
+ "import": {
100
+ "types": "./dist/util/index.d.mts",
101
+ "default": "./dist/util/index.mjs"
102
+ },
103
+ "require": {
104
+ "types": "./dist/util/index.d.ts",
105
+ "default": "./dist/util/index.js"
106
+ }
107
+ },
98
108
  "./compat": {
99
109
  "import": {
100
110
  "types": "./dist/compat/index.d.mts",
@@ -198,6 +208,16 @@
198
208
  "default": "./dist/string/index.js"
199
209
  }
200
210
  },
211
+ "./util": {
212
+ "import": {
213
+ "types": "./dist/util/index.d.mts",
214
+ "default": "./dist/util/index.mjs"
215
+ },
216
+ "require": {
217
+ "types": "./dist/util/index.d.ts",
218
+ "default": "./dist/util/index.js"
219
+ }
220
+ },
201
221
  "./compat": {
202
222
  "import": {
203
223
  "types": "./dist/compat/index.d.mts",
package/util.d.ts ADDED
@@ -0,0 +1 @@
1
+ export * from './dist/util';