-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtasks.js
83 lines (71 loc) · 1.74 KB
/
tasks.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import bigCartesianLib from 'big-cartesian'
import cartesianLib from 'cartesian'
import cartesianProductLib from 'cartesian-product'
import { CXProduct } from 'cxproduct'
import fastCartesianProductLib from 'fast-cartesian-product'
import lodash from 'lodash'
// eslint-disable-next-line import/no-unassigned-import
import 'lodash.product'
import PowerCartesianProduct from 'power-cartesian-product'
import fastCartesianLib from 'fast-cartesian'
// eslint-disable-next-line fp/no-let, init-declarations
let matrix
// Retrieve matrix used as argument based on the input, e.g. [4, 16]
const beforeAll = ({ size: [length, secondLength] }) => {
const array = Array.from({ length: secondLength }, getIndex)
// eslint-disable-next-line fp/no-mutation
matrix = Array.from({ length }, () => array)
}
const getIndex = (_, index) => index
export const fastCartesianMain = {
beforeAll,
main: () => {
fastCartesianLib(matrix)
},
}
export const bigCartesian = {
beforeAll,
main: () => {
;[...bigCartesianLib(matrix)]
},
}
export const fastCartesianProduct = {
beforeAll,
main: () => {
fastCartesianProductLib(matrix)
},
}
export const cartesianProduct = {
beforeAll,
main: () => {
cartesianProductLib(matrix)
},
}
export const powerCartesianProduct = {
beforeAll,
main: () => {
;[...new PowerCartesianProduct(matrix)]
},
}
export const cartesian = {
beforeAll,
main: () => {
cartesianLib(matrix)
},
}
export const lodashProduct = {
beforeAll,
main: () => {
lodash.product(...matrix)
},
}
export const cxProduct = {
beforeAll,
main: () => {
const array = []
new CXProduct(matrix).forEach((value) => {
// eslint-disable-next-line fp/no-mutating-methods
array.push(value)
})
},
}