es-toolkit 1.13.1-dev.385 → 1.13.1-dev.387

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.
@@ -86,7 +86,6 @@ export { isArrayLike } from '../predicate/isArrayLike.mjs';
86
86
  export { isPrimitive } from '../predicate/isPrimitive.mjs';
87
87
  export { isObjectLike } from '../predicate/isObjectLike.mjs';
88
88
  export { isArguments } from '../predicate/isArguments.mjs';
89
- export { isBoolean } from '../predicate/isBoolean.mjs';
90
89
  export { delay } from '../promise/delay.mjs';
91
90
  export { withTimeout } from '../promise/withTimeout.mjs';
92
91
  export { camelCase } from '../string/camelCase.mjs';
@@ -112,6 +111,7 @@ export { property } from './object/property.mjs';
112
111
  export { mapKeys } from './object/mapKeys.mjs';
113
112
  export { isPlainObject } from './predicate/isPlainObject.mjs';
114
113
  export { isArray } from './predicate/isArray.mjs';
114
+ export { isBoolean } from './predicate/isBoolean.mjs';
115
115
  export { isTypedArray } from './predicate/isTypedArray.mjs';
116
116
  export { isMatch } from './predicate/isMatch.mjs';
117
117
  export { matches } from './predicate/matches.mjs';
@@ -86,7 +86,6 @@ export { isArrayLike } from '../predicate/isArrayLike.js';
86
86
  export { isPrimitive } from '../predicate/isPrimitive.js';
87
87
  export { isObjectLike } from '../predicate/isObjectLike.js';
88
88
  export { isArguments } from '../predicate/isArguments.js';
89
- export { isBoolean } from '../predicate/isBoolean.js';
90
89
  export { delay } from '../promise/delay.js';
91
90
  export { withTimeout } from '../promise/withTimeout.js';
92
91
  export { camelCase } from '../string/camelCase.js';
@@ -112,6 +111,7 @@ export { property } from './object/property.js';
112
111
  export { mapKeys } from './object/mapKeys.js';
113
112
  export { isPlainObject } from './predicate/isPlainObject.js';
114
113
  export { isArray } from './predicate/isArray.js';
114
+ export { isBoolean } from './predicate/isBoolean.js';
115
115
  export { isTypedArray } from './predicate/isTypedArray.js';
116
116
  export { isMatch } from './predicate/isMatch.js';
117
117
  export { matches } from './predicate/matches.js';
@@ -2,13 +2,13 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const size = require('../_chunk/size-BlsJKU.js');
5
+ const size = require('../_chunk/size-gkSUOE.js');
6
6
  const promise_index = require('../_chunk/index-CwRt_M.js');
7
7
  const function_index = require('../function/index.js');
8
8
  const math_index = require('../math/index.js');
9
9
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
10
10
  const object_index = require('../object/index.js');
11
- const predicate_index = require('../predicate/index.js');
11
+ const isArguments = require('../_chunk/isArguments-B5Iphy.js');
12
12
  const isNil = require('../_chunk/isNil-CYi_Vh.js');
13
13
  const isTypedArray$1 = require('../_chunk/isTypedArray-BBEkFl.js');
14
14
  const string_index = require('../string/index.js');
@@ -300,6 +300,16 @@ function isArray(value) {
300
300
  return Array.isArray(value);
301
301
  }
302
302
 
303
+ function isBoolean(x) {
304
+ if (x === true || x === false) {
305
+ return true;
306
+ }
307
+ if (typeof x === 'object' && x != null && isArguments.getTag(x) === '[object Boolean]') {
308
+ return true;
309
+ }
310
+ return false;
311
+ }
312
+
303
313
  function isTypedArray(x) {
304
314
  return isTypedArray$1.isTypedArray(x);
305
315
  }
@@ -521,16 +531,15 @@ exports.omit = object_index.omit;
521
531
  exports.omitBy = object_index.omitBy;
522
532
  exports.pick = object_index.pick;
523
533
  exports.pickBy = object_index.pickBy;
524
- exports.isArguments = predicate_index.isArguments;
525
- exports.isArrayLike = predicate_index.isArrayLike;
526
- exports.isBoolean = predicate_index.isBoolean;
527
- exports.isEqual = predicate_index.isEqual;
528
- exports.isFunction = predicate_index.isFunction;
529
- exports.isLength = predicate_index.isLength;
530
- exports.isNotNil = predicate_index.isNotNil;
531
- exports.isNull = predicate_index.isNull;
532
- exports.isObjectLike = predicate_index.isObjectLike;
533
- exports.isUndefined = predicate_index.isUndefined;
534
+ exports.isArguments = isArguments.isArguments;
535
+ exports.isArrayLike = isArguments.isArrayLike;
536
+ exports.isEqual = isArguments.isEqual;
537
+ exports.isFunction = isArguments.isFunction;
538
+ exports.isLength = isArguments.isLength;
539
+ exports.isNotNil = isArguments.isNotNil;
540
+ exports.isNull = isArguments.isNull;
541
+ exports.isObjectLike = isArguments.isObjectLike;
542
+ exports.isUndefined = isArguments.isUndefined;
534
543
  exports.isNil = isNil.isNil;
