a-js-tools 0.5.4 → 0.6.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
@@ -27,6 +27,14 @@ npm install a-js-tools --save
27
27
  - `toLowerCamelCase` 转化为小驼峰
28
28
  - `toSplitCase` 转化为连接符分隔
29
29
 
30
+ ## 数组相关
31
+
32
+ - `intersection` 方法,计算两个数组的交集(两个数组共有的元素)
33
+ - `union` 方法,计算两个数组的并集(两个数组合并在一起并去重)
34
+ - `difference` 方法,计算两个数组的差集(以第一个数组为基准)
35
+ - `symmetricDifference` 方法,计算两个数组的对称差集(在两个数组都不共有的元素)
36
+ - `enArr` 对象,包含上面的方法
37
+
30
38
  ## 查看文档
31
39
 
32
- 产看 [https://earthnut.dev/a-js-tools](https://earthnut.dev/a-js-tools)
40
+ 查看 [https://earthnut.dev/a-js-tools](https://earthnut.dev/a-js-tools)
package/cjs/index.cjs CHANGED
@@ -7,7 +7,12 @@ var performance = require('./src/performance.cjs');
7
7
  var escapeRegExp = require('./src/regexp/escapeRegExp.cjs');
8
8
  var autoEscapedRegExp = require('./src/regexp/autoEscapedRegExp.cjs');
9
9
  var isNode = require('./src/isNode.cjs');
10
- var createConstructor = require('./src/createConstructor.cjs');
10
+ var createConstructor = require('./src/object/createConstructor.cjs');
11
+ var index = require('./src/array/index.cjs');
12
+ var intersection = require('./src/array/intersection.cjs');
13
+ var union = require('./src/array/union.cjs');
14
+ var difference = require('./src/array/difference.cjs');
15
+ var symmetricDifference = require('./src/array/symmetricDifference.cjs');
11
16
 
12
17
 
13
18
 
@@ -23,3 +28,8 @@ exports.autoEscapedRegExp = autoEscapedRegExp.autoEscapedRegExp;
23
28
  exports.isBrowser = isNode.isBrowser;
24
29
  exports.isNode = isNode.isNode;
25
30
  exports.createConstructor = createConstructor.createConstructor;
31
+ exports.enArr = index.enArr;
32
+ exports.intersection = intersection.intersection;
33
+ exports.union = union.union;
34
+ exports.difference = difference.difference;
35
+ exports.symmetricDifference = symmetricDifference.symmetricDifference;
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+
5
+ /**
6
+ * 求给出的两个数组的差值(A - B)
7
+ *
8
+ * @param a - 第一个数组
9
+ * @param b - 第二个数组
10
+ * @throws {TypeError} 当两个参数有一个不是
11
+ * @description 当两个参数有一个不是数组时将抛出
12
+ * @returns 返回第一个参数相对第二个参数的差值
13
+ * @example
14
+ *
15
+ * ```ts
16
+ * import { difference} from 'a-js-tools';
17
+ *
18
+ * const log = console.log;
19
+ *
20
+ *
21
+ * log(difference([], [1, 2, 3])); // []
22
+ *
23
+ * log([1, 2, 3], []); //[1, 2, 3]
24
+ *
25
+ * log([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5]); //[6, 7]
26
+ *
27
+ * // 将抛出 TypeError
28
+ * log(difference([1, 2, 3], 'a'));
29
+ * log(difference([1, 2, 3], 1));
30
+ * log(difference([1, 2, 3], undefined));
31
+ * log(difference([1, 2, 3], null));
32
+ * log(difference([1, 2, 3], true));
33
+ * ```
34
+ *
35
+ */
36
+ function difference(a, b) {
37
+ if (!aTypeOfJs.isArray(a) || !aTypeOfJs.isArray(b)) {
38
+ throw new TypeError('参数需为数组');
39
+ }
40
+ if (a.length === 0 || b.length === 0) {
41
+ return a;
42
+ }
43
+ /** 获取两个数组中长度较小的 */
44
+ // 参数有顺序要求
45
+ // const [shorter, longer] = a.length > b.length ? [b, a] : [a, b];
46
+ // const shorterSet = new Set(shorter);
47
+ const bSet = new Set(b);
48
+ return a.filter(i => !bSet.has(i));
49
+ }
50
+
51
+ exports.difference = difference;
@@ -0,0 +1,19 @@
1
+ 'use strict';
2
+
3
+ var intersection = require('./intersection.cjs');
4
+ var union = require('./union.cjs');
5
+ var difference = require('./difference.cjs');
6
+ var symmetricDifference = require('./symmetricDifference.cjs');
7
+
8
+ const enArr = {
9
+ union: union.union,
10
+ intersection: intersection.intersection,
11
+ difference: difference.difference,
12
+ symmetricDifference: symmetricDifference.symmetricDifference,
13
+ };
14
+
15
+ exports.intersection = intersection.intersection;
16
+ exports.union = union.union;
17
+ exports.difference = difference.difference;
18
+ exports.symmetricDifference = symmetricDifference.symmetricDifference;
19
+ exports.enArr = enArr;
@@ -0,0 +1,45 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+
5
+ /**
6
+ *
7
+ * 两个数组的交集
8
+ *
9
+ * @param a 数组 1️⃣
10
+ * @param b 数组 2️⃣
11
+ * @returns 返回两个数组的交集
12
+ * @example
13
+ *
14
+ * ```ts
15
+ * import { intersection } from 'a-js-tools';
16
+ *
17
+ * const log = console.log;
18
+ *
19
+ *
20
+ * log(intersection([1, 2, 3, 4], [2, 3])); // [2, 3]
21
+ * log(intersection([1, 3, 5, 7], [2, 3, 4])); // [3]
22
+ *
23
+ * ```
24
+ *
25
+ */
26
+ function intersection(a, b) {
27
+ if (!aTypeOfJs.isArray(a) || !aTypeOfJs.isArray(b)) {
28
+ throw new TypeError('参数必须是数组类型数据');
29
+ }
30
+ // 任意数组为空,则返回空数组
31
+ if (a.length === 0 || b.length === 0) {
32
+ return [];
33
+ }
34
+ /**
35
+ * 在实际运算中, new Set() 的 开销为 O(n) ,filter 的开销也为 O(n)
36
+ *
37
+ * 但是以较短的数组创建 Set ,可以节省内存开销
38
+ */
39
+ const [shorter, longer] = a.length <= b.length ? [a, b] : [b, a];
40
+ // 提前创建工具 Set
41
+ const shortSet = new Set(shorter);
42
+ return longer.filter(item => shortSet.has(item));
43
+ }
44
+
45
+ exports.intersection = intersection;
@@ -0,0 +1,51 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+ var difference = require('./difference.cjs');
5
+
6
+ /**
7
+ *
8
+ * 对称差集 ( A △ B)
9
+ *
10
+ * @param a - 数组 a
11
+ * @param b - 数组 b
12
+ * @returns - 返回一个全新的数组
13
+ *
14
+ * @example
15
+ *
16
+ * ```ts
17
+ * import { symmetricDifference } from 'a-js-tools';
18
+ *
19
+ * const log = console.log;
20
+ *
21
+ * log(symmetricDifference([1, 2], [2, 3])); // [1, 3]
22
+ *
23
+ * log(symmetricDifference([1, 2, 3], [1, 2, 4])); // [3, 4]
24
+ *
25
+ * log(symmetricDifference([1, 2, 3], [1, 2, 3])); // []
26
+ *
27
+ *
28
+ * /// TypeError
29
+ * log(symmetricDifference(1, []));
30
+ * log(symmetricDifference(undefined, []));
31
+ * log(symmetricDifference(null, []));
32
+ * log(symmetricDifference('a', []));
33
+ * log(symmetricDifference(true, []));
34
+ *
35
+ * ```
36
+ *
37
+ */
38
+ function symmetricDifference(a, b) {
39
+ if (!aTypeOfJs.isArray(a) || !aTypeOfJs.isArray(b)) {
40
+ throw new TypeError('参数必须是数组');
41
+ }
42
+ if (a.length === 0) {
43
+ return [...b];
44
+ }
45
+ if (b.length === 0) {
46
+ return [...a];
47
+ }
48
+ return [...difference.difference(a, b), ...difference.difference(b, a)];
49
+ }
50
+
51
+ exports.symmetricDifference = symmetricDifference;
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var aTypeOfJs = require('a-type-of-js');
4
+
5
+ /**
6
+ *
7
+ * 数组的并集
8
+ *
9
+ * <span style="color:#f36;">请注意,参数有不为数组时直接抛出 TypeError</span>
10
+ * @param arrays - 多个数组
11
+ * @returns 联合后的数组
12
+ *
13
+ *
14
+ * @example
15
+ *
16
+ * ```ts
17
+ * import { union } from 'a-js-tools';
18
+ *
19
+ * const log = console.log;
20
+ *
21
+ * // []
22
+ * log(union());
23
+ *
24
+ * // [1, 2, 3]
25
+ * log(union([1, 2, 3]));
26
+ *
27
+ * // TypeError
28
+ * log(union([1, 2, 3], 'i'));
29
+ * log(union([1, 2, 3], undefined));
30
+ * log(union([1, 2, 3], null));
31
+ * log(union([1, 2, 3], 4));
32
+ * log(union([1, 2, 3], {}));
33
+ * log(union([1, 2, 3], false));
34
+ *
35
+ * // [1, 2, 3, 4, 6]
36
+ * log(union([1, 2, 3], [2, 4, 6]));
37
+ *
38
+ * // [1, 2, 3, 4, 6]
39
+ * log(union([1, 2, 3], [2, 4, 6], [1, 2, 3]));
40
+ *
41
+ * // [1, 2, 3, 4, 6]
42
+ * log(union([1, 2, 3], [2, 4, 6], [1, 2, 3], [1, 2, 3]));
43
+ * ```
44
+ *
45
+ */
46
+ function union(...arrays) {
47
+ if (arrays.length === 0) {
48
+ return [];
49
+ }
50
+ if (arrays.some(i => !aTypeOfJs.isArray(i))) {
51
+ throw new TypeError('参数必须都是数组形式的元素');
52
+ }
53
+ if (arrays.length === 1) {
54
+ return [...arrays[0]];
55
+ }
56
+ const resultSet = new Set();
57
+ for (const array of arrays) {
58
+ for (const item of array) {
59
+ resultSet.add(item);
60
+ }
61
+ }
62
+ return Array.from(resultSet);
63
+ }
64
+
65
+ exports.union = union;
package/mjs/index.mjs CHANGED
@@ -5,4 +5,9 @@ export { debounce, throttle } from './src/performance.mjs';
5
5
  export { escapeRegExp } from './src/regexp/escapeRegExp.mjs';
6
6
  export { autoEscapedRegExp } from './src/regexp/autoEscapedRegExp.mjs';
7
7
  export { isBrowser, isNode } from './src/isNode.mjs';
8
- export { createConstructor } from './src/createConstructor.mjs';
8
+ export { createConstructor } from './src/object/createConstructor.mjs';
9
+ export { enArr } from './src/array/index.mjs';
10
+ export { intersection } from './src/array/intersection.mjs';
11
+ export { union } from './src/array/union.mjs';
12
+ export { difference } from './src/array/difference.mjs';
13
+ export { symmetricDifference } from './src/array/symmetricDifference.mjs';
@@ -0,0 +1,49 @@
1
+ import { isArray } from 'a-type-of-js';
2
+
3
+ /**
4
+ * 求给出的两个数组的差值(A - B)
5
+ *
6
+ * @param a - 第一个数组
7
+ * @param b - 第二个数组
8
+ * @throws {TypeError} 当两个参数有一个不是
9
+ * @description 当两个参数有一个不是数组时将抛出
10
+ * @returns 返回第一个参数相对第二个参数的差值
11
+ * @example
12
+ *
13
+ * ```ts
14
+ * import { difference} from 'a-js-tools';
15
+ *
16
+ * const log = console.log;
17
+ *
18
+ *
19
+ * log(difference([], [1, 2, 3])); // []
20
+ *
21
+ * log([1, 2, 3], []); //[1, 2, 3]
22
+ *
23
+ * log([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5]); //[6, 7]
24
+ *
25
+ * // 将抛出 TypeError
26
+ * log(difference([1, 2, 3], 'a'));
27
+ * log(difference([1, 2, 3], 1));
28
+ * log(difference([1, 2, 3], undefined));
29
+ * log(difference([1, 2, 3], null));
30
+ * log(difference([1, 2, 3], true));
31
+ * ```
32
+ *
33
+ */
34
+ function difference(a, b) {
35
+ if (!isArray(a) || !isArray(b)) {
36
+ throw new TypeError('参数需为数组');
37
+ }
38
+ if (a.length === 0 || b.length === 0) {
39
+ return a;
40
+ }
41
+ /** 获取两个数组中长度较小的 */
42
+ // 参数有顺序要求
43
+ // const [shorter, longer] = a.length > b.length ? [b, a] : [a, b];
44
+ // const shorterSet = new Set(shorter);
45
+ const bSet = new Set(b);
46
+ return a.filter(i => !bSet.has(i));
47
+ }
48
+
49
+ export { difference };
@@ -0,0 +1,13 @@
1
+ import { intersection } from './intersection.mjs';
2
+ import { union } from './union.mjs';
3
+ import { difference } from './difference.mjs';
4
+ import { symmetricDifference } from './symmetricDifference.mjs';
5
+
6
+ const enArr = {
7
+ union,
8
+ intersection,
9
+ difference,
10
+ symmetricDifference,
11
+ };
12
+
13
+ export { difference, enArr, intersection, symmetricDifference, union };
@@ -0,0 +1,43 @@
1
+ import { isArray } from 'a-type-of-js';
2
+
3
+ /**
4
+ *
5
+ * 两个数组的交集
6
+ *
7
+ * @param a 数组 1️⃣
8
+ * @param b 数组 2️⃣
9
+ * @returns 返回两个数组的交集
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import { intersection } from 'a-js-tools';
14
+ *
15
+ * const log = console.log;
16
+ *
17
+ *
18
+ * log(intersection([1, 2, 3, 4], [2, 3])); // [2, 3]
19
+ * log(intersection([1, 3, 5, 7], [2, 3, 4])); // [3]
20
+ *
21
+ * ```
22
+ *
23
+ */
24
+ function intersection(a, b) {
25
+ if (!isArray(a) || !isArray(b)) {
26
+ throw new TypeError('参数必须是数组类型数据');
27
+ }
28
+ // 任意数组为空,则返回空数组
29
+ if (a.length === 0 || b.length === 0) {
30
+ return [];
31
+ }
32
+ /**
33
+ * 在实际运算中, new Set() 的 开销为 O(n) ,filter 的开销也为 O(n)
34
+ *
35
+ * 但是以较短的数组创建 Set ,可以节省内存开销
36
+ */
37
+ const [shorter, longer] = a.length <= b.length ? [a, b] : [b, a];
38
+ // 提前创建工具 Set
39
+ const shortSet = new Set(shorter);
40
+ return longer.filter(item => shortSet.has(item));
41
+ }
42
+
43
+ export { intersection };
@@ -0,0 +1,49 @@
1
+ import { isArray } from 'a-type-of-js';
2
+ import { difference } from './difference.mjs';
3
+
4
+ /**
5
+ *
6
+ * 对称差集 ( A △ B)
7
+ *
8
+ * @param a - 数组 a
9
+ * @param b - 数组 b
10
+ * @returns - 返回一个全新的数组
11
+ *
12
+ * @example
13
+ *
14
+ * ```ts
15
+ * import { symmetricDifference } from 'a-js-tools';
16
+ *
17
+ * const log = console.log;
18
+ *
19
+ * log(symmetricDifference([1, 2], [2, 3])); // [1, 3]
20
+ *
21
+ * log(symmetricDifference([1, 2, 3], [1, 2, 4])); // [3, 4]
22
+ *
23
+ * log(symmetricDifference([1, 2, 3], [1, 2, 3])); // []
24
+ *
25
+ *
26
+ * /// TypeError
27
+ * log(symmetricDifference(1, []));
28
+ * log(symmetricDifference(undefined, []));
29
+ * log(symmetricDifference(null, []));
30
+ * log(symmetricDifference('a', []));
31
+ * log(symmetricDifference(true, []));
32
+ *
33
+ * ```
34
+ *
35
+ */
36
+ function symmetricDifference(a, b) {
37
+ if (!isArray(a) || !isArray(b)) {
38
+ throw new TypeError('参数必须是数组');
39
+ }
40
+ if (a.length === 0) {
41
+ return [...b];
42
+ }
43
+ if (b.length === 0) {
44
+ return [...a];
45
+ }
46
+ return [...difference(a, b), ...difference(b, a)];
47
+ }
48
+
49
+ export { symmetricDifference };
@@ -0,0 +1,63 @@
1
+ import { isArray } from 'a-type-of-js';
2
+
3
+ /**
4
+ *
5
+ * 数组的并集
6
+ *
7
+ * <span style="color:#f36;">请注意,参数有不为数组时直接抛出 TypeError</span>
8
+ * @param arrays - 多个数组
9
+ * @returns 联合后的数组
10
+ *
11
+ *
12
+ * @example
13
+ *
14
+ * ```ts
15
+ * import { union } from 'a-js-tools';
16
+ *
17
+ * const log = console.log;
18
+ *
19
+ * // []
20
+ * log(union());
21
+ *
22
+ * // [1, 2, 3]
23
+ * log(union([1, 2, 3]));
24
+ *
25
+ * // TypeError
26
+ * log(union([1, 2, 3], 'i'));
27
+ * log(union([1, 2, 3], undefined));
28
+ * log(union([1, 2, 3], null));
29
+ * log(union([1, 2, 3], 4));
30
+ * log(union([1, 2, 3], {}));
31
+ * log(union([1, 2, 3], false));
32
+ *
33
+ * // [1, 2, 3, 4, 6]
34
+ * log(union([1, 2, 3], [2, 4, 6]));
35
+ *
36
+ * // [1, 2, 3, 4, 6]
37
+ * log(union([1, 2, 3], [2, 4, 6], [1, 2, 3]));
38
+ *
39
+ * // [1, 2, 3, 4, 6]
40
+ * log(union([1, 2, 3], [2, 4, 6], [1, 2, 3], [1, 2, 3]));
41
+ * ```
42
+ *
43
+ */
44
+ function union(...arrays) {
45
+ if (arrays.length === 0) {
46
+ return [];
47
+ }
48
+ if (arrays.some(i => !isArray(i))) {
49
+ throw new TypeError('参数必须都是数组形式的元素');
50
+ }
51
+ if (arrays.length === 1) {
52
+ return [...arrays[0]];
53
+ }
54
+ const resultSet = new Set();
55
+ for (const array of arrays) {
56
+ for (const item of array) {
57
+ resultSet.add(item);
58
+ }
59
+ }
60
+ return Array.from(resultSet);
61
+ }
62
+
63
+ export { union };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "type": "module",
3
- "version": "0.5.4",
3
+ "version": "0.6.0",
4
4
  "name": "a-js-tools",
5
5
  "description": "一点点 🤏 js 函数",
6
6
  "license": "ISC",
package/types/index.d.ts CHANGED
@@ -3,5 +3,6 @@ export { throttle, debounce } from './src/performance';
3
3
  export type { DebounceAndThrottleReturnType } from './src/performance';
4
4
  export { escapeRegExp, autoEscapedRegExp } from './src/regexp';
5
5
  export { isBrowser, isNode } from './src/isNode';
6
- export { createConstructor } from './src/createConstructor';
7
- export type { CreateConstructor } from './src/createConstructor';
6
+ export { createConstructor } from './src/object/createConstructor';
7
+ export type { CreateConstructor } from './src/object/createConstructor';
8
+ export { intersection, enArr, union, difference, symmetricDifference, } from './src/array/';
@@ -0,0 +1,32 @@
1
+ /**
2
+ * 求给出的两个数组的差值(A - B)
3
+ *
4
+ * @param a - 第一个数组
5
+ * @param b - 第二个数组
6
+ * @throws {TypeError} 当两个参数有一个不是
7
+ * @description 当两个参数有一个不是数组时将抛出
8
+ * @returns 返回第一个参数相对第二个参数的差值
9
+ * @example
10
+ *
11
+ * ```ts
12
+ * import { difference} from 'a-js-tools';
13
+ *
14
+ * const log = console.log;
15
+ *
16
+ *
17
+ * log(difference([], [1, 2, 3])); // []
18
+ *
19
+ * log([1, 2, 3], []); //[1, 2, 3]
20
+ *
21
+ * log([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5]); //[6, 7]
22
+ *
23
+ * // 将抛出 TypeError
24
+ * log(difference([1, 2, 3], 'a'));
25
+ * log(difference([1, 2, 3], 1));
26
+ * log(difference([1, 2, 3], undefined));
27
+ * log(difference([1, 2, 3], null));
28
+ * log(difference([1, 2, 3], true));
29
+ * ```
30
+ *
31
+ */
32
+ export declare function difference<T>(a: T[], b: T[]): T[];
@@ -0,0 +1,11 @@
1
+ import { intersection } from './intersection';
2
+ import { union } from './union';
3
+ import { difference } from './difference';
4
+ import { symmetricDifference } from './symmetricDifference';
5
+ export { union, intersection, difference, symmetricDifference };
6
+ export declare const enArr: {
7
+ union: typeof union;
8
+ intersection: typeof intersection;
9
+ difference: typeof difference;
10
+ symmetricDifference: typeof symmetricDifference;
11
+ };
@@ -0,0 +1,22 @@
1
+ /**
2
+ *
3
+ * 两个数组的交集
4
+ *
5
+ * @param a 数组 1️⃣
6
+ * @param b 数组 2️⃣
7
+ * @returns 返回两个数组的交集
8
+ * @example
9
+ *
10
+ * ```ts
11
+ * import { intersection } from 'a-js-tools';
12
+ *
13
+ * const log = console.log;
14
+ *
15
+ *
16
+ * log(intersection([1, 2, 3, 4], [2, 3])); // [2, 3]
17
+ * log(intersection([1, 3, 5, 7], [2, 3, 4])); // [3]
18
+ *
19
+ * ```
20
+ *
21
+ */
22
+ export declare function intersection<T>(a: T[], b: T[]): T[];
@@ -0,0 +1,33 @@
1
+ /**
2
+ *
3
+ * 对称差集 ( A △ B)
4
+ *
5
+ * @param a - 数组 a
6
+ * @param b - 数组 b
7
+ * @returns - 返回一个全新的数组
8
+ *
9
+ * @example
10
+ *
11
+ * ```ts
12
+ * import { symmetricDifference } from 'a-js-tools';
13
+ *
14
+ * const log = console.log;
15
+ *
16
+ * log(symmetricDifference([1, 2], [2, 3])); // [1, 3]
17
+ *
18
+ * log(symmetricDifference([1, 2, 3], [1, 2, 4])); // [3, 4]
19
+ *
20
+ * log(symmetricDifference([1, 2, 3], [1, 2, 3])); // []
21
+ *
22
+ *
23
+ * /// TypeError
24
+ * log(symmetricDifference(1, []));
25
+ * log(symmetricDifference(undefined, []));
26
+ * log(symmetricDifference(null, []));
27
+ * log(symmetricDifference('a', []));
28
+ * log(symmetricDifference(true, []));
29
+ *
30
+ * ```
31
+ *
32
+ */
33
+ export declare function symmetricDifference<T>(a: T[], b: T[]): T[];
@@ -0,0 +1,42 @@
1
+ /**
2
+ *
3
+ * 数组的并集
4
+ *
5
+ * <span style="color:#f36;">请注意,参数有不为数组时直接抛出 TypeError</span>
6
+ * @param arrays - 多个数组
7
+ * @returns 联合后的数组
8
+ *
9
+ *
10
+ * @example
11
+ *
12
+ * ```ts
13
+ * import { union } from 'a-js-tools';
14
+ *
15
+ * const log = console.log;
16
+ *
17
+ * // []
18
+ * log(union());
19
+ *
20
+ * // [1, 2, 3]
21
+ * log(union([1, 2, 3]));
22
+ *
23
+ * // TypeError
24
+ * log(union([1, 2, 3], 'i'));
25
+ * log(union([1, 2, 3], undefined));
26
+ * log(union([1, 2, 3], null));
27
+ * log(union([1, 2, 3], 4));
28
+ * log(union([1, 2, 3], {}));
29
+ * log(union([1, 2, 3], false));
30
+ *
31
+ * // [1, 2, 3, 4, 6]
32
+ * log(union([1, 2, 3], [2, 4, 6]));
33
+ *
34
+ * // [1, 2, 3, 4, 6]
35
+ * log(union([1, 2, 3], [2, 4, 6], [1, 2, 3]));
36
+ *
37
+ * // [1, 2, 3, 4, 6]
38
+ * log(union([1, 2, 3], [2, 4, 6], [1, 2, 3], [1, 2, 3]));
39
+ * ```
40
+ *
41
+ */
42
+ export declare function union<T>(...arrays: T[][]): T[];