ut2 1.1.3 → 1.2.0

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
@@ -81,6 +81,7 @@ const debounced = debounce(() => {
81
81
  - debounce - 防抖函数。
82
82
  - delay - 延迟触发。
83
83
  - negate - 否定断言。
84
+ - once - 只执行一次。
84
85
  - partial - 预设部分参数。
85
86
  - throttle - 节流函数。
86
87
  - Math 数学
@@ -125,6 +126,7 @@ const debounced = debounce(() => {
125
126
  - isBlob - `Blob` 对象。
126
127
  - isBoolean - 布尔类型或对象。
127
128
  - isBuffer - `buffer` 对象。
129
+ - isDataView - `DataView` 对象。
128
130
  - isDate - `Date` 对象。
129
131
  - isElement - `Dom` 元素。
130
132
  - isEmpty - 空对象、数组、`Map`、`Set`。
package/dist/ut2.js CHANGED
@@ -198,7 +198,11 @@
198
198
  return isArray(array) ? array.filter(function (item) { return !!item; }) : [];
199
199
  }
200
200
 
201
- function eq(value, other) {
201
+ function eq(value, other, strictCheck) {
202
+ if (strictCheck === void 0) { strictCheck = false; }
203
+ if (strictCheck) {
204
+ return Object.is(value, other);
205
+ }
202
206
  return value === other || (value !== value && other !== other);
203
207
  }
204
208
 
@@ -212,7 +216,8 @@
212
216
  return function (value) { return value; };
213
217
  }
214
218
 
215
- function difference(array, values, iteratee) {
219
+ function difference(array, values, iteratee, strictCheck) {
220
+ if (strictCheck === void 0) { strictCheck = false; }
216
221
  if (!isArray(array)) {
217
222
  return [];
218
223
  }
@@ -222,7 +227,7 @@
222
227
  var internalIteratee = createIteratee(iteratee);
223
228
  return array.filter(function (item) {
224
229
  var current = internalIteratee(item);
225
- return values.findIndex(function (value) { return eq(internalIteratee(value), current); }) === -1;
230
+ return values.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) === -1;
226
231
  });
227
232
  }
228
233
 
@@ -237,7 +242,8 @@
237
242
  return result;
238
243
  }
239
244
 
240
- function intersection(array, other, iteratee) {
245
+ function intersection(array, other, iteratee, strictCheck) {
246
+ if (strictCheck === void 0) { strictCheck = false; }
241
247
  if (!isArray(array) || !isArray(other)) {
242
248
  return [];
243
249
  }
@@ -245,8 +251,7 @@
245
251
  var caches = [];
246
252
  return array.filter(function (item) {
247
253
  var current = internalIteratee(item);
248
- if (other.findIndex(function (value) { return eq(internalIteratee(value), current); }) !== -1 &&
249
- !caches.includes(current)) {
254
+ if (other.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) !== -1 && !caches.includes(current)) {
250
255
  caches.push(current);
251
256
  return true;
252
257
  }
@@ -262,7 +267,7 @@
262
267
  var numberIsSafeInteger = Number.isSafeInteger;
263
268
  var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
264
269
  var arrayAt = Array.prototype.at;
265
- var VERSION = "1.1.3";
270
+ var VERSION = "1.2.0";
266
271
 
267
272
  function isFunction(value) {
268
273
  if (!isObject(value)) {
@@ -336,22 +341,24 @@
336
341
  return result;
337
342
  }
338
343
 
339
- function uniq(array, iteratee) {
344
+ function uniq(array, iteratee, strickCheck) {
345
+ if (strickCheck === void 0) { strickCheck = false; }
340
346
  if (!isArray(array)) {
341
347
  return [];
342
348
  }
343
349
  var internalIteratee = createIteratee(iteratee);
344
350
  return array.filter(function (value, index, arr) {
345
351
  var current = internalIteratee(value);
346
- return arr.findIndex(function (item) { return eq(internalIteratee(item), current); }) === index;
352
+ return arr.findIndex(function (item) { return eq(internalIteratee(item), current, strickCheck); }) === index;
347
353
  });
348
354
  }
349
355
 
350
- function union(array, other, iteratee) {
356
+ function union(array, other, iteratee, strickCheck) {
351
357
  if (other === void 0) { other = []; }
358
+ if (strickCheck === void 0) { strickCheck = false; }
352
359
  array = isArray(array) ? array : [];
353
360
  other = isArray(other) ? other : [];
354
- return uniq(array.concat(other), iteratee);
361
+ return uniq(array.concat(other), iteratee, strickCheck);
355
362
  }
356
363
 
357
364
  function isArrayLikeObject(value) {
@@ -379,19 +386,20 @@
379
386
  return result;
380
387
  }
381
388
 
382
- function xor(array, other, iteratee) {
389
+ function xor(array, other, iteratee, strickCheck) {
383
390
  if (other === void 0) { other = []; }
384
- var internalIteratee = createIteratee(iteratee);
391
+ if (strickCheck === void 0) { strickCheck = false; }
385
392
  if (!isArray(array) && !isArray(other)) {
386
393
  return [];
387
394
  }
395
+ var internalIteratee = createIteratee(iteratee);
388
396
  if (!isArray(other)) {
389
- return uniq(array, internalIteratee);
397
+ return uniq(array, internalIteratee, strickCheck);
390
398
  }
391
399
  if (!isArray(array)) {
392
- return uniq(other, internalIteratee);
400
+ return uniq(other, internalIteratee, strickCheck);
393
401
  }
394
- return difference(union(array, other, internalIteratee), intersection(array, other, internalIteratee), internalIteratee);
402
+ return difference(union(array, other, internalIteratee, strickCheck), intersection(array, other, internalIteratee, strickCheck), internalIteratee, strickCheck);
395
403
  }
396
404
 
397
405
  function zip() {
@@ -673,6 +681,10 @@
673
681
  };
674
682
  }
675
683
 
684
+ function once(func) {
685
+ return before(2, func);
686
+ }
687
+
676
688
  function partial(func) {
677
689
  var args = [];
678
690
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -1134,6 +1146,10 @@
1134
1146
  return false;
1135
1147
  }
1136
1148
 
1149
+ function isDataView(value) {
1150
+ return isType(value, 'DataView');
1151
+ }
1152
+
1137
1153
  function isDate(value) {
1138
1154
  return nodeIsDate ? nodeIsDate(value) : isObjectLike(value) && isType(value, 'Date');
1139
1155
  }
@@ -1147,9 +1163,7 @@
1147
1163
  return true;
1148
1164
  }
1149
1165
  var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
1150
- return (typeof Ctor === 'function' &&
1151
- Ctor instanceof Ctor &&
1152
- functionToString.call(Ctor) === objectCtorString);
1166
+ return typeof Ctor === 'function' && Ctor instanceof Ctor && functionToString.call(Ctor) === objectCtorString;
1153
1167
  }
1154
1168
 
1155
1169
  function isElement(value) {
@@ -1419,6 +1433,7 @@
1419
1433
  exports.isBlob = isBlob;
1420
1434
  exports.isBoolean = isBoolean;
1421
1435
  exports.isBuffer = isBuffer;
1436
+ exports.isDataView = isDataView;
1422
1437
  exports.isDate = isDate;
1423
1438
  exports.isElement = isElement;
1424
1439
  exports.isEmpty = isEmpty;
@@ -1461,6 +1476,7 @@
1461
1476
  exports.nthArg = nthArg;
1462
1477
  exports.omit = omit;
1463
1478
  exports.omitBy = omitBy;
1479
+ exports.once = once;
1464
1480
  exports.orderBy = orderBy;
1465
1481
  exports.partial = partial;
1466
1482
  exports.partition = partition;