535
544
  exports.isPrimitive = isTypedArray$1.isPrimitive;
536
545
  exports.camelCase = string_index.camelCase;
@@ -552,6 +561,7 @@ exports.flattenDeep = flattenDeep;
552
561
  exports.flattenDepth = flattenDepth;
553
562
  exports.get = get;
554
563
  exports.isArray = isArray;
564
+ exports.isBoolean = isBoolean;
555
565
  exports.isMatch = isMatch;
556
566
  exports.isPlainObject = isPlainObject;
557
567
  exports.isTypedArray = isTypedArray;
@@ -86,7 +86,6 @@ export { isArrayLike } from '../predicate/isArrayLike.mjs';
86
86
  export { isPrimitive } from '../predicate/isPrimitive.mjs';
87
87
  export { isObjectLike } from '../predicate/isObjectLike.mjs';
88
88
  export { isArguments } from '../predicate/isArguments.mjs';
89
- export { isBoolean } from '../predicate/isBoolean.mjs';
90
89
  export { delay } from '../promise/delay.mjs';
91
90
  export { withTimeout } from '../promise/withTimeout.mjs';
92
91
  export { camelCase } from '../string/camelCase.mjs';
@@ -112,6 +111,7 @@ export { property } from './object/property.mjs';
112
111
  export { mapKeys } from './object/mapKeys.mjs';
113
112
  export { isPlainObject } from './predicate/isPlainObject.mjs';
114
113
  export { isArray } from './predicate/isArray.mjs';
114
+ export { isBoolean } from './predicate/isBoolean.mjs';
115
115
  export { isTypedArray } from './predicate/isTypedArray.mjs';
116
116
  export { isMatch } from './predicate/isMatch.mjs';
117
117
  export { matches } from './predicate/matches.mjs';
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Checks if the given value is boolean.
3
+ *
4
+ * This function tests whether the provided value is strictly `boolean`.
5
+ * It returns `true` if the value is `boolean`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
8
+ *
9
+ * @param {unknown} x - The Value to test if it is boolean.
10
+ * @returns {x is boolean} True if the value is booelan, false otherwise.
11
+ *
12
+ * @example
13
+ *
14
+ * const value1 = true;
15
+ * const value2 = 0;
16
+ * const value3 = 'abc';
17
+ *
18
+ * console.log(isBoolean(value1)); // true
19
+ * console.log(isBoolean(value2)); // false
20
+ * console.log(isBoolean(value3)); // false
21
+ *
22
+ */
23
+ declare function isBoolean(x: unknown): x is boolean;
24
+
25
+ export { isBoolean };
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Checks if the given value is boolean.
3
+ *
4
+ * This function tests whether the provided value is strictly `boolean`.
5
+ * It returns `true` if the value is `boolean`, and `false` otherwise.
6
+ *
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
8
+ *
9
+ * @param {unknown} x - The Value to test if it is boolean.
10
+ * @returns {x is boolean} True if the value is booelan, false otherwise.
11
+ *
12
+ * @example
13
+ *
14
+ * const value1 = true;
15
+ * const value2 = 0;
16
+ * const value3 = 'abc';
17
+ *
18
+ * console.log(isBoolean(value1)); // true
19
+ * console.log(isBoolean(value2)); // false
20
+ * console.log(isBoolean(value3)); // false
21
+ *
22
+ */
23
+ declare function isBoolean(x: unknown): x is boolean;
24
+
25
+ export { isBoolean };
@@ -0,0 +1,13 @@
1
+ import { getTag } from '../_internal/getTag.mjs';
2
+
3
+ function isBoolean(x) {
4
+ if (x === true || x === false) {
5
+ return true;
6
+ }
7
+ if (typeof x === 'object' && x != null && getTag(x) === '[object Boolean]') {
8
+ return true;
9
+ }
10
+ return false;
11
+ }
12
+
13
+ export { isBoolean };
package/dist/index.js CHANGED
@@ -2,16 +2,17 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const size = require('./_chunk/size-BlsJKU.js');
5
+ const size = require('./_chunk/size-gkSUOE.js');
6
6
  const array_index = require('./array/index.js');
