ut2 1.21.3 → 1.21.5

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/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  一个现代 JavaScript 实用工具库。[点击查看在线文档]。
4
4
 
5
- [![npm][npm]][npm-url] [![Build and Deploy Docs](https://github.com/caijf/ut2/actions/workflows/ci.yml/badge.svg)](https://github.com/caijf/ut2/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/caijf/ut2/branch/main/graph/badge.svg?token=XKTS0H7085)](https://codecov.io/gh/caijf/ut2) [![benchmark](https://img.shields.io/badge/benchmark-online-green)](https://s57jpy.csb.app/) ![npm](https://img.shields.io/npm/dm/ut2) ![GitHub](https://img.shields.io/github/license/caijf/ut2.svg)
5
+ [![npm][npm]][npm-url] [![Build and Deploy Docs](https://github.com/caijf/ut2/actions/workflows/ci.yml/badge.svg)](https://github.com/caijf/ut2/actions/workflows/ci.yml) [![codecov](https://codecov.io/gh/caijf/ut2/branch/main/graph/badge.svg?token=XKTS0H7085)](https://codecov.io/gh/caijf/ut2) [![benchmark](https://img.shields.io/badge/benchmark-online-green)](https://kqfct3.csb.app/) ![npm](https://img.shields.io/npm/dm/ut2) ![GitHub](https://img.shields.io/github/license/caijf/ut2.svg)
6
6
 
7
7
  ## 比较
8
8
 
@@ -40,7 +40,10 @@ pnpm add ut2
40
40
 
41
41
  如果你的项目使用的是原生方式开发,可以在浏览器中使用 `script` 标签直接引入文件,并使用全局变量 `ut2` 。
42
42
 
43
- `npm` 包的 `ut2/dist` 目录下提供了 `UMD` 包 `ut2.js` 以及 `ut2.min.js`。你也可以通过 [UNPKG](https://unpkg.com/browse/ut2/dist/) 下载到本地进行使用。或者直接使用 [UNPKG 线上版本](https://unpkg.com/ut2/dist/ut2.min.js)<sup> _注意版本_ </sup>。
43
+ `npm` 包的 [ut2/dist](https://www.npmjs.com/package/ut2?activeTab=code) 目录下提供了 `UMD` 包 `ut2.js` 以及 `ut2.min.js`。你也可以直接使用`cdn`:
44
+
45
+ - jsdelivr: <https://cdn.jsdelivr.net/npm/ut2@1>
46
+ - unpkg: <https://unpkg.com/ut2@1>
44
47
 
45
48
  ### 示例
46
49
 
package/dist/ut2.js CHANGED
@@ -4,6 +4,24 @@
4
4
  (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.ut2 = {}));
5
5
  })(this, (function (exports) { 'use strict';
6
6
 
7
+ function baseSlice(array, start, end) {
8
+ var index = -1, length = array.length;
9
+ if (start < 0) {
10
+ start = -start > length ? 0 : length + start;
11
+ }
12
+ end = end > length ? length : end;
13
+ if (end < 0) {
14
+ end += length;
15
+ }
16
+ length = start > end ? 0 : (end - start) >>> 0;
17
+ start >>>= 0;
18
+ var result = Array(length);
19
+ while (++index < length) {
20
+ result[index] = array[index + start];
21
+ }
22
+ return result;
23
+ }
24
+
7
25
  var nativeUndefined = void 0;
8
26
  var stringUndefined = 'undefined';
9
27
  var stringObject = 'object';
@@ -60,8 +78,8 @@
60
78
  var weakMapTag = tagPrefix + 'WeakMap]';
61
79
  var windowTag = tagPrefix + 'Window]';
62
80
 
63
- function isArray(value) {
64
- return Array.isArray(value);
81
+ function isNil(value) {
82
+ return value == null;
65
83
  }
66
84
 
67
85
  function isObjectLike(value) {
@@ -110,35 +128,25 @@
110
128
  return remainder ? result - remainder : result;
111
129
  }
112
130
 
113
- function toLength(value) {
114
- value = toInteger(value);
115
- if (!value) {
116
- return 0;
117
- }
118
- if (value < 0) {
119
- return 0;
120
- }
121
- if (value > MAX_ARRAY_LENGTH) {
122
- return MAX_ARRAY_LENGTH;
123
- }
124
- return value;
125
- }
126
-
127
131
  function chunk(array, size) {
128
132
  if (size === void 0) { size = 1; }
129
- size = toLength(size);
130
- if (!isArray(array) || size < 1) {
133
+ size = toInteger(size);
134
+ var length = isNil(array) ? 0 : array.length;
135
+ if (!length || size < 1) {
131
136
  return [];
132
137
  }
133
- var length = array.length;
134
138
  var result = Array(mathCeil(length / size));
135
139
  var resIndex = 0, index = 0;
136
140
  while (index < length) {
137
- result[resIndex++] = array.slice(index, (index += size));
141
+ result[resIndex++] = baseSlice(array, index, (index += size));
138
142
  }
139
143
  return result;
140
144
  }
141
145
 
146
+ function isArray(value) {
147
+ return Array.isArray(value);
148
+ }
149
+
142
150
  function compact(array) {
143
151
  return isArray(array) ? array.filter(function (item) { return !!item; }) : [];
144
152
  }
@@ -472,10 +480,6 @@
472
480
  return typeof value === 'number' || getTag(value) === numberTag;
473
481
  }
474
482
 
475
- function isNil(value) {
476
- return value == null;
477
- }
478
-
479
483
  var symbolToString = symbolProto ? symbolProto.toString : nativeUndefined;
480
484
  function baseToString(value) {
481
485
  if (typeof value === 'string') {
@@ -607,7 +611,7 @@
607
611
  return value == null || value !== value ? defaultValue : value;
608
612
  };
609
613
 
610
- var VERSION = "1.21.3";
614
+ var VERSION = "1.21.5";
611
615
  var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
612
616
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
613
617
  var FUNC_ERROR_TEXT = 'Expected a function';
@@ -2212,6 +2216,20 @@
2212
2216
 
2213
2217
  var times = list;
2214
2218
 
2219
+ function toLength(value) {
2220
+ value = toInteger(value);
2221
+ if (!value) {
2222
+ return 0;
2223
+ }
2224
+ if (value < 0) {
2225
+ return 0;
2226
+ }
2227
+ if (value > MAX_ARRAY_LENGTH) {
2228
+ return MAX_ARRAY_LENGTH;
2229
+ }
2230
+ return value;
2231
+ }
2232
+
2215
2233
  function toSafeInteger(value) {
2216
2234
  if (!value) {
2217
2235
  return value === 0 ? value : 0;