es-toolkit 1.18.0-dev.577 → 1.18.0-dev.579

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.
@@ -90,6 +90,7 @@ export { withTimeout } from '../promise/withTimeout.mjs';
90
90
  export { timeout } from '../promise/timeout.mjs';
91
91
  export { snakeCase } from '../string/snakeCase.mjs';
92
92
  export { kebabCase } from '../string/kebabCase.mjs';
93
+ export { upperCase } from '../string/upperCase.mjs';
93
94
  export { lowerCase } from '../string/lowerCase.mjs';
94
95
  export { startCase } from '../string/startCase.mjs';
95
96
  export { capitalize } from '../string/capitalize.mjs';
@@ -90,6 +90,7 @@ export { withTimeout } from '../promise/withTimeout.js';
90
90
  export { timeout } from '../promise/timeout.js';
91
91
  export { snakeCase } from '../string/snakeCase.js';
92
92
  export { kebabCase } from '../string/kebabCase.js';
93
+ export { upperCase } from '../string/upperCase.js';
93
94
  export { lowerCase } from '../string/lowerCase.js';
94
95
  export { startCase } from '../string/startCase.js';
95
96
  export { capitalize } from '../string/capitalize.js';
@@ -7,9 +7,9 @@ const promise_index = require('../_chunk/index-BGZDR9.js');
7
7
  const rest$1 = require('../_chunk/rest-CXt9w3.js');
8
8
  const range = require('../_chunk/range-BXlMmn.js');
9
9
  const randomInt = require('../_chunk/randomInt-CF7bZK.js');
10
- const toMerged = require('../_chunk/toMerged-Bmrr2j.js');
11
- const isWeakSet$1 = require('../_chunk/isWeakSet-BerD1A.js');
12
- const isTypedArray$1 = require('../_chunk/isTypedArray-Dsrnb1.js');
10
+ const toMerged = require('../_chunk/toMerged-LBvzaK.js');
11
+ const isWeakSet$1 = require('../_chunk/isWeakSet-Dob5v4.js');
12
+ const isPlainObject$1 = require('../_chunk/isPlainObject-BIekvL.js');
13
13
  const string_index = require('../string/index.js');
14
14
 
15
15
  function castArray(value) {
@@ -221,7 +221,7 @@ function isMatch(target, source) {
221
221
  }
222
222
  for (let i = 0; i < keys.length; i++) {
223
223
  const key = keys[i];
224
- if (!isTypedArray$1.isPrimitive(target) && !(key in target)) {
224
+ if (!isPlainObject$1.isPrimitive(target) && !(key in target)) {
225
225
  return false;
226
226
  }
227
227
  if (source[key] === undefined && target[key] !== undefined) {
@@ -878,7 +878,7 @@ function isPlainObject(object) {
878
878
  }
879
879
 
880
880
  function isTypedArray(x) {
881
- return isTypedArray$1.isTypedArray(x);
881
+ return isPlainObject$1.isTypedArray(x);
882
882
  }
883
883
 
884
884
  function mergeWith(object, ...otherArgs) {
@@ -1212,7 +1212,7 @@ exports.isNil = isWeakSet$1.isNil;
1212
1212
  exports.isNotNil = isWeakSet$1.isNotNil;
1213
1213
  exports.isNull = isWeakSet$1.isNull;
1214
1214
  exports.isUndefined = isWeakSet$1.isUndefined;
1215
- exports.isPrimitive = isTypedArray$1.isPrimitive;
1215
+ exports.isPrimitive = isPlainObject$1.isPrimitive;
1216
1216
  exports.capitalize = string_index.capitalize;
1217
1217
  exports.deburr = string_index.deburr;
1218
1218
  exports.escape = string_index.escape;
@@ -1225,6 +1225,7 @@ exports.pascalCase = string_index.pascalCase;
1225
1225
  exports.snakeCase = string_index.snakeCase;
1226
1226
  exports.startCase = string_index.startCase;
1227
1227
  exports.unescape = string_index.unescape;
1228
+ exports.upperCase = string_index.upperCase;
1228
1229
  exports.upperFirst = string_index.upperFirst;
1229
1230
  exports.ary = ary;
1230
1231
  exports.attempt = attempt;
@@ -92,6 +92,7 @@ export { timeout } from '../promise/timeout.mjs';
92
92
  export { capitalize } from '../string/capitalize.mjs';
93
93
  export { snakeCase } from '../string/snakeCase.mjs';
94
94
  export { kebabCase } from '../string/kebabCase.mjs';
95
+ export { upperCase } from '../string/upperCase.mjs';
95
96
  export { lowerCase } from '../string/lowerCase.mjs';
96
97
  export { startCase } from '../string/startCase.mjs';
97
98
  export { pascalCase } from '../string/pascalCase.mjs';
package/dist/index.d.mts CHANGED
@@ -115,6 +115,7 @@ export { timeout } from './promise/timeout.mjs';
115
115
  export { camelCase } from './string/camelCase.mjs';
116
116
  export { snakeCase } from './string/snakeCase.mjs';
117
117
  export { kebabCase } from './string/kebabCase.mjs';
118
+ export { upperCase } from './string/upperCase.mjs';
118
119
  export { lowerCase } from './string/lowerCase.mjs';
119
120
  export { startCase } from './string/startCase.mjs';
120
121
  export { capitalize } from './string/capitalize.mjs';
package/dist/index.d.ts CHANGED
@@ -115,6 +115,7 @@ export { timeout } from './promise/timeout.js';
115
115
  export { camelCase } from './string/camelCase.js';
116
116
  export { snakeCase } from './string/snakeCase.js';
117
117
  export { kebabCase } from './string/kebabCase.js';
118
+ export { upperCase } from './string/upperCase.js';
118
119
  export { lowerCase } from './string/lowerCase.js';
119
120
  export { startCase } from './string/startCase.js';
120
121
  export { capitalize } from './string/capitalize.js';
package/dist/index.js CHANGED
@@ -10,10 +10,10 @@ const function_index = require('./function/index.js');
10
10
  const range = require('./_chunk/range-BXlMmn.js');
11
11
  const randomInt = require('./_chunk/randomInt-CF7bZK.js');
12
12
  const math_index = require('./math/index.js');
13
- const toMerged = require('./_chunk/toMerged-Bmrr2j.js');
13
+ const toMerged = require('./_chunk/toMerged-LBvzaK.js');
14
14
  const object_index = require('./object/index.js');
15
- const isWeakSet = require('./_chunk/isWeakSet-BerD1A.js');
16
- const isTypedArray = require('./_chunk/isTypedArray-Dsrnb1.js');
15
+ const isWeakSet = require('./_chunk/isWeakSet-Dob5v4.js');
16
+ const isPlainObject = require('./_chunk/isPlainObject-BIekvL.js');
17
17
  const predicate_index = require('./predicate/index.js');
18
18
  const string_index = require('./string/index.js');
19
19
 
@@ -126,9 +126,9 @@ exports.isNull = isWeakSet.isNull;
126
126
  exports.isUndefined = isWeakSet.isUndefined;
127
127
  exports.isWeakMap = isWeakSet.isWeakMap;
128
128
  exports.isWeakSet = isWeakSet.isWeakSet;
129
- exports.isPlainObject = isTypedArray.isPlainObject;
130
- exports.isPrimitive = isTypedArray.isPrimitive;
131
- exports.isTypedArray = isTypedArray.isTypedArray;
129
+ exports.isPlainObject = isPlainObject.isPlainObject;
130
+ exports.isPrimitive = isPlainObject.isPrimitive;
131
+ exports.isTypedArray = isPlainObject.isTypedArray;
132
132
  exports.isBoolean = predicate_index.isBoolean;
133
133
  exports.isRegExp = predicate_index.isRegExp;
134
134
  exports.isString = predicate_index.isString;
@@ -146,4 +146,5 @@ exports.pascalCase = string_index.pascalCase;
146
146
  exports.snakeCase = string_index.snakeCase;
147
147
  exports.startCase = string_index.startCase;
148
148
  exports.unescape = string_index.unescape;
149
+ exports.upperCase = string_index.upperCase;
149
150
  exports.upperFirst = string_index.upperFirst;
package/dist/index.mjs CHANGED
@@ -115,6 +115,7 @@ export { timeout } from './promise/timeout.mjs';
115
115
  export { camelCase } from './string/camelCase.mjs';
116
116
  export { snakeCase } from './string/snakeCase.mjs';
117
117
  export { kebabCase } from './string/kebabCase.mjs';
118
+ export { upperCase } from './string/upperCase.mjs';
118
119
  export { lowerCase } from './string/lowerCase.mjs';
119
120
  export { startCase } from './string/startCase.mjs';
120
121
  export { capitalize } from './string/capitalize.mjs';
@@ -1,39 +1,42 @@
1
+ import { isTypedArray } from '../predicate/isTypedArray.mjs';
2
+ import { isPrimitive } from '../predicate/isPrimitive.mjs';
3
+
1
4
  function clone(obj) {
2
5
  if (isPrimitive(obj)) {
3
6
  return obj;
4
7
  }
5
- if (Array.isArray(obj)) {
6
- return obj.slice();
8
+ if (Array.isArray(obj) || isTypedArray(obj) || obj instanceof ArrayBuffer || obj instanceof SharedArrayBuffer) {
9
+ return obj.slice(0);
7
10
  }
8
- if (obj instanceof Date) {
9
- return new Date(obj.getTime());
11
+ const prototype = Object.getPrototypeOf(obj);
12
+ const Constructor = prototype.constructor;
13
+ if (obj instanceof Date || obj instanceof Map || obj instanceof Set) {
14
+ return new Constructor(obj);
10
15
  }
11
16
  if (obj instanceof RegExp) {
12
- return new RegExp(obj.source, obj.flags);
13
- }
14
- if (obj instanceof Map) {
15
- const result = new Map();
16
- for (const [key, value] of obj) {
17
- result.set(key, value);
18
- }
19
- return result;
20
- }
21
- if (obj instanceof Set) {
22
- const result = new Set();
23
- for (const value of obj) {
24
- result.add(value);
25
- }
26
- return result;
17
+ const newRegExp = new Constructor(obj);
18
+ newRegExp.lastIndex = obj.lastIndex;
19
+ return newRegExp;
20
+ }
21
+ if (obj instanceof DataView) {
22
+ return new Constructor(obj.buffer.slice(0));
23
+ }
24
+ if (obj instanceof Error) {
25
+ const newError = new Constructor(obj.message);
26
+ newError.stack = obj.stack;
27
+ newError.name = obj.name;
28
+ newError.cause = obj.cause;
29
+ return newError;
30
+ }
31
+ if (typeof File !== 'undefined' && obj instanceof File) {
32
+ const newFile = new Constructor([obj], obj.name, { type: obj.type, lastModified: obj.lastModified });
33
+ return newFile;
27
34
  }
28
35
  if (typeof obj === 'object') {
29
- const prototype = Object.getPrototypeOf(obj);
30
- const result = Object.create(prototype);
31
- return Object.assign(result, obj);
36
+ const newObject = Object.create(prototype);
37
+ return Object.assign(newObject, obj);
32
38
  }
33
39
  return obj;
34
40
  }
35
- function isPrimitive(value) {
36
- return value == null || (typeof value !== 'object' && typeof value !== 'function');
37
- }
38
41
 
39
42
  export { clone };
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const toMerged = require('../_chunk/toMerged-Bmrr2j.js');
5
+ const toMerged = require('../_chunk/toMerged-LBvzaK.js');
6
6
 
7
7
  function pick(obj, keys) {
8
8
  const result = {};
@@ -2,8 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
4
4
 
5
- const isWeakSet = require('../_chunk/isWeakSet-BerD1A.js');
6
- const isTypedArray = require('../_chunk/isTypedArray-Dsrnb1.js');
5
+ const isWeakSet = require('../_chunk/isWeakSet-Dob5v4.js');
6
+ const isPlainObject = require('../_chunk/isPlainObject-BIekvL.js');
7
7
 
8
8
  function isRegExp(value) {
9
9
  return value instanceof RegExp;
@@ -30,9 +30,9 @@ exports.isNull = isWeakSet.isNull;
30
30
  exports.isUndefined = isWeakSet.isUndefined;
31
31
  exports.isWeakMap = isWeakSet.isWeakMap;
32
32
  exports.isWeakSet = isWeakSet.isWeakSet;
33
- exports.isPlainObject = isTypedArray.isPlainObject;
34
- exports.isPrimitive = isTypedArray.isPrimitive;
35
- exports.isTypedArray = isTypedArray.isTypedArray;
33
+ exports.isPlainObject = isPlainObject.isPlainObject;
34
+ exports.isPrimitive = isPlainObject.isPrimitive;
35
+ exports.isTypedArray = isPlainObject.isTypedArray;
36
36
  exports.isBoolean = isBoolean;
37
37
  exports.isRegExp = isRegExp;
38
38
  exports.isString = isString;
@@ -1,6 +1,7 @@
1
1
  export { camelCase } from './camelCase.mjs';
2
2
  export { snakeCase } from './snakeCase.mjs';
3
3
  export { kebabCase } from './kebabCase.mjs';
4
+ export { upperCase } from './upperCase.mjs';
4
5
  export { lowerCase } from './lowerCase.mjs';
5
6
  export { startCase } from './startCase.mjs';
6
7
  export { capitalize } from './capitalize.mjs';
@@ -1,6 +1,7 @@
1
1
  export { camelCase } from './camelCase.js';
2
2
  export { snakeCase } from './snakeCase.js';
3
3
  export { kebabCase } from './kebabCase.js';
4
+ export { upperCase } from './upperCase.js';
4
5
  export { lowerCase } from './lowerCase.js';
5
6
  export { startCase } from './startCase.js';
6
7
  export { capitalize } from './capitalize.js';
@@ -30,6 +30,11 @@ function kebabCase(str) {
30
30
  return words.map(word => word.toLowerCase()).join('-');
31
31
  }
32
32
 
33
+ const upperCase = (str) => {
34
+ const words = getWords(str);
35
+ return words.map(word => word.toUpperCase()).join(' ');
36
+ };
37
+
33
38
  function lowerCase(str) {
34
39
  const words = getWords(str);
35
40
  return words.map(word => word.toLowerCase()).join(' ');
@@ -152,4 +157,5 @@ exports.pascalCase = pascalCase;
152
157
  exports.snakeCase = snakeCase;
153
158
  exports.startCase = startCase;
154
159
  exports.unescape = unescape;
160
+ exports.upperCase = upperCase;
155
161
  exports.upperFirst = upperFirst;
@@ -1,6 +1,7 @@
1
1
  export { camelCase } from './camelCase.mjs';
2
2
  export { snakeCase } from './snakeCase.mjs';
3
3
  export { kebabCase } from './kebabCase.mjs';
4
+ export { upperCase } from './upperCase.mjs';
4
5
  export { lowerCase } from './lowerCase.mjs';
5
6
  export { startCase } from './startCase.mjs';
6
7
  export { capitalize } from './capitalize.mjs';
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to upper case.
3
+ *
4
+ * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to upper case.
7
+ * @returns {string} - The converted string to upper case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE'
11
+ * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE'
12
+ * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT'
13
+ * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'
14
+ */
15
+ declare const upperCase: (str: string) => string;
16
+
17
+ export { upperCase };
@@ -0,0 +1,17 @@
1
+ /**
2
+ * Converts a string to upper case.
3
+ *
4
+ * Upper case is the naming convention in which each word is written in uppercase and separated by an space ( ) character.
5
+ *
6
+ * @param {string} str - The string that is to be changed to upper case.
7
+ * @returns {string} - The converted string to upper case.
8
+ *
9
+ * @example
10
+ * const convertedStr1 = upperCase('camelCase') // returns 'CAMEL CASE'
11
+ * const convertedStr2 = upperCase('some whitespace') // returns 'SOME WHITESPACE'
12
+ * const convertedStr3 = upperCase('hyphen-text') // returns 'HYPHEN TEXT'
13
+ * const convertedStr4 = upperCase('HTTPRequest') // returns 'HTTP REQUEST'
14
+ */
15
+ declare const upperCase: (str: string) => string;
16
+
17
+ export { upperCase };
@@ -0,0 +1,8 @@
1
+ import { getWords } from './_internal/getWords.mjs';
2
+
3
+ const upperCase = (str) => {
4
+ const words = getWords(str);
5
+ return words.map(word => word.toUpperCase()).join(' ');
6
+ };
7
+
8
+ export { upperCase };
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.18.0-dev.577+34fcd212",
4
+ "version": "1.18.0-dev.579+7f2e19dc",
5
5
  "homepage": "https://es-toolkit.slash.page",
6
6
  "bugs": "https://github.com/toss/es-toolkit/issues",
7
7
  "repository": {
@@ -1,5 +1,13 @@
1
1
  'use strict';
2
2
 
3
+ function isTypedArray(x) {
4
+ return ArrayBuffer.isView(x) && !(x instanceof DataView);
5
+ }
6
+
7
+ function isPrimitive(value) {
8
+ return value == null || (typeof value !== 'object' && typeof value !== 'function');
9
+ }
10
+
3
11
  function isPlainObject(object) {
4
12
  if (typeof object !== 'object') {
5
13
  return false;
@@ -20,14 +28,6 @@ function isPlainObject(object) {
20
28
  return Object.getPrototypeOf(object) === proto;
21
29
  }
22
30
 
23
- function isPrimitive(value) {
24
- return value == null || (typeof value !== 'object' && typeof value !== 'function');
25
- }
26
-
27
- function isTypedArray(x) {
28
- return ArrayBuffer.isView(x) && !(x instanceof DataView);
29
- }
30
-
31
31
  exports.isPlainObject = isPlainObject;
32
32
  exports.isPrimitive = isPrimitive;
33
33
  exports.isTypedArray = isTypedArray;