7
7
  const promise_index = require('./_chunk/index-CwRt_M.js');
8
8
  const function_index = require('./function/index.js');
9
9
  const math_index = require('./math/index.js');
10
10
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
11
11
  const object_index = require('./object/index.js');
12
- const predicate_index = require('./predicate/index.js');
12
+ const isArguments = require('./_chunk/isArguments-B5Iphy.js');
13
13
  const isNil = require('./_chunk/isNil-CYi_Vh.js');
14
14
  const isTypedArray = require('./_chunk/isTypedArray-BBEkFl.js');
15
+ const predicate_index = require('./predicate/index.js');
15
16
  const string_index = require('./string/index.js');
16
17
 
17
18
 
@@ -102,20 +103,20 @@ exports.omit = object_index.omit;
102
103
  exports.omitBy = object_index.omitBy;
103
104
  exports.pick = object_index.pick;
104
105
  exports.pickBy = object_index.pickBy;
105
- exports.isArguments = predicate_index.isArguments;
106
- exports.isArrayLike = predicate_index.isArrayLike;
107
- exports.isBoolean = predicate_index.isBoolean;
108
- exports.isEqual = predicate_index.isEqual;
109
- exports.isFunction = predicate_index.isFunction;
110
- exports.isLength = predicate_index.isLength;
111
- exports.isNotNil = predicate_index.isNotNil;
112
- exports.isNull = predicate_index.isNull;
113
- exports.isObjectLike = predicate_index.isObjectLike;
114
- exports.isUndefined = predicate_index.isUndefined;
106
+ exports.isArguments = isArguments.isArguments;
107
+ exports.isArrayLike = isArguments.isArrayLike;
108
+ exports.isEqual = isArguments.isEqual;
109
+ exports.isFunction = isArguments.isFunction;
110
+ exports.isLength = isArguments.isLength;
111
+ exports.isNotNil = isArguments.isNotNil;
112
+ exports.isNull = isArguments.isNull;
113
+ exports.isObjectLike = isArguments.isObjectLike;
114
+ exports.isUndefined = isArguments.isUndefined;
115
115
  exports.isNil = isNil.isNil;
116
116
  exports.isPlainObject = isTypedArray.isPlainObject;
117
117
  exports.isPrimitive = isTypedArray.isPrimitive;
118
118
  exports.isTypedArray = isTypedArray.isTypedArray;
119
+ exports.isBoolean = predicate_index.isBoolean;
119
120
  exports.camelCase = string_index.camelCase;
120
121
  exports.capitalize = string_index.capitalize;
121
122
  exports.kebabCase = string_index.kebabCase;
@@ -2,271 +2,25 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
5
+ const isArguments = require('../_chunk/isArguments-B5Iphy.js');
6
6
  const isNil = require('../_chunk/isNil-CYi_Vh.js');
7
-
8
- const regexpTag = '[object RegExp]';
9
- const stringTag = '[object String]';
10
- const numberTag = '[object Number]';
11
- const booleanTag = '[object Boolean]';
12
- const argumentsTag = '[object Arguments]';
13
- const symbolTag = '[object Symbol]';
14
- const dateTag = '[object Date]';
15
- const mapTag = '[object Map]';
16
- const setTag = '[object Set]';
17
- const arrayTag = '[object Array]';
18
- const functionTag = '[object Function]';
19
- const arrayBufferTag = '[object ArrayBuffer]';
20
- const objectTag = '[object Object]';
21
- const errorTag = '[object Error]';
22
- const dataViewTag = '[object DataView]';
23
- const uint8ArrayTag = '[object Uint8Array]';
24
- const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
25
- const uint16ArrayTag = '[object Uint16Array]';
26
- const uint32ArrayTag = '[object Uint32Array]';
27
- const bigUint64ArrayTag = '[object BigUint64Array]';
28
- const int8ArrayTag = '[object Int8Array]';
29
- const int16ArrayTag = '[object Int16Array]';
30
- const int32ArrayTag = '[object Int32Array]';
31
- const bigInt64ArrayTag = '[object BigInt64Array]';
32
- const float32ArrayTag = '[object Float32Array]';
33
- const float64ArrayTag = '[object Float64Array]';
34
-
35
- function getSymbols(object) {
36
- return Object.getOwnPropertySymbols(object)
37
- .filter(symbol => object.propertyIsEnumerable(symbol));
38
- }
39
-
40
- function getTag(value) {
41
- if (value == null) {
42
- return value === undefined ? '[object Undefined]' : '[object Null]';
43
- }
44
- return Object.prototype.toString.call(value);
45
- }
46
-
47
- function isEqual(a, b) {
48
- if (typeof a === typeof b) {
49
- switch (typeof a) {
50
- case 'bigint':
51
- case 'string':
52
- case 'boolean':
53
- case 'symbol':
54
- case 'undefined': {
55
- return a === b;
56
- }
57
- case 'number': {
58
- return a === b || Object.is(a, b);
59
- }
60
- case 'function': {
61
- return a === b;
62
- }
63
- case 'object': {
64
- return areObjectsEqual(a, b);
65
- }
66
- }
67
- }
68
- return areObjectsEqual(a, b);
69
- }
70
- function areObjectsEqual(a, b, stack) {
71
- if (Object.is(a, b)) {
72
- return true;
73
- }
74
- let aTag = getTag(a);
75
- let bTag = getTag(b);
76
- if (aTag === argumentsTag) {
77
- aTag = objectTag;
78
- }
79
- if (bTag === argumentsTag) {
80
- bTag = objectTag;
81
- }
82
- if (aTag !== bTag) {
83
- return false;
84
- }
85
- switch (aTag) {
86
- case regexpTag:
87
- case stringTag:
88
- return a.toString() === b.toString();
89
- case numberTag: {
90
- const x = a.valueOf();
91
- const y = b.valueOf();
92
- return x === y || Number.isNaN(x) && Number.isNaN(y);
93
- }
94
- case booleanTag:
95
- case dateTag:
96
- case symbolTag:
97
- return Object.is(a.valueOf(), b.valueOf());
98
- case regexpTag: {
99
- return a.source === b.source && a.flags === b.flags;
100
- }
101
- case functionTag: {
102
- return a == b;
103
- }
104
- }
105
- stack = stack ?? new Map();
106
- const aStack = stack.get(a);
107
- const bStack = stack.get(b);
108
- if (aStack != null && bStack != null) {
109
- return aStack === b;
110
- }
111
- stack.set(a, b);
112
- stack.set(b, a);
113
- try {
114
- switch (aTag) {
115
- case mapTag: {
116
- if (a.size !== b.size) {
117
- return false;
118
- }
119
- for (const [key, value] of a.entries()) {
120
- if (!b.has(key) || !areObjectsEqual(value, b.get(key), stack)) {
121
- return false;
122
- }
123
- }
124
- return true;
125
- }
126
- case setTag: {
127
- if (a.size !== b.size) {
128
- return false;
129
- }
130
- const aValues = Array.from(a.values());
131
- const bValues = Array.from(b.values());
132
- for (let i = 0; i < aValues.length; i++) {
133
- const aValue = aValues[i];
134
- const index = bValues.findIndex(bValue => {
135
- return areObjectsEqual(aValue, bValue, stack);
136
- });
137
- if (index === -1) {
138
- return false;
139
- }
140
- bValues.splice(index, 1);
141
- }
142
- return true;
143
- }
144
- case arrayTag:
145
- case uint8ArrayTag:
146
- case uint8ClampedArrayTag:
147
- case uint16ArrayTag:
148
- case uint32ArrayTag:
149
- case bigUint64ArrayTag:
150
- case int8ArrayTag:
151
- case int16ArrayTag:
152
- case int32ArrayTag:
153
- case bigInt64ArrayTag:
154
- case float32ArrayTag:
155
- case float64ArrayTag: {
156
- if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
157
- return false;
158
- }
159
- if (a.length !== b.length) {
160
- return false;
161
- }
162
- for (let i = 0; i < a.length; i++) {
163
- if (!areObjectsEqual(a[i], b[i], stack)) {
164
- return false;
165
- }
166
- }
167
- return true;
168
- }
169
- case arrayBufferTag: {
170
- if (a.byteLength !== b.byteLength) {
171
- return false;
172
- }
173
- return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack);
174
- }
175
- case dataViewTag: {
176
- if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
177
- return false;
178
- }
179
- return areObjectsEqual(a.buffer, b.buffer, stack);
180
- }
181
- case errorTag: {
182
- return a.name === b.name && a.message === b.message;
183
- }
184
- case objectTag: {
185
- if (a == null || b == null) {
186
- return a === b;
187
- }
188
- const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack) ||
189
- (isTypedArray.isPlainObject(a) && isTypedArray.isPlainObject(b));
190
- if (!areEqualInstances) {
191
- return false;
192
- }
193
- const aKeys = [...Object.keys(a), ...getSymbols(a)];
194
- const bKeys = [...Object.keys(b), ...getSymbols(b)];
195
- if (aKeys.length !== bKeys.length) {
196
- return false;
197
- }
198
- for (let i = 0; i < aKeys.length; i++) {
199
- const propKey = aKeys[i];
200
- const aProp = a[propKey];
201
- if (!b.hasOwnProperty(propKey)) {
202
- return false;
203
- }
204
- const bProp = b[propKey];
205
- if (!areObjectsEqual(aProp, bProp, stack)) {
206
- return false;
207
- }
208
- }
209
- return true;
210
- }
211
- default: {
212
- return false;
213
- }
214
- }
215
- }
216
- finally {
217
- stack.delete(a);
218
- stack.delete(b);
219
- }
220
- }
221
-
222
- function isNotNil(x) {
223
- return x !== null && x !== undefined;
224
- }
225
-
226
- function isNull(x) {
227
- return x === null;
228
- }
229
-
230
- function isUndefined(x) {
231
- return x === undefined;
232
- }
233
-
234
- function isLength(value) {
235
- return Number.isSafeInteger(value) && value >= 0;
236
- }
237
-
238
- function isFunction(value) {
239
- return typeof value === 'function';
240
- }
241
-
242
- function isArrayLike(value) {
243
- return value != null && typeof value !== "function" &&
244
- isLength(value.length);
245
- }
246
-
247
- function isObjectLike(value) {
248
- return typeof value === 'object' && value !== null;
249
- }
250
-
251
- function isArguments(value) {
252
- return value !== null && typeof value === 'object' && getTag(value) === '[object Arguments]';
253
- }
7
+ const isTypedArray = require('../_chunk/isTypedArray-BBEkFl.js');
254
8
 
255
9
  function isBoolean(x) {
256
- return x === false || x === true || (x !== null && typeof x === 'object' && getTag(x) === '[object Boolean]');
257
- }
258
-
10
+ return typeof x === 'boolean';
11
+ }
12
+
13
+ exports.isArguments = isArguments.isArguments;
14
+ exports.isArrayLike = isArguments.isArrayLike;
15
+ exports.isEqual = isArguments.isEqual;
16
+ exports.isFunction = isArguments.isFunction;
17
+ exports.isLength = isArguments.isLength;
18
+ exports.isNotNil = isArguments.isNotNil;
19
+ exports.isNull = isArguments.isNull;
20
+ exports.isObjectLike = isArguments.isObjectLike;
21
+ exports.isUndefined = isArguments.isUndefined;
22
+ exports.isNil = isNil.isNil;
259
23
  exports.isPlainObject = isTypedArray.isPlainObject;
260
24
  exports.isPrimitive = isTypedArray.isPrimitive;
261
25
  exports.isTypedArray = isTypedArray.isTypedArray;
262
- exports.isNil = isNil.isNil;
263
- exports.isArguments = isArguments;
264
- exports.isArrayLike = isArrayLike;
265
26
  exports.isBoolean = isBoolean;
266
- exports.isEqual = isEqual;
267
- exports.isFunction = isFunction;
268
- exports.isLength = isLength;
269
- exports.isNotNil = isNotNil;
270
- exports.isNull = isNull;
271
- exports.isObjectLike = isObjectLike;
272
- exports.isUndefined = isUndefined;
@@ -4,7 +4,7 @@
4
4
  * This function tests whether the provided value is strictly `boolean`.
5
5
  * It returns `true` if the value is `boolean`, and `false` otherwise.
6
6
  *
7
- * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
8
8
  *
9
9
  * @param {unknown} x - The Value to test if it is boolean.
10
10
  * @returns {x is boolean} True if the value is booelan, false otherwise.
@@ -4,7 +4,7 @@
4
4
  * This function tests whether the provided value is strictly `boolean`.
5
5
  * It returns `true` if the value is `boolean`, and `false` otherwise.
6
6
  *
7
- * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
7
+ * This function can also serve as a type predicate in TypeScript, narrowing the type of the argument to `boolean`.
8
8
  *
9
9
  * @param {unknown} x - The Value to test if it is boolean.
10
10
  * @returns {x is boolean} True if the value is booelan, false otherwise.
@@ -1,7 +1,5 @@
1
- import { getTag } from '../compat/_internal/getTag.mjs';
2
-
3
1
  function isBoolean(x) {
4
- return x === false || x === true || (x !== null && typeof x === 'object' && getTag(x) === '[object Boolean]');
2
+ return typeof x === 'boolean';
5
3
  }
6
4
 
7
5
  export { isBoolean };
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.13.1-dev.385+f6be4d7a",
4
+ "version": "1.13.1-dev.387+3ac7d23d",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {