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/es/difference.js CHANGED
@@ -2,7 +2,8 @@ import eq from './eq.js';
2
2
  import createIteratee from './internals/createIteratee.js';
3
3
  import isArray from './isArray.js';
4
4
 
5
- function difference(array, values, iteratee) {
5
+ function difference(array, values, iteratee, strictCheck) {
6
+ if (strictCheck === void 0) { strictCheck = false; }
6
7
  if (!isArray(array)) {
7
8
  return [];
8
9
  }
@@ -12,7 +13,7 @@ function difference(array, values, iteratee) {
12
13
  var internalIteratee = createIteratee(iteratee);
13
14
  return array.filter(function (item) {
14
15
  var current = internalIteratee(item);
15
- return values.findIndex(function (value) { return eq(internalIteratee(value), current); }) === -1;
16
+ return values.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) === -1;
16
17
  });
17
18
  }
18
19
 
package/es/eq.js CHANGED
@@ -1,4 +1,10 @@
1
- function eq(value, other) {
1
+ import sameValue from './internals/sameValue.js';
2
+
3
+ function eq(value, other, strictCheck) {
4
+ if (strictCheck === void 0) { strictCheck = false; }
5
+ if (strictCheck) {
6
+ return sameValue(value, other);
7
+ }
2
8
  return value === other || (value !== value && other !== other);
3
9
  }
4
10
 
package/es/index.js CHANGED
@@ -20,6 +20,7 @@ export { default as before } from './before.js';
20
20
  export { default as debounce } from './debounce.js';
21
21
  export { default as delay } from './delay.js';
22
22
  export { default as negate } from './negate.js';
23
+ export { default as once } from './once.js';
23
24
  export { default as partial } from './partial.js';
24
25
  export { default as throttle } from './throttle.js';
25
26
  export { default as ceil } from './ceil.js';
@@ -59,6 +60,7 @@ export { default as isArrayLikeObject } from './isArrayLikeObject.js';
59
60
  export { default as isBlob } from './isBlob.js';
60
61
  export { default as isBoolean } from './isBoolean.js';
61
62
  export { default as isBuffer } from './isBuffer.js';
63
+ export { default as isDataView } from './isDataView.js';
62
64
  export { default as isDate } from './isDate.js';
63
65
  export { default as isElement } from './isElement.js';
64
66
  export { default as isEmpty } from './isEmpty.js';
@@ -8,6 +8,7 @@ var numberIsInteger = Number.isInteger;
8
8
  var numberIsSafeInteger = Number.isSafeInteger;
9
9
  var objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
10
10
  var arrayAt = Array.prototype.at;
11
- var VERSION = "1.1.3";
11
+ var objectIs = Object.is;
12
+ var VERSION = "1.2.1";
12
13
 
13
- export { FUNC_ERROR_TEXT, VERSION, argType, arrayAt, numberIsFinite, numberIsInteger, numberIsSafeInteger, objectGetOwnPropertySymbols, supportedArgumentsType };
14
+ export { FUNC_ERROR_TEXT, VERSION, argType, arrayAt, numberIsFinite, numberIsInteger, numberIsSafeInteger, objectGetOwnPropertySymbols, objectIs, supportedArgumentsType };
@@ -0,0 +1,10 @@
1
+ import { objectIs } from './helpers.js';
2
+
3
+ function sameValue(value, other) {
4
+ if (typeof objectIs === 'function') {
5
+ return objectIs(value, other);
6
+ }
7
+ return value === other ? value !== 0 || 1 / value === 1 / other : value != value && other != other;
8
+ }
9
+
10
+ export { sameValue as default };
@@ -2,7 +2,8 @@ import eq from './eq.js';
2
2
  import createIteratee from './internals/createIteratee.js';
3
3
  import isArray from './isArray.js';
4
4
 
5
- function intersection(array, other, iteratee) {
5
+ function intersection(array, other, iteratee, strictCheck) {
6
+ if (strictCheck === void 0) { strictCheck = false; }
6
7
  if (!isArray(array) || !isArray(other)) {
7
8
  return [];
8
9
  }
@@ -10,8 +11,7 @@ function intersection(array, other, iteratee) {
10
11
  var caches = [];
11
12
  return array.filter(function (item) {
12
13
  var current = internalIteratee(item);
13
- if (other.findIndex(function (value) { return eq(internalIteratee(value), current); }) !== -1 &&
14
- !caches.includes(current)) {
14
+ if (other.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) !== -1 && !caches.includes(current)) {
15
15
  caches.push(current);
16
16
  return true;
17
17
  }
@@ -0,0 +1,7 @@
1
+ import isType from './internals/isType.js';
2
+
3
+ function isDataView(value) {
4
+ return isType(value, 'DataView');
5
+ }
6
+
7
+ export { isDataView as default };
@@ -11,9 +11,7 @@ function isPlainObject(value) {
11
11
  return true;
12
12
  }
13
13
  var Ctor = hasOwnProperty.call(proto, 'constructor') && proto.constructor;
14
- return (typeof Ctor === 'function' &&
15
- Ctor instanceof Ctor &&
16
- functionToString.call(Ctor) === objectCtorString);
14
+ return typeof Ctor === 'function' && Ctor instanceof Ctor && functionToString.call(Ctor) === objectCtorString;
17
15
  }
18
16
 
19
17
  export { isPlainObject as default };
package/es/merge.js CHANGED
@@ -12,9 +12,7 @@ function baseMerge(object, source, customizer, storage) {
12
12
  var keys = allKeysIn(source);
13
13
  keys.forEach(function (key) {
14
14
  var srcValue = source[key];
15
- var newValue = typeof customizer === 'function'
16
- ? customizer(obj[key], srcValue, key, obj, source)
17
- : undefined;
15
+ var newValue = typeof customizer === 'function' ? customizer(obj[key], srcValue, key, obj, source) : undefined;
18
16
  if (newValue === undefined) {
19
17
  newValue = srcValue;
20
18
  }
package/es/once.js ADDED
@@ -0,0 +1,7 @@
1
+ import before from './before.js';
2
+
3
+ function once(func) {
4
+ return before(2, func);
5
+ }
6
+
7
+ export { once as default };
package/es/orderBy.js CHANGED
@@ -9,9 +9,7 @@ function orderBy(collection, iteratees, orders) {
9
9
  orders = (isArray(orders) ? orders : orders !== undefined ? [orders] : []);
10
10
  if (isArray(collection)) {
11
11
  collection.forEach(function (item, index) {
12
- var criteria = iteratees.map(function (iteratee) {
13
- return createIteratee(iteratee)(item);
14
- });
12
+ var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item); });
15
13
  result.push({
16
14
  criteria: criteria,
17
15
  index: index,
@@ -19,9 +17,7 @@ function orderBy(collection, iteratees, orders) {
19
17
  });
20
18
  });
21
19
  }
22
- return result
23
- .sort(function (a, b) { return compareMultiple(a, b, orders); })
24
- .map(function (item) { return item.value; });
20
+ return result.sort(function (a, b) { return compareMultiple(a, b, orders); }).map(function (item) { return item.value; });
25
21
  }
26
22
 
27
23
  export { orderBy as default };
package/es/union.js CHANGED
@@ -1,11 +1,12 @@
1
1
  import isArray from './isArray.js';
2
2
  import uniq from './uniq.js';
3
3
 
4
- function union(array, other, iteratee) {
4
+ function union(array, other, iteratee, strickCheck) {
5
5
  if (other === void 0) { other = []; }
6
+ if (strickCheck === void 0) { strickCheck = false; }
6
7
  array = isArray(array) ? array : [];
7
8
  other = isArray(other) ? other : [];
8
- return uniq(array.concat(other), iteratee);
9
+ return uniq(array.concat(other), iteratee, strickCheck);
9
10
  }
10
11
 
11
12
  export { union as default };
package/es/uniq.js CHANGED
@@ -2,14 +2,15 @@ import eq from './eq.js';
2
2
  import createIteratee from './internals/createIteratee.js';
3
3
  import isArray from './isArray.js';
4
4
 
5
- function uniq(array, iteratee) {
5
+ function uniq(array, iteratee, strickCheck) {
6
+ if (strickCheck === void 0) { strickCheck = false; }
6
7
  if (!isArray(array)) {
7
8
  return [];
8
9
  }
9
10
  var internalIteratee = createIteratee(iteratee);
10
11
  return array.filter(function (value, index, arr) {
11
12
  var current = internalIteratee(value);
12
- return arr.findIndex(function (item) { return eq(internalIteratee(item), current); }) === index;
13
+ return arr.findIndex(function (item) { return eq(internalIteratee(item), current, strickCheck); }) === index;
13
14
  });
14
15
  }
15
16
 
package/es/xor.js CHANGED
@@ -5,19 +5,20 @@ import isArray from './isArray.js';
5
5
  import union from './union.js';
6
6
  import uniq from './uniq.js';
7
7
 
8
- function xor(array, other, iteratee) {
8
+ function xor(array, other, iteratee, strickCheck) {
9
9
  if (other === void 0) { other = []; }
10
- var internalIteratee = createIteratee(iteratee);
10
+ if (strickCheck === void 0) { strickCheck = false; }
11
11
  if (!isArray(array) && !isArray(other)) {
12
12
  return [];
13
13
  }
14
+ var internalIteratee = createIteratee(iteratee);
14
15
  if (!isArray(other)) {
15
- return uniq(array, internalIteratee);
16
+ return uniq(array, internalIteratee, strickCheck);
16
17
  }
17
18
  if (!isArray(array)) {
18
- return uniq(other, internalIteratee);
19
+ return uniq(other, internalIteratee, strickCheck);
19
20
  }
20
- return difference(union(array, other, internalIteratee), intersection(array, other, internalIteratee), internalIteratee);
21
+ return difference(union(array, other, internalIteratee, strickCheck), intersection(array, other, internalIteratee, strickCheck), internalIteratee, strickCheck);
21
22
  }
22
23
 
23
24
  export { xor as default };
package/lib/difference.js CHANGED
@@ -4,7 +4,8 @@ var eq = require('./eq.js');
4
4
  var createIteratee = require('./internals/createIteratee.js');
5
5
  var isArray = require('./isArray.js');
6
6
 
7
- function difference(array, values, iteratee) {
7
+ function difference(array, values, iteratee, strictCheck) {
8
+ if (strictCheck === void 0) { strictCheck = false; }
8
9
  if (!isArray(array)) {
9
10
  return [];
10
11
  }
@@ -14,7 +15,7 @@ function difference(array, values, iteratee) {
14
15
  var internalIteratee = createIteratee(iteratee);
15
16
  return array.filter(function (item) {
16
17
  var current = internalIteratee(item);
17
- return values.findIndex(function (value) { return eq(internalIteratee(value), current); }) === -1;
18
+ return values.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) === -1;
18
19
  });
19
20
  }
20
21
 
package/lib/eq.js CHANGED
@@ -1,6 +1,12 @@
1
1
  'use strict';
2
2
 
3
- function eq(value, other) {
3
+ var sameValue = require('./internals/sameValue.js');
4
+
5
+ function eq(value, other, strictCheck) {
6
+ if (strictCheck === void 0) { strictCheck = false; }
7
+ if (strictCheck) {
8
+ return sameValue(value, other);
9
+ }
4
10
  return value === other || (value !== value && other !== other);
5
11
  }
6
12
 
package/lib/index.js CHANGED
@@ -22,6 +22,7 @@ var before = require('./before.js');
22
22
  var debounce = require('./debounce.js');
23
23
  var delay = require('./delay.js');
24
24
  var negate = require('./negate.js');
25
+ var once = require('./once.js');
25
26
  var partial = require('./partial.js');
26
27
  var throttle = require('./throttle.js');
27
28
  var ceil = require('./ceil.js');
@@ -61,6 +62,7 @@ var isArrayLikeObject = require('./isArrayLikeObject.js');
61
62
  var isBlob = require('./isBlob.js');
62
63
  var isBoolean = require('./isBoolean.js');
63
64
  var isBuffer = require('./isBuffer.js');
65
+ var isDataView = require('./isDataView.js');
64
66
  var isDate = require('./isDate.js');
65
67
  var isElement = require('./isElement.js');
66
68
  var isEmpty = require('./isEmpty.js');
@@ -136,6 +138,7 @@ exports.before = before;
136
138
  exports.debounce = debounce;
137
139
  exports.delay = delay;
138
140
  exports.negate = negate;
141
+ exports.once = once;
139
142
  exports.partial = partial;
140
143
  exports.throttle = throttle;
141
144
  exports.ceil = ceil;
@@ -175,6 +178,7 @@ exports.isArrayLikeObject = isArrayLikeObject;
175
178
  exports.isBlob = isBlob;
176
179
  exports.isBoolean = isBoolean;
177
180
  exports.isBuffer = isBuffer;
181
+ exports.isDataView = isDataView;
178
182
  exports.isDate = isDate;
179
183
  exports.isElement = isElement;
180
184
  exports.isEmpty = isEmpty;
@@ -10,4 +10,5 @@ exports.numberIsInteger = Number.isInteger;
10
10
  exports.numberIsSafeInteger = Number.isSafeInteger;
11
11
  exports.objectGetOwnPropertySymbols = Object.getOwnPropertySymbols;
12
12
  exports.arrayAt = Array.prototype.at;
13
- exports.VERSION = "1.1.3";
13
+ exports.objectIs = Object.is;
14
+ exports.VERSION = "1.2.1";
@@ -0,0 +1,12 @@
1
+ 'use strict';
2
+
3
+ var helpers = require('./helpers.js');
4
+
5
+ function sameValue(value, other) {
6
+ if (typeof helpers.objectIs === 'function') {
7
+ return helpers.objectIs(value, other);
8
+ }
9
+ return value === other ? value !== 0 || 1 / value === 1 / other : value != value && other != other;
10
+ }
11
+
12
+ module.exports = sameValue;
@@ -4,7 +4,8 @@ var eq = require('./eq.js');
4
4
  var createIteratee = require('./internals/createIteratee.js');
5
5
  var isArray = require('./isArray.js');
6
6
 
7
- function intersection(array, other, iteratee) {
7
+ function intersection(array, other, iteratee, strictCheck) {
8
+ if (strictCheck === void 0) { strictCheck = false; }
8
9
  if (!isArray(array) || !isArray(other)) {
9
10
  return [];
10
11
  }
@@ -12,8 +13,7 @@ function intersection(array, other, iteratee) {
12
13
  var caches = [];
13
14
  return array.filter(function (item) {
14
15
  var current = internalIteratee(item);
15
- if (other.findIndex(function (value) { return eq(internalIteratee(value), current); }) !== -1 &&
16
- !caches.includes(current)) {
16
+ if (other.findIndex(function (value) { return eq(internalIteratee(value), current, strictCheck); }) !== -1 && !caches.includes(current)) {
17
17
  caches.push(current);
18
18
  return true;
19
19
  }
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var isType = require('./internals/isType.js');
4
+
5
+ function isDataView(value) {
6
+ return isType(value, 'DataView');
7
+ }
8
+
9
+ module.exports = isDataView;
@@ -13,9 +13,7 @@ function isPlainObject(value) {
13
13
  return true;
14
14
  }
15
15
  var Ctor = native.hasOwnProperty.call(proto, 'constructor') && proto.constructor;
16
- return (typeof Ctor === 'function' &&
17
- Ctor instanceof Ctor &&
18
- native.functionToString.call(Ctor) === native.objectCtorString);
16
+ return typeof Ctor === 'function' && Ctor instanceof Ctor && native.functionToString.call(Ctor) === native.objectCtorString;
19
17
  }
20
18
 
21
19
  module.exports = isPlainObject;
package/lib/merge.js CHANGED
@@ -14,9 +14,7 @@ function baseMerge(object, source, customizer, storage) {
14
14
  var keys = allKeysIn(source);
15
15
  keys.forEach(function (key) {
16
16
  var srcValue = source[key];
17
- var newValue = typeof customizer === 'function'
18
- ? customizer(obj[key], srcValue, key, obj, source)
19
- : undefined;
17
+ var newValue = typeof customizer === 'function' ? customizer(obj[key], srcValue, key, obj, source) : undefined;
20
18
  if (newValue === undefined) {
21
19
  newValue = srcValue;
22
20
  }
package/lib/once.js ADDED
@@ -0,0 +1,9 @@
1
+ 'use strict';
2
+
3
+ var before = require('./before.js');
4
+
5
+ function once(func) {
6
+ return before(2, func);
7
+ }
8
+
9
+ module.exports = once;
package/lib/orderBy.js CHANGED
@@ -11,9 +11,7 @@ function orderBy(collection, iteratees, orders) {
11
11
  orders = (isArray(orders) ? orders : orders !== undefined ? [orders] : []);
12
12
  if (isArray(collection)) {
13
13
  collection.forEach(function (item, index) {
14
- var criteria = iteratees.map(function (iteratee) {
15
- return createIteratee(iteratee)(item);
16
- });
14
+ var criteria = iteratees.map(function (iteratee) { return createIteratee(iteratee)(item); });
17
15
  result.push({
18
16
  criteria: criteria,
19
17
  index: index,
@@ -21,9 +19,7 @@ function orderBy(collection, iteratees, orders) {
21
19
  });
22
20
  });
23
21
  }
24
- return result
25
- .sort(function (a, b) { return compare.compareMultiple(a, b, orders); })
26
- .map(function (item) { return item.value; });
22
+ return result.sort(function (a, b) { return compare.compareMultiple(a, b, orders); }).map(function (item) { return item.value; });
27
23
  }
28
24
 
29
25
  module.exports = orderBy;
package/lib/union.js CHANGED
@@ -3,11 +3,12 @@
3
3
  var isArray = require('./isArray.js');
4
4
  var uniq = require('./uniq.js');
5
5
 
6
- function union(array, other, iteratee) {
6
+ function union(array, other, iteratee, strickCheck) {
7
7
  if (other === void 0) { other = []; }
8
+ if (strickCheck === void 0) { strickCheck = false; }
8
9
  array = isArray(array) ? array : [];
9
10
  other = isArray(other) ? other : [];
10
- return uniq(array.concat(other), iteratee);
11
+ return uniq(array.concat(other), iteratee, strickCheck);
11
12
  }
12
13
 
13
14
  module.exports = union;
package/lib/uniq.js CHANGED
@@ -4,14 +4,15 @@ var eq = require('./eq.js');
4
4
  var createIteratee = require('./internals/createIteratee.js');
5
5
  var isArray = require('./isArray.js');
6
6
 
7
- function uniq(array, iteratee) {
7
+ function uniq(array, iteratee, strickCheck) {
8
+ if (strickCheck === void 0) { strickCheck = false; }
8
9
  if (!isArray(array)) {
9
10
  return [];
10
11
  }
11
12
  var internalIteratee = createIteratee(iteratee);
12
13
  return array.filter(function (value, index, arr) {
13
14
  var current = internalIteratee(value);
14
- return arr.findIndex(function (item) { return eq(internalIteratee(item), current); }) === index;
15
+ return arr.findIndex(function (item) { return eq(internalIteratee(item), current, strickCheck); }) === index;
15
16
  });
16
17
  }
17
18
 
package/lib/xor.js CHANGED
@@ -7,19 +7,20 @@ var isArray = require('./isArray.js');
7
7
  var union = require('./union.js');
8
8
  var uniq = require('./uniq.js');
9
9
 
10
- function xor(array, other, iteratee) {
10
+ function xor(array, other, iteratee, strickCheck) {
11
11
  if (other === void 0) { other = []; }
12
- var internalIteratee = createIteratee(iteratee);
12
+ if (strickCheck === void 0) { strickCheck = false; }
13
13
  if (!isArray(array) && !isArray(other)) {
14
14
  return [];
15
15
  }
16
+ var internalIteratee = createIteratee(iteratee);
16
17
  if (!isArray(other)) {
17
- return uniq(array, internalIteratee);
18
+ return uniq(array, internalIteratee, strickCheck);
18
19
  }
19
20
  if (!isArray(array)) {
20
- return uniq(other, internalIteratee);
21
+ return uniq(other, internalIteratee, strickCheck);
21
22
  }
22
- return difference(union(array, other, internalIteratee), intersection(array, other, internalIteratee), internalIteratee);
23
+ return difference(union(array, other, internalIteratee, strickCheck), intersection(array, other, internalIteratee, strickCheck), internalIteratee, strickCheck);
23
24
  }
24
25
 
25
26
  module.exports = xor;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.1.3",
3
+ "version": "1.2.1",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
package/types/before.d.ts CHANGED
@@ -16,16 +16,9 @@
16
16
  * });
17
17
  *
18
18
  * increment(); // 1
19
- *
20
19
  * increment(); // 2
21
- *
22
20
  * increment(); // 2 返回之前的结果
23
21
  *
24
- * // 只执行一次
25
- * const once = function (func){
26
- * before(2, func);
27
- * }
28
- *
29
22
  */
30
23
  declare function before<T extends (...args: any[]) => any>(n: number, func: T): T;
31
24
  export default before;
@@ -7,7 +7,7 @@
7
7
  * @alias module:Collection.countBy
8
8
  * @since 1.0.0
9
9
  * @param {Array} collection 一个用来迭代的集合。
10
- * @param {Function|string} [iteratee] 迭代函数,用来转换键。
10
+ * @param {Function | string} [iteratee] 迭代函数,用来转换键。
11
11
  * @returns {Object} 组成集合对象。
12
12
  * @example
13
13
  *
@@ -1,14 +1,17 @@
1
1
  /**
2
- * 创建一个 `array` 排除 `values` 值的新数组。使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
2
+ * 创建一个 `array` 排除 `values` 值的新数组。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
3
3
  *
4
4
  * `iteratee` 调用时会传入 1 个参数 `value` 。
5
5
  *
6
+ * 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
7
+ *
6
8
  * @static
7
9
  * @alias module:Array.difference
8
10
  * @since 1.0.0
9
11
  * @param {Array} array 要检查的数组。
10
12
  * @param {Array} values 排除的值。
11
13
  * @param {Function | string} [iteratee] 迭代函数,调用每个元素。
14
+ * @param {boolean} [strictCheck=false] 严格比较,区分 `+0` `-0`。
12
15
  * @returns {Array} 过滤值后的新数组。
13
16
  * @example
14
17
  *
@@ -21,6 +24,10 @@
21
24
  * // 如果迭代元素为对象,迭代函数可以直接写入对象属性。
22
25
  * difference([{x: 2}, {x: 1}], [{x: 1}], 'x'); // [{x: 2}]
23
26
  *
27
+ * difference([-0, 0], [0]); // []
28
+ *
29
+ * difference([-0, 0], [0], undefined, true); // [-0]
30
+ *
24
31
  */
25
- declare function difference<T, F extends (value: T) => any, K extends keyof T>(array: T[], values: any[], iteratee?: F | K): T[];
32
+ declare function difference<T, F extends (value: T) => any, K extends keyof T>(array: T[], values: any[], iteratee?: F | K, strictCheck?: boolean): T[];
26
33
  export default difference;
package/types/eq.d.ts CHANGED
@@ -1,11 +1,15 @@
1
1
  /**
2
- * 检查两个值是否相等。使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。
2
+ * 检查两个值是否相等。
3
+ *
4
+ * 默认使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果 `strictCheck=true` 将使用 [`SameValue`](https://tc39.es/ecma262/#sec-samevalue) 做等值比较。
3
5
  *
4
6
  * @static
5
7
  * @alias module:Util.eq
6
8
  * @since 1.0.0
9
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness | JavaScript 中的相等性判断}
7
10
  * @param {*} value 要比较的值。
8
11
  * @param {*} other 另一个要比较的值。
12
+ * @param {boolean} [strictCheck=false] 严格比较,区分 `+0` `-0`。
9
13
  * @returns {boolean} 如果两个值相等,返回 `true` ,否则返回 `false` 。
10
14
  * @example
11
15
  *
@@ -23,6 +27,8 @@
23
27
  *
24
28
  * eq(object, object); // true
25
29
  *
30
+ * eq(-0, 0, true); // false
31
+ *
26
32
  */
27
- declare function eq(value: any, other: any): boolean;
33
+ declare function eq(value: any, other: any, strictCheck?: boolean): boolean;
28
34
  export default eq;
@@ -7,7 +7,7 @@
7
7
  * @alias module:Collection.groupBy
8
8
  * @since 1.0.0
9
9
  * @param {Array} collection 一个用来迭代的集合。
10
- * @param {Function|string} [iteratee] 迭代函数,用来转换键。
10
+ * @param {Function | string} [iteratee] 迭代函数,用来转换键。
11
11
  * @returns {Object} 组成聚合对象。
12
12
  * @example
13
13
  *
package/types/index.d.ts CHANGED
@@ -38,6 +38,7 @@ export { default as before } from './before';
38
38
  export { default as debounce } from './debounce';
39
39
  export { default as delay } from './delay';
40
40
  export { default as negate } from './negate';
41
+ export { default as once } from './once';
41
42
  export { default as partial } from './partial';
42
43
  export { default as throttle } from './throttle';
43
44
  /**
@@ -107,6 +108,7 @@ export { default as isArrayLikeObject } from './isArrayLikeObject';
107
108
  export { default as isBlob } from './isBlob';
108
109
  export { default as isBoolean } from './isBoolean';
109
110
  export { default as isBuffer } from './isBuffer';
111
+ export { default as isDataView } from './isDataView';
110
112
  export { default as isDate } from './isDate';
111
113
  export { default as isElement } from './isElement';
112
114
  export { default as isEmpty } from './isEmpty';
@@ -2,9 +2,9 @@
2
2
  * 数字调整。
3
3
  *
4
4
  * @private
5
- * @param {'floor'|'ceil'|'round'} type 调整的类型。
6
- * @param {number} value 要调整的数字。
7
- * @param {number} precision 指数(调整基数的10个对数)。
5
+ * @param {'floor' | 'ceil' | 'round'} type 调整的类型。
6
+ * @param {number} value 要调整的数字。
7
+ * @param {number} precision 指数(调整基数的10个对数)。
8
8
  * @returns {number} 调整后的数字。
9
9
  */
10
10
  declare function decimalAdjust(type: 'floor' | 'ceil' | 'round', value: number, precision?: number): number;
@@ -6,6 +6,7 @@ export declare const numberIsInteger: (number: unknown) => boolean;
6
6
  export declare const numberIsSafeInteger: (number: unknown) => boolean;
7
7
  export declare const objectGetOwnPropertySymbols: (o: any) => symbol[];
8
8
  export declare const arrayAt: (index: number) => any;
9
+ export declare const objectIs: (value1: any, value2: any) => boolean;
9
10
  /**
10
11
  * ut2 版本号。
11
12
  *
@@ -4,7 +4,7 @@
4
4
  * @private
5
5
  * @since 1.0.0
6
6
  * @param {*} value 检查值
7
- * @param {string|string[]} type 类型名称
7
+ * @param {string | string[]} type 类型名称
8
8
  * @returns {boolean} 返回值类型是否匹配
9
9
  */
10
10
  declare function isType(value: any, type: string | string[]): boolean;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * 检查两个值是否相等。
3
+ *
4
+ * @private
5
+ * @see {@link https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Equality_comparisons_and_sameness | JavaScript 中的相等性判断}
6
+ * @see {@link https://tc39.es/ecma262/#sec-samevalue | SameValue}
7
+ * @param {*} value 要比较的值。
8
+ * @param {*} other 另一个要比较的值。
9
+ * @returns {boolean} 如果两个值相等返回 `true`, 否则返回 `false` 。
10
+ */
11
+ declare function sameValue(value: any, other: any): boolean;
12
+ export default sameValue;
@@ -3,7 +3,7 @@
3
3
  *
4
4
  * @private
5
5
  * @param {string} string 要拆分的字符串。
6
- * @param {RegExp|string} [pattern] 拆分词组的匹配模式。
6
+ * @param {RegExp | string} [pattern] 拆分词组的匹配模式。
7
7
  * @returns {string[]} 拆分后的数组。
8
8
  */
9
9
  declare function splitCaseWords(string: string, pattern?: RegExp | string): string[];