sculp-js 1.5.1 → 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.
Files changed (55) hide show
  1. package/lib/cjs/array.js +2 -21
  2. package/lib/cjs/async.js +2 -2
  3. package/lib/cjs/base64.js +62 -0
  4. package/lib/cjs/clipboard.js +2 -2
  5. package/lib/cjs/cookie.js +2 -2
  6. package/lib/cjs/date.js +2 -3
  7. package/lib/cjs/dom.js +2 -2
  8. package/lib/cjs/download.js +2 -2
  9. package/lib/cjs/easing.js +2 -2
  10. package/lib/cjs/file.js +2 -2
  11. package/lib/cjs/func.js +3 -3
  12. package/lib/cjs/index.js +14 -4
  13. package/lib/cjs/math.js +88 -0
  14. package/lib/cjs/number.js +2 -2
  15. package/lib/cjs/object.js +10 -20
  16. package/lib/cjs/path.js +2 -2
  17. package/lib/cjs/qs.js +2 -2
  18. package/lib/cjs/random.js +2 -2
  19. package/lib/cjs/string.js +2 -2
  20. package/lib/cjs/tooltip.js +2 -2
  21. package/lib/cjs/tree.js +2 -2
  22. package/lib/cjs/type.js +68 -2
  23. package/lib/cjs/unique.js +2 -2
  24. package/lib/cjs/url.js +2 -2
  25. package/lib/cjs/watermark.js +2 -2
  26. package/lib/cjs/we-decode.js +2 -2
  27. package/lib/es/array.js +3 -21
  28. package/lib/es/async.js +2 -2
  29. package/lib/es/base64.js +59 -0
  30. package/lib/es/clipboard.js +2 -2
  31. package/lib/es/cookie.js +2 -2
  32. package/lib/es/date.js +2 -3
  33. package/lib/es/dom.js +2 -2
  34. package/lib/es/download.js +2 -2
  35. package/lib/es/easing.js +2 -2
  36. package/lib/es/file.js +2 -2
  37. package/lib/es/func.js +3 -3
  38. package/lib/es/index.js +7 -5
  39. package/lib/es/math.js +82 -0
  40. package/lib/es/number.js +2 -2
  41. package/lib/es/object.js +9 -18
  42. package/lib/es/path.js +2 -2
  43. package/lib/es/qs.js +2 -2
  44. package/lib/es/random.js +2 -2
  45. package/lib/es/string.js +2 -2
  46. package/lib/es/tooltip.js +2 -2
  47. package/lib/es/tree.js +2 -2
  48. package/lib/es/type.js +66 -3
  49. package/lib/es/unique.js +2 -2
  50. package/lib/es/url.js +2 -2
  51. package/lib/es/watermark.js +2 -2
  52. package/lib/es/we-decode.js +2 -2
  53. package/lib/index.d.ts +92 -15
  54. package/lib/umd/index.js +318 -149
  55. package/package.json +2 -2
package/lib/es/array.js CHANGED
@@ -1,27 +1,9 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
- import { objectHas } from './object.js';
8
- import { isArray, isString, isObject } from './type.js';
9
-
10
- /**
11
- * 判断一个对象是否为类数组
12
- *
13
- * @param any
14
- * @returns {boolean}
15
- */
16
- function arrayLike(any) {
17
- if (isArray(any))
18
- return true;
19
- if (isString(any))
20
- return true;
21
- if (!isObject(any))
22
- return false;
23
- return objectHas(any, 'length');
24
- }
25
7
  /**
26
8
  * 遍历数组,返回 false 中断遍历(支持continue和break操作)
27
9
  *
@@ -108,4 +90,4 @@ function arrayRemove(array, expect) {
108
90
  return array;
109
91
  }
110
92
 
111
- export { arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove };
93
+ export { arrayEach, arrayEachAsync, arrayInsertBefore, arrayRemove };
package/lib/es/async.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -0,0 +1,59 @@
1
+ /*!
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ import { getGlobal } from './func.js';
8
+ import { isNullOrUnDef } from './type.js';
9
+ import { weAtob, weBtoa } from './we-decode.js';
10
+
11
+ function stringToUint8Array(str) {
12
+ const utf8 = encodeURIComponent(str); // 将字符串转换为 UTF-8 编码
13
+ const uint8Array = new Uint8Array(utf8.length); // 创建 Uint8Array
14
+ for (let i = 0; i < utf8.length; i++) {
15
+ uint8Array[i] = utf8.charCodeAt(i); // 填充 Uint8Array
16
+ }
17
+ return uint8Array;
18
+ }
19
+ function uint8ArrayToString(uint8Array) {
20
+ const utf8 = String.fromCharCode.apply(null, uint8Array); // 将 Uint8Array 转为字符串
21
+ return decodeURIComponent(utf8); // 将 UTF-8 字符串解码回正常字符串
22
+ }
23
+ /**
24
+ * 将base64编码的字符串转换为原始字符串,包括对中文内容的处理(高性能,且支持Web、Node、小程序等任意平台)
25
+ * @param base64 base64编码的字符串
26
+ * @returns 原始字符串,包括中文内容
27
+ */
28
+ function decodeFromBase64(base64) {
29
+ const binaryString = !isNullOrUnDef(getGlobal('atob')) ? getGlobal('atob')(base64) : weAtob(base64);
30
+ const len = binaryString.length;
31
+ const bytes = new Uint8Array(len);
32
+ for (let i = 0; i < len; i++) {
33
+ bytes[i] = binaryString.charCodeAt(i);
34
+ }
35
+ // 使用TextDecoder将Uint8Array转换为原始字符串,包括中文内容
36
+ return !isNullOrUnDef(getGlobal('TextDecoder'))
37
+ ? new (getGlobal('TextDecoder'))('utf-8').decode(bytes)
38
+ : uint8ArrayToString(bytes);
39
+ }
40
+ /**
41
+ * 将原始字符串,包括中文内容,转换为base64编码的字符串(高性能,且支持Web、Node、小程序等任意平台)
42
+ * @param rawStr 原始字符串,包括中文内容
43
+ * @returns base64编码的字符串
44
+ */
45
+ function encodeToBase64(rawStr) {
46
+ const utf8Array = !isNullOrUnDef(getGlobal('TextEncoder'))
47
+ ? new (getGlobal('TextEncoder'))().encode(rawStr)
48
+ : stringToUint8Array(rawStr);
49
+ // 将 Uint8Array 转换为二进制字符串
50
+ let binaryString = '';
51
+ const len = utf8Array.length;
52
+ for (let i = 0; i < len; i++) {
53
+ binaryString += String.fromCharCode(utf8Array[i]);
54
+ }
55
+ // 将二进制字符串转换为base64编码的字符串
56
+ return !isNullOrUnDef(getGlobal('btoa')) ? getGlobal('btoa')(binaryString) : weBtoa(binaryString);
57
+ }
58
+
59
+ export { decodeFromBase64, encodeToBase64 };
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/cookie.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/date.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -127,7 +127,6 @@ function dateToEnd(value) {
127
127
  * - DD:日
128
128
  * - dd: 日
129
129
  * - HH:时(24 小时制)
130
- * - hh:时(12 小时制)
131
130
  * - mm:分
132
131
  * - ss:秒
133
132
  * - SSS:毫秒
package/lib/es/dom.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/easing.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/file.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/func.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -124,7 +124,7 @@ function setGlobal(key, val) {
124
124
  throw new SyntaxError('当前环境下无法设置全局属性');
125
125
  }
126
126
  /**
127
- * 设置全局变量
127
+ * 获取全局变量
128
128
  * @param {string | number | symbol} key
129
129
  * @param val
130
130
  */
package/lib/es/index.js CHANGED
@@ -1,20 +1,20 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
- export { arrayEach, arrayEachAsync, arrayInsertBefore, arrayLike, arrayRemove } from './array.js';
7
+ export { arrayEach, arrayEachAsync, arrayInsertBefore, arrayRemove } from './array.js';
8
8
  export { copyText } from './clipboard.js';
9
9
  export { cookieDel, cookieGet, cookieSet } from './cookie.js';
10
10
  export { calculateDate, calculateDateTime, dateParse, dateToEnd, dateToStart, formatDate, isValidDate } from './date.js';
11
11
  export { addClass, getComputedCssVal, getStrWidthPx, getStyle, hasClass, isDomReady, onDomReady, removeClass, setStyle, smoothScroll } from './dom.js';
12
12
  export { crossOriginDownload, downloadBlob, downloadData, downloadHref, downloadURL } from './download.js';
13
- export { cloneDeep, isPlainObject, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick } from './object.js';
13
+ export { cloneDeep, isPlainObject, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectMap, objectAssign as objectMerge, objectOmit, objectPick } from './object.js';
14
14
  export { pathJoin, pathNormalize } from './path.js';
15
15
  export { qsParse, qsStringify } from './qs.js';
16
16
  export { STRING_ARABIC_NUMERALS, STRING_LOWERCASE_ALPHA, STRING_UPPERCASE_ALPHA, parseQueryParams, stringAssign, stringCamelCase, stringEscapeHtml, stringFill, stringFormat, stringKebabCase } from './string.js';
17
- export { isArray, isBigInt, isBoolean, isDate, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, typeIs } from './type.js';
17
+ export { arrayLike, isArray, isBigInt, isBoolean, isDate, isEmpty, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, objectHas, typeIs } from './type.js';
18
18
  export { urlDelParams, urlParse, urlSetParams, urlStringify } from './url.js';
19
19
  export { asyncMap, wait } from './async.js';
20
20
  export { chooseLocalFile, compressImg, supportCanvas } from './file.js';
@@ -25,4 +25,6 @@ export { HEX_POOL, formatNumber, numberAbbr, numberToHex } from './number.js';
25
25
  export { UNIQUE_NUMBER_SAFE_LENGTH, uniqueNumber, uniqueString } from './unique.js';
26
26
  export { tooltipEvent } from './tooltip.js';
27
27
  export { buildTree, flatTree, forEachDeep, forEachMap, formatTree, fuzzySearchTree, searchTreeById } from './tree.js';
28
+ export { add, divide, multiply, strip, subtract } from './math.js';
28
29
  export { weAtob, weBtoa } from './we-decode.js';
30
+ export { decodeFromBase64, encodeToBase64 } from './base64.js';
package/lib/es/math.js ADDED
@@ -0,0 +1,82 @@
1
+ /*!
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
+ * Released under the MIT License.
5
+ */
6
+
7
+ /**
8
+ * 数值安全乘法
9
+ * @param arg1 数值1
10
+ * @param arg2 数值2
11
+ */
12
+ const multiply = (arg1, arg2) => {
13
+ let m = 0;
14
+ const s1 = arg1.toString();
15
+ const s2 = arg2.toString();
16
+ if (s1.split('.')[1] !== undefined)
17
+ m += s1.split('.')[1].length;
18
+ if (s2.split('.')[1] !== undefined)
19
+ m += s2.split('.')[1].length;
20
+ return (Number(s1.replace('.', '')) * Number(s2.replace('.', ''))) / Math.pow(10, m);
21
+ };
22
+ /**
23
+ * 数值安全加法
24
+ * @param arg1 数值1
25
+ * @param arg2 数值2
26
+ */
27
+ const add = (arg1, arg2) => {
28
+ let r1 = 0;
29
+ let r2 = 0;
30
+ let m = 0;
31
+ try {
32
+ r1 = arg1.toString().split('.')[1].length;
33
+ }
34
+ catch (e) {
35
+ r1 = 0;
36
+ }
37
+ try {
38
+ r2 = arg2.toString().split('.')[1].length;
39
+ }
40
+ catch (e) {
41
+ r2 = 0;
42
+ }
43
+ m = 10 ** Math.max(r1, r2);
44
+ return (multiply(arg1, m) + multiply(arg2, m)) / m;
45
+ };
46
+ /**
47
+ * 数值安全减法
48
+ * @param arg1 数值1
49
+ * @param arg2 数值2
50
+ */
51
+ const subtract = (arg1, arg2) => add(arg1, -arg2);
52
+ /**
53
+ * 数值安全除法
54
+ * @param arg1 数值1
55
+ * @param arg2 数值2
56
+ */
57
+ const divide = (arg1, arg2) => {
58
+ let t1 = 0;
59
+ let t2 = 0;
60
+ let r1 = 0;
61
+ let r2 = 0;
62
+ if (arg1.toString().split('.')[1] !== undefined)
63
+ t1 = arg1.toString().split('.')[1].length;
64
+ if (arg2.toString().split('.')[1] !== undefined)
65
+ t2 = arg2.toString().split('.')[1].length;
66
+ r1 = Number(arg1.toString().replace('.', ''));
67
+ r2 = Number(arg2.toString().replace('.', ''));
68
+ return (r1 / r2) * Math.pow(10, t2 - t1);
69
+ };
70
+ /**
71
+ * Correct the given number to specifying significant digits.
72
+ *
73
+ * @param num The input number
74
+ * @param precision An integer specifying the number of significant digits
75
+ *
76
+ * @example strip(0.09999999999999998) === 0.1 // true
77
+ */
78
+ function strip(num, precision = 15) {
79
+ return +parseFloat(Number(num).toPrecision(precision));
80
+ }
81
+
82
+ export { add, divide, multiply, strip, subtract };
package/lib/es/number.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/object.js CHANGED
@@ -1,10 +1,10 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
- import { isObject, isUndefined, typeIs, isArray } from './type.js';
7
+ import { isObject, objectHas, isNumber, isUndefined, typeIs, isArray } from './type.js';
8
8
 
9
9
  /**
10
10
  * 判断对象是否为纯对象
@@ -21,15 +21,6 @@ const isPlainObject = (obj) => {
21
21
  // 是否对象直接实例
22
22
  return proto === Object.prototype;
23
23
  };
24
- /**
25
- * 判断对象内是否有该静态属性
26
- * @param {object} obj
27
- * @param {string} key
28
- * @returns {boolean}
29
- */
30
- function objectHas(obj, key) {
31
- return Object.prototype.hasOwnProperty.call(obj, key);
32
- }
33
24
  /**
34
25
  * 遍历对象,返回 false 中断遍历
35
26
  * @param {O} obj
@@ -183,23 +174,23 @@ function objectGet(obj, path, strict = false) {
183
174
  let i = 0;
184
175
  for (let len = keyArr.length; i < len - 1; ++i) {
185
176
  const key = keyArr[i];
186
- if (key in tempObj) {
187
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
177
+ if (isNumber(Number(key)) && Array.isArray(tempObj)) {
178
+ tempObj = tempObj[key];
179
+ }
180
+ else if (isObject(tempObj) && objectHas(tempObj, key)) {
188
181
  tempObj = tempObj[key];
189
182
  }
190
183
  else {
191
184
  tempObj = undefined;
192
185
  if (strict) {
193
- throw new Error('[berry/js-utils/object] objectGet path 路径不正确');
186
+ throw new Error('[Object] objectGet path 路径不正确');
194
187
  }
195
188
  break;
196
189
  }
197
190
  }
198
191
  return {
199
- // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
200
192
  p: tempObj,
201
193
  k: tempObj ? keyArr[i] : undefined,
202
- // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access,@typescript-eslint/no-unsafe-assignment
203
194
  v: tempObj ? tempObj[keyArr[i]] : undefined
204
195
  };
205
196
  }
@@ -227,4 +218,4 @@ function cloneDeep(obj, map = new WeakMap()) {
227
218
  return cloneObj;
228
219
  }
229
220
 
230
- export { cloneDeep, isPlainObject, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectHas, objectMap, objectAssign as objectMerge, objectOmit, objectPick };
221
+ export { cloneDeep, isPlainObject, objectAssign, objectEach, objectEachAsync, objectFill, objectGet, objectMap, objectAssign as objectMerge, objectOmit, objectPick };
package/lib/es/path.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/qs.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/random.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/string.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/tooltip.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/tree.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/type.js CHANGED
@@ -1,9 +1,34 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
7
+ // 常用类型定义
8
+ /**
9
+ * 判断对象内是否有该静态属性
10
+ * @param {object} obj
11
+ * @param {string} key
12
+ * @returns {boolean}
13
+ */
14
+ function objectHas(obj, key) {
15
+ return Object.prototype.hasOwnProperty.call(obj, key);
16
+ }
17
+ /**
18
+ * 判断一个对象是否为类数组
19
+ *
20
+ * @param any
21
+ * @returns {boolean}
22
+ */
23
+ function arrayLike(any) {
24
+ if (isArray(any))
25
+ return true;
26
+ if (isString(any))
27
+ return true;
28
+ if (!isObject(any))
29
+ return false;
30
+ return objectHas(any, 'length');
31
+ }
7
32
  /**
8
33
  * 判断任意值的数据类型
9
34
  * @param {unknown} any
@@ -50,5 +75,43 @@ function isJsonString(str) {
50
75
  return false;
51
76
  }
52
77
  }
78
+ /**
79
+ * Checks if `value` is an empty object, collection, map, or set.
80
+ *
81
+ * Objects are considered empty if they have no own enumerable string keyed
82
+ * properties.
83
+ *
84
+ * Array-like values such as `arguments` objects, arrays, buffers, strings, or
85
+ * jQuery-like collections are considered empty if they have a `length` of `0`.
86
+ * Similarly, maps and sets are considered empty if they have a `size` of `0`.
87
+ *
88
+ * @param {*} value The value to check.
89
+ * @returns {boolean} Returns `true` if `value` is empty, else `false`.
90
+ * @example
91
+ *
92
+ * _.isEmpty(null);
93
+ * // => true
94
+ *
95
+ * _.isEmpty(true);
96
+ * // => true
97
+ *
98
+ * _.isEmpty(1);
99
+ * // => true
100
+ *
101
+ * _.isEmpty([1, 2, 3]);
102
+ * // => false
103
+ *
104
+ * _.isEmpty({ 'a': 1 });
105
+ * // => false
106
+ */
107
+ function isEmpty(value) {
108
+ if (isNullOrUnDef(value) || Number.isNaN(value)) {
109
+ return true;
110
+ }
111
+ if (arrayLike(value) && (isArray(value) || isString(value) || isFunction(value.splice))) {
112
+ return !value.length;
113
+ }
114
+ return !Object.keys(value).length;
115
+ }
53
116
 
54
- export { typeIs as default, isArray, isBigInt, isBoolean, isDate, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, typeIs };
117
+ export { arrayLike, typeIs as default, isArray, isBigInt, isBoolean, isDate, isEmpty, isError, isFunction, isJsonString, isNaN, isNull, isNullOrUnDef, isNumber, isObject, isPrimitive, isRegExp, isString, isSymbol, isUndefined, objectHas, typeIs };
package/lib/es/unique.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
package/lib/es/url.js CHANGED
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6
 
@@ -1,6 +1,6 @@
1
1
  /*!
2
- * sculp-js v1.5.0
3
- * (c) 2023-2024 chandq
2
+ * sculp-js v1.6.1
3
+ * (c) 2023-2025 chandq
4
4
  * Released under the MIT License.
5
5
  */
6
6