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/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,8 @@
1
- function eq(value, other) {
1
+ function eq(value, other, strictCheck) {
2
+ if (strictCheck === void 0) { strictCheck = false; }
3
+ if (strictCheck) {
4
+ return Object.is(value, other);
5
+ }
2
6
  return value === other || (value !== value && other !== other);
3
7
  }
4
8
 
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,6 @@ 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 VERSION = "1.2.0";
12
12
 
13
13
  export { FUNC_ERROR_TEXT, VERSION, argType, arrayAt, numberIsFinite, numberIsInteger, numberIsSafeInteger, objectGetOwnPropertySymbols, supportedArgumentsType };
@@ -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/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/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,10 @@
1
1
  'use strict';
2
2
 
3
- function eq(value, other) {
3
+ function eq(value, other, strictCheck) {
4
+ if (strictCheck === void 0) { strictCheck = false; }
5
+ if (strictCheck) {
6
+ return Object.is(value, other);
7
+ }
4
8
  return value === other || (value !== value && other !== other);
5
9
  }
6
10
 
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,4 @@ 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.VERSION = "1.2.0";
@@ -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/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/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.0",
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;
@@ -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;
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';
@@ -1,14 +1,17 @@
1
1
  /**
2
- * 创建唯一值的数组,该数组包含 2 个数组参数都包含的元素(交集)。使用了 [`SameValueZero`](https://tc39.es/ecma262/#sec-samevaluezero) 做等值比较。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
2
+ * 创建唯一值的数组,该数组包含 2 个数组参数都包含的元素(交集)。如果传入迭代函数,会调用数组的每个元素以产生唯一性计算的标准。
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.intersection
8
10
  * @since 1.0.0
9
11
  * @param {Array} array 要检查的数组。
10
12
  * @param {Array} other 另一个要检查的数组。
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
  * intersection([{x: 1}, {x: 1}, {x: 2}, {x: 2}], [{x: 1}], 'x'); // [{x: 1}]
23
26
  *
27
+ * intersection([-0, 0], [0]); // [-0]
28
+ *
29
+ * intersection([-0, 0], [0], undefined, true); // [0]
30
+ *
24
31
  */
25
- declare function intersection<T, F extends (value: T) => any, K extends keyof T>(array: T[], other: T[], iteratee?: F | K): T[];
32
+ declare function intersection<T, F extends (value: T) => any, K extends keyof T>(array: T[], other: T[], iteratee?: F | K, strictCheck?: boolean): T[];
26
33
  export default intersection;
@@ -8,13 +8,13 @@
8
8
  * @returns {boolean} 如果值为类数组对象,返回 `true` ,否则返回 `false` 。
9
9
  * @example
10
10
  *
11
- * isArrayLike([1, 2, 3]); // true
11
+ * isArrayLikeObject([1, 2, 3]); // true
12
12
  *
13
- * isArrayLike(document.body.children); // true
13
+ * isArrayLikeObject(document.body.children); // true
14
14
  *
15
- * isArrayLike('abc'); // false
15
+ * isArrayLikeObject('abc'); // false
16
16
  *
17
- * isArrayLike(()=>{}); // false
17
+ * isArrayLikeObject(()=>{}); // false
18
18
  *
19
19
  */
20
20
  declare function isArrayLikeObject(value: any): boolean;
@@ -11,7 +11,7 @@
11
11
  * @returns {boolean} 如果值为 `buffer` ,返回 `true` ,否则返回 `false` 。
12
12
  * @example
13
13
  *
14
- * isBuffer(new Blob(['a'])); // true
14
+ * isBuffer(new Buffer(2)); // true
15
15
  *
16
16
  * isBuffer({}); // false
17
17
  *
@@ -0,0 +1,15 @@
1
+ /**
2
+ * 检查值是否为 `DataView` 对象。
3
+ *
4
+ * @static
5
+ * @alias module:Type.isDataView
6
+ * @since 1.2.0
7
+ * @param {*} value 要检查的值。
8
+ * @returns {boolean} 如果值为 `DataView` 对象,返回 `true` ,否则返回 `false` 。
9
+ * @example
10
+ *
11
+ * isDataView(new DataView(new ArrayBuffer(8))); // true
12
+ *
13
+ */
14
+ declare function isDataView(value: any): boolean;
15
+ export default isDataView;
@@ -14,11 +14,11 @@
14
14
  *
15
15
  * isPlainObject(new Foo); // false
16
16
  *
17
- * isObject([1,2,3]); // false
17
+ * isPlainObject([1,2,3]); // false
18
18
  *
19
- * isObject({ a: 1, b: 2 }); // true
19
+ * isPlainObject({ a: 1, b: 2 }); // true
20
20
  *
21
- * isObject(Object.create(null)); // true
21
+ * isPlainObject(Object.create(null)); // true
22
22
  *
23
23
  */
24
24
  declare function isPlainObject(value: any): boolean;
@@ -9,9 +9,9 @@
9
9
  * @returns {boolean} 如果值为类型化数组,返回 `true` ,否则返回 `false` 。
10
10
  * @example
11
11
  *
12
- * ut2.isTypedArray(new Uint8Array); // true
12
+ * isTypedArray(new Uint8Array); // true
13
13
  *
14
- * ut2.isTypedArray([]); // false
14
+ * isTypedArray([]); // false
15
15
  *
16
16
  */
17
17
  declare function isTypedArray(value: any): boolean;
@@ -0,0 +1,24 @@
1
+ /**
2
+ * 创建一个只能调用 `func` 一次的函数。重复调用将返回第一次调用 `func` 的结果。
3
+ *
4
+ * @static
5
+ * @alias module:Function.once
6
+ * @since 1.2.0
7
+ * @requires module:Function.before
8
+ * @param {Function} func 限制执行的函数。
9
+ * @returns {Function} 新的限定函数。
10
+ * @example
11
+ *
12
+ * let count = 0;
13
+ *
14
+ * const increment = _.once(()=>{
15
+ * return ++count;
16
+ * });
17
+ *
18
+ * increment(); // 1
19
+ * increment(); // 1
20
+ * increment(); // 1
21
+ *
22
+ */
23
+ declare function once<T extends (...args: any[]) => any>(func: T): T;
24
+ export default once;
@@ -8,21 +8,21 @@
8
8
  * @returns {number} 转换后的数字。
9
9
  * @example
10
10
  *
11
- * toSafeInteger(3.2); // 3.2
11
+ * toFinite(3.2); // 3.2
12
12
  *
13
- * toSafeInteger('3.2'); // 3.2
13
+ * toFinite('3.2'); // 3.2
14
14
  *
15
- * toSafeInteger(-0); // -0
15
+ * toFinite(-0); // -0
16
16
  *
17
- * toSafeInteger('-0'); // -0
17
+ * toFinite('-0'); // -0
18
18
  *
19
- * toSafeInteger('0'); // 0
19
+ * toFinite('0'); // 0
20
20
  *
21
- * toSafeInteger(NaN); // 0
21
+ * toFinite(NaN); // 0
22
22
  *
23
- * toSafeInteger(Infinity); // 1.7976931348623157e+308
23
+ * toFinite(Infinity); // 1.7976931348623157e+308
24
24
  *
25
- * toSafeInteger(-Infinity); // -1.7976931348623157e+308
25
+ * toFinite(-Infinity); // -1.7976931348623157e+308
26
26
  *
27
27
  */
28
28
  declare function toFinite(value: any): number;