ut2 1.1.3 → 1.2.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 (67) hide show
  1. package/README.md +2 -0
  2. package/dist/ut2.js +55 -37
  3. package/dist/ut2.js.map +1 -1
  4. package/dist/ut2.min.js +1 -1
  5. package/dist/ut2.min.js.map +1 -1
  6. package/es/difference.js +3 -2
  7. package/es/eq.js +7 -1
  8. package/es/index.js +2 -0
  9. package/es/internals/helpers.js +3 -2
  10. package/es/internals/sameValue.js +10 -0
  11. package/es/intersection.js +3 -3
  12. package/es/isDataView.js +7 -0
  13. package/es/isPlainObject.js +1 -3
  14. package/es/merge.js +1 -3
  15. package/es/once.js +7 -0
  16. package/es/orderBy.js +2 -6
  17. package/es/union.js +3 -2
  18. package/es/uniq.js +3 -2
  19. package/es/xor.js +6 -5
  20. package/lib/difference.js +3 -2
  21. package/lib/eq.js +7 -1
  22. package/lib/index.js +4 -0
  23. package/lib/internals/helpers.js +2 -1
  24. package/lib/internals/sameValue.js +12 -0
  25. package/lib/intersection.js +3 -3
  26. package/lib/isDataView.js +9 -0
  27. package/lib/isPlainObject.js +1 -3
  28. package/lib/merge.js +1 -3
  29. package/lib/once.js +9 -0
  30. package/lib/orderBy.js +2 -6
  31. package/lib/union.js +3 -2
  32. package/lib/uniq.js +3 -2
  33. package/lib/xor.js +6 -5
  34. package/package.json +1 -1
  35. package/types/before.d.ts +0 -7
  36. package/types/countBy.d.ts +1 -1
  37. package/types/difference.d.ts +9 -2
  38. package/types/eq.d.ts +8 -2
  39. package/types/groupBy.d.ts +1 -1
  40. package/types/index.d.ts +2 -0
  41. package/types/internals/decimalAdjust.d.ts +3 -3
  42. package/types/internals/helpers.d.ts +1 -0
  43. package/types/internals/isType.d.ts +1 -1
  44. package/types/internals/sameValue.d.ts +12 -0
  45. package/types/internals/splitCaseWords.d.ts +1 -1
  46. package/types/intersection.d.ts +9 -2
  47. package/types/isArrayLikeObject.d.ts +4 -4
  48. package/types/isBuffer.d.ts +1 -1
  49. package/types/isDataView.d.ts +15 -0
  50. package/types/isPlainObject.d.ts +3 -3
  51. package/types/isTypedArray.d.ts +2 -2
  52. package/types/kebabCase.d.ts +1 -1
  53. package/types/keyBy.d.ts +1 -1
  54. package/types/lowerCase.d.ts +1 -1
  55. package/types/merge.d.ts +2 -2
  56. package/types/omit.d.ts +1 -1
  57. package/types/once.d.ts +24 -0
  58. package/types/orderBy.d.ts +2 -2
  59. package/types/partition.d.ts +1 -1
  60. package/types/pick.d.ts +1 -1
  61. package/types/snakeCase.d.ts +1 -1
  62. package/types/toFinite.d.ts +8 -8
  63. package/types/union.d.ts +11 -4
  64. package/types/uniq.d.ts +10 -3
  65. package/types/upperCase.d.ts +1 -1
  66. package/types/words.d.ts +1 -1
  67. package/types/xor.d.ts +13 -6
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,29 @@
198
198
  return isArray(array) ? array.filter(function (item) { return !!item; }) : [];
199
199
  }
200
200
 
201
- function eq(value, other) {
201
+ var argType = 'Arguments';
202
+ var supportedArgumentsType = isType((function () { return arguments; })(), argType);
203
+ var FUNC_ERROR_TEXT = 'Expected a function';
204
+ var numberIsFinite = Number.isFinite;
205
+ var numberIsInteger = Number.isInteger;
206
+ var numberIsSafeInteger = Number.isSafeInteger;
207
+ var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
208
+ var arrayAt = Array.prototype.at;
209
+ var objectIs = Object.is;
210
+ var VERSION = "1.2.1";
211
+
212
+ function sameValue(value, other) {
213
+ if (typeof objectIs === 'function') {
214
+ return objectIs(value, other);
215
+ }
216
+ return value === other ? value !== 0 || 1 / value === 1 / other : value != value && other != other;
217
+ }
218
+
219
+ function eq(value, other, strictCheck) {
220
+ if (strictCheck === void 0) { strictCheck = false; }
221
+ if (strictCheck) {
222
+ return sameValue(value, other);
223
+ }
202
224
  return value === other || (value !== value && other !== other);
203
225
  }
204
226
 
@@ -212,7 +234,8 @@
212
234
  return function (value) { return value; };
213
235
  }
214
236
 
215
- function difference(array, values, iteratee) {
237
+ function difference(array, values, iteratee, strictCheck) {
238
+ if (strictCheck === void 0) { strictCheck = false; }
216
239
  if (!isArray(array)) {
217
240
  return [];
218
241
  }
@@ -222,7 +245,7 @@
222
245
  var internalIteratee = createIteratee(iteratee);
223
246
  return array.filter(function (item) {
224
247
  var current = internalIteratee(item);
225
- return values.findIndex(function (value) { return eq(internalIteratee(value), current); }) === -1;
248
+ return values.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) === -1;
226
249
  });
227
250
  }
228
251
 
@@ -237,7 +260,8 @@
237
260
  return result;
238
261
  }
239
262
 
240
- function intersection(array, other, iteratee) {
263
+ function intersection(array, other, iteratee, strictCheck) {
264
+ if (strictCheck === void 0) { strictCheck = false; }
241
265
  if (!isArray(array) || !isArray(other)) {
242
266
  return [];
243
267
  }
@@ -245,8 +269,7 @@
245
269
  var caches = [];
246
270
  return array.filter(function (item) {
247
271
  var current = internalIteratee(item);
248
- if (other.findIndex(function (value) { return eq(internalIteratee(value), current); }) !== -1 &&
249
- !caches.includes(current)) {
272
+ if (other.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) !== -1 && !caches.includes(current)) {
250
273
  caches.push(current);
251
274
  return true;
252
275
  }
@@ -254,16 +277,6 @@
254
277
  });
255
278
  }
256
279
 
257
- var argType = 'Arguments';
258
- var supportedArgumentsType = isType((function () { return arguments; })(), argType);
259
- var FUNC_ERROR_TEXT = 'Expected a function';
260
- var numberIsFinite = Number.isFinite;
261
- var numberIsInteger = Number.isInteger;
262
- var numberIsSafeInteger = Number.isSafeInteger;
263
- var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
264
- var arrayAt = Array.prototype.at;
265
- var VERSION = "1.1.3";
266
-
267
280
  function isFunction(value) {
268
281
  if (!isObject(value)) {
269
282
  return false;
@@ -336,22 +349,24 @@
336
349
  return result;
337
350
  }
338
351
 
339
- function uniq(array, iteratee) {
352
+ function uniq(array, iteratee, strickCheck) {
353
+ if (strickCheck === void 0) { strickCheck = false; }
340
354
  if (!isArray(array)) {
341
355
  return [];
342
356
  }
343
357
  var internalIteratee = createIteratee(iteratee);
344
358
  return array.filter(function (value, index, arr) {
345
359
  var current = internalIteratee(value);
346
- return arr.findIndex(function (item) { return eq(internalIteratee(item), current); }) === index;
360
+ return arr.findIndex(function (item) { return eq(internalIteratee(item), current, strickCheck); }) === index;
347
361
  });
348
362
  }
349
363
 
350
- function union(array, other, iteratee) {
364
+ function union(array, other, iteratee, strickCheck) {
351
365
  if (other === void 0) { other = []; }
366
+ if (strickCheck === void 0) { strickCheck = false; }
352
367
  array = isArray(array) ? array : [];
353
368
  other = isArray(other) ? other : [];
354
- return uniq(array.concat(other), iteratee);
369
+ return uniq(array.concat(other), iteratee, strickCheck);
355
370
  }
356
371
 
357
372
  function isArrayLikeObject(value) {
@@ -379,19 +394,20 @@
379
394
  return result;
380
395
  }
381
396
 
382
- function xor(array, other, iteratee) {
397
+ function xor(array, other, iteratee, strickCheck) {
383
398
  if (other === void 0) { other = []; }
384
- var internalIteratee = createIteratee(iteratee);
399
+ if (strickCheck === void 0) { strickCheck = false; }
385
400
  if (!isArray(array) && !isArray(other)) {
386
401
  return [];
387
402
  }
403
+ var internalIteratee = createIteratee(iteratee);
388
404
  if (!isArray(other)) {
389
- return uniq(array, internalIteratee);
405
+ return uniq(array, internalIteratee, strickCheck);
390
406
  }
391
407
  if (!isArray(array)) {
392
- return uniq(other, internalIteratee);
408
+ return uniq(other, internalIteratee, strickCheck);
393
409
  }
394
- return difference(union(array, other, internalIteratee), intersection(array, other, internalIteratee), internalIteratee);
410
+ return difference(union(array, other, internalIteratee, strickCheck), intersection(array, other, internalIteratee, strickCheck), internalIteratee, strickCheck);
395
411
  }
396
412
 
397
413
  function zip() {
@@ -498,9 +514,7 @@
498
514
  orders = (isArray(orders) ? orders : orders !== undefined ? [orders] : []);
499
515
  if (isArray(collection)) {
500
516
  collection.forEach(function (item, index) {
501
- var criteria = iteratees.map(function (iteratee) {
502
- return createIteratee(iteratee)(item);
503
- });
517
+ var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item); });
504
518
  result.push({
505
519
  criteria: criteria,
506
520
  index: index,
@@ -508,9 +522,7 @@
508
522
  });
509
523
  });
510
524
  }
511
- return result
512
- .sort(function (a, b) { return compareMultiple(a, b, orders); })
513
- .map(function (item) { return item.value; });
525
+ return result.sort(function (a, b) { return compareMultiple(a, b, orders); }).map(function (item) { return item.value; });
514
526
  }
515
527
 
516
528
  function partition(collection, predicate) {
@@ -673,6 +685,10 @@
673
685
  };
674
686
  }
675
687
 
688
+ function once(func) {
689
+ return before(2, func);
690
+ }
691
+
676
692
  function partial(func) {
677
693
  var args = [];
678
694
  for (var _i = 1; _i < arguments.length; _i++) {
@@ -901,9 +917,7 @@
901
917
  var keys = allKeysIn(source);
902
918
  keys.forEach(function (key) {
903
919
  var srcValue = source[key];
904
- var newValue = typeof customizer === 'function'
905
- ? customizer(obj[key], srcValue, key, obj, source)
906
- : undefined;
920
+ var newValue = typeof customizer === 'function' ? customizer(obj[key], srcValue, key, obj, source) : undefined;
907
921
  if (newValue === undefined) {
908
922
  newValue = srcValue;
909
923
  }
@@ -1134,6 +1148,10 @@
1134
1148
  return false;
1135
1149
  }
1136
1150
 
1151
+ function isDataView(value) {
1152
+ return isType(value, 'DataView');
1153
+ }
1154
+
1137
1155
  function isDate(value) {
1138
1156
  return nodeIsDate ? nodeIsDate(value) : isObjectLike(value) && isType(value, 'Date');
1139
1157
  }
@@ -1147,9 +1165,7 @@
1147
1165
  return true;
1148
1166
  }
1149
1167
  var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
1150
- return (typeof Ctor === 'function' &&
1151
- Ctor instanceof Ctor &&
1152
- functionToString.call(Ctor) === objectCtorString);
1168
+ return typeof Ctor === 'function' && Ctor instanceof Ctor && functionToString.call(Ctor) === objectCtorString;
1153
1169
  }
1154
1170
 
1155
1171
  function isElement(value) {
@@ -1419,6 +1435,7 @@
1419
1435
  exports.isBlob = isBlob;
1420
1436
  exports.isBoolean = isBoolean;
1421
1437
  exports.isBuffer = isBuffer;
1438
+ exports.isDataView = isDataView;
1422
1439
  exports.isDate = isDate;
1423
1440
  exports.isElement = isElement;
1424
1441
  exports.isEmpty = isEmpty;
@@ -1461,6 +1478,7 @@
1461
1478
  exports.nthArg = nthArg;
1462
1479
  exports.omit = omit;
1463
1480
  exports.omitBy = omitBy;
1481
+ exports.once = once;
1464
1482
  exports.orderBy = orderBy;
1465
1483
  exports.partial = partial;
1466
1484
  exports.partition = partition;