ut2 1.11.6 → 1.12.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/index.js CHANGED
@@ -121,6 +121,7 @@ export { default as noop } from './noop.js';
121
121
  export { default as nthArg } from './nthArg.js';
122
122
  export { default as range } from './range.js';
123
123
  export { default as sleep } from './sleep.js';
124
+ export { default as list } from './list.js';
124
125
  export { default as times } from './times.js';
125
126
  export { default as toFinite } from './toFinite.js';
126
127
  export { default as toInteger } from './toInteger.js';
@@ -2,7 +2,7 @@ import isObjectLike from '../isObjectLike.js';
2
2
  import getTag from './getTag.js';
3
3
  import { argumentsTag, stringUndefined, functionProtoToString } from './native.js';
4
4
 
5
- var VERSION = "1.11.6";
5
+ var VERSION = "1.12.0";
6
6
  var isBrowser = typeof window !== stringUndefined && isObjectLike(window) && typeof document !== stringUndefined && isObjectLike(document) && window.document === document;
7
7
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
8
8
  var FUNC_ERROR_TEXT = 'Expected a function';
package/es/list.js ADDED
@@ -0,0 +1,22 @@
1
+ import identity from './identity.js';
2
+ import { MAX_SAFE_INTEGER, mathMin, mathFloor, MAX_ARRAY_LENGTH } from './internals/native.js';
3
+ import isInteger from './isInteger.js';
4
+ import isFinite from './isFinite.js';
5
+
6
+ var list = function (n, iteratee) {
7
+ if (iteratee === void 0) { iteratee = identity; }
8
+ if (n < 1 || n > MAX_SAFE_INTEGER) {
9
+ return [];
10
+ }
11
+ var index = 0;
12
+ var length = mathMin(isInteger(n) ? n : mathFloor(isFinite(n) ? n : 0), MAX_ARRAY_LENGTH);
13
+ var result = Array(length);
14
+ var func = typeof iteratee === 'function' ? iteratee : identity;
15
+ while (index < length) {
16
+ result[index] = func(index);
17
+ index++;
18
+ }
19
+ return result;
20
+ };
21
+
22
+ export { list as default };
package/es/times.js CHANGED
@@ -1,22 +1,5 @@
1
- import identity from './identity.js';
2
- import { MAX_SAFE_INTEGER, mathMin, mathFloor, MAX_ARRAY_LENGTH } from './internals/native.js';
3
- import isInteger from './isInteger.js';
4
- import isFinite from './isFinite.js';
1
+ import list from './list.js';
5
2
 
6
- var times = function (n, iteratee) {
7
- if (iteratee === void 0) { iteratee = identity; }
8
- if (n < 1 || n > MAX_SAFE_INTEGER) {
9
- return [];
10
- }
11
- var index = 0;
12
- var length = mathMin(isInteger(n) ? n : mathFloor(isFinite(n) ? n : 0), MAX_ARRAY_LENGTH);
13
- var result = Array(length);
14
- var func = typeof iteratee === 'function' ? iteratee : identity;
15
- while (index < length) {
16
- result[index] = func(index);
17
- index++;
18
- }
19
- return result;
20
- };
3
+ var times = list;
21
4
 
22
5
  export { times as default };
package/lib/index.js CHANGED
@@ -123,6 +123,7 @@ var noop = require('./noop.js');
123
123
  var nthArg = require('./nthArg.js');
124
124
  var range = require('./range.js');
125
125
  var sleep = require('./sleep.js');
126
+ var list = require('./list.js');
126
127
  var times = require('./times.js');
127
128
  var toFinite = require('./toFinite.js');
128
129
  var toInteger = require('./toInteger.js');
@@ -260,6 +261,7 @@ exports.noop = noop;
260
261
  exports.nthArg = nthArg;
261
262
  exports.range = range;
262
263
  exports.sleep = sleep;
264
+ exports.list = list;
263
265
  exports.times = times;
264
266
  exports.toFinite = toFinite;
265
267
  exports.toInteger = toInteger;
@@ -4,7 +4,7 @@ var isObjectLike = require('../isObjectLike.js');
4
4
  var getTag = require('./getTag.js');
5
5
  var native = require('./native.js');
6
6
 
7
- var VERSION = "1.11.6";
7
+ var VERSION = "1.12.0";
8
8
  var isBrowser = typeof window !== native.stringUndefined && isObjectLike(window) && typeof document !== native.stringUndefined && isObjectLike(document) && window.document === document;
9
9
  var supportedArgumentsType = getTag((function () { return arguments; })()) === native.argumentsTag;
10
10
  var FUNC_ERROR_TEXT = 'Expected a function';
package/lib/list.js ADDED
@@ -0,0 +1,24 @@
1
+ 'use strict';
2
+
3
+ var identity = require('./identity.js');
4
+ var native = require('./internals/native.js');
5
+ var isInteger = require('./isInteger.js');
6
+ var isFinite = require('./isFinite.js');
7
+
8
+ var list = function (n, iteratee) {
9
+ if (iteratee === void 0) { iteratee = identity; }
10
+ if (n < 1 || n > native.MAX_SAFE_INTEGER) {
11
+ return [];
12
+ }
13
+ var index = 0;
14
+ var length = native.mathMin(isInteger(n) ? n : native.mathFloor(isFinite(n) ? n : 0), native.MAX_ARRAY_LENGTH);
15
+ var result = Array(length);
16
+ var func = typeof iteratee === 'function' ? iteratee : identity;
17
+ while (index < length) {
18
+ result[index] = func(index);
19
+ index++;
20
+ }
21
+ return result;
22
+ };
23
+
24
+ module.exports = list;
package/lib/times.js CHANGED
@@ -1,24 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var identity = require('./identity.js');
4
- var native = require('./internals/native.js');
5
- var isInteger = require('./isInteger.js');
6
- var isFinite = require('./isFinite.js');
3
+ var list = require('./list.js');
7
4
 
8
- var times = function (n, iteratee) {
9
- if (iteratee === void 0) { iteratee = identity; }
10
- if (n < 1 || n > native.MAX_SAFE_INTEGER) {
11
- return [];
12
- }
13
- var index = 0;
14
- var length = native.mathMin(isInteger(n) ? n : native.mathFloor(isFinite(n) ? n : 0), native.MAX_ARRAY_LENGTH);
15
- var result = Array(length);
16
- var func = typeof iteratee === 'function' ? iteratee : identity;
17
- while (index < length) {
18
- result[index] = func(index);
19
- index++;
20
- }
21
- return result;
22
- };
5
+ var times = list;
23
6
 
24
7
  module.exports = times;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ut2",
3
- "version": "1.11.6",
3
+ "version": "1.12.0",
4
4
  "author": "caijf",
5
5
  "license": "MIT",
6
6
  "main": "lib/index.js",
package/types/index.d.ts CHANGED
@@ -175,6 +175,7 @@ export { default as noop } from './noop';
175
175
  export { default as nthArg } from './nthArg';
176
176
  export { default as range } from './range';
177
177
  export { default as sleep } from './sleep';
178
+ export { default as list } from './list';
178
179
  export { default as times } from './times';
179
180
  export { default as toFinite } from './toFinite';
180
181
  export { default as toInteger } from './toInteger';
@@ -17,5 +17,5 @@
17
17
  * isWindow(frames); // true
18
18
  *
19
19
  */
20
- declare function isWindow(value: any): value is Window & typeof globalThis;
20
+ declare function isWindow(value: any): value is Window;
21
21
  export default isWindow;
@@ -0,0 +1,28 @@
1
+ interface List {
2
+ <T>(n: number, iteratee: (index: number) => T): T[];
3
+ (n: number): number[];
4
+ }
5
+ /**
6
+ * 调用 `iteratee` `n` 次,每次调用返回的结果存入到数组中。
7
+ *
8
+ * `iteratee` 调用传入一个参数 `index`。
9
+ *
10
+ * *注:原方法名为 `times`,自 `v1.12.0` 版本调整为 `list`。*
11
+ *
12
+ * @function
13
+ * @alias module:Util.list
14
+ * @since 1.12.0
15
+ * @param {number} n 调用 `iteratee` 的次数。
16
+ * @param {Function} [iteratee=identity] 每次迭代调用的函数。默认 `identity`。
17
+ * @returns {Array} 调用结果的数组。
18
+ * @example
19
+ *
20
+ * list(3); // [0, 1, 2]
21
+ *
22
+ * list(3, String); // ['0', '1', '2']
23
+ *
24
+ * list(4, () => 0); // [0, 0, 0, 0]
25
+ *
26
+ */
27
+ declare const list: List;
28
+ export default list;
package/types/times.d.ts CHANGED
@@ -1,26 +1,8 @@
1
- interface Times {
2
- <T>(n: number, iteratee: (index: number) => T): T[];
3
- (n: number): number[];
4
- }
1
+ import list from './list';
2
+ type Times = typeof list;
5
3
  /**
6
- * 调用 `iteratee` `n` 次,每次调用返回的结果存入到数组中。
7
- *
8
- * `iteratee` 调用传入一个参数 `index`。
9
- *
10
- * @function
11
- * @alias module:Util.times
12
- * @since 1.0.0
13
- * @param {number} n 调用 `iteratee` 的次数。
14
- * @param {Function} [iteratee=identity] 每次迭代调用的函数。默认 `identity`。
15
- * @returns {Array} 调用结果的数组。
16
- * @example
17
- *
18
- * times(3); // [0, 1, 2]
19
- *
20
- * times(3, String); // ['0', '1', '2']
21
- *
22
- * times(4, () => 0); // [0, 0, 0, 0]
23
- *
4
+ * @private
5
+ * @deprecated 方法名调整为 `list` 。
24
6
  */
25
7
  declare const times: Times;
26
8
  export default times;