1 | import { compareText as _compareText } from '../../utils/string'
|
2 | import { factory } from '../../utils/factory'
|
3 | import { createAlgorithm14 } from '../../type/matrix/utils/algorithm14'
|
4 | import { createAlgorithm13 } from '../../type/matrix/utils/algorithm13'
|
5 |
|
6 | const name = 'compareText'
|
7 | const dependencies = [
|
8 | 'typed',
|
9 | 'matrix'
|
10 | ]
|
11 |
|
12 | export const createCompareText = factory(name, dependencies, ({ typed, matrix }) => {
|
13 | const algorithm13 = createAlgorithm13({ typed })
|
14 | const algorithm14 = createAlgorithm14({ typed })
|
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 | const compareText = typed(name, {
|
45 |
|
46 | 'any, any': _compareText,
|
47 |
|
48 | 'DenseMatrix, DenseMatrix': function (x, y) {
|
49 | return algorithm13(x, y, _compareText)
|
50 | },
|
51 |
|
52 | 'Array, Array': function (x, y) {
|
53 |
|
54 | return compareText(matrix(x), matrix(y)).valueOf()
|
55 | },
|
56 |
|
57 | 'Array, Matrix': function (x, y) {
|
58 |
|
59 | return compareText(matrix(x), y)
|
60 | },
|
61 |
|
62 | 'Matrix, Array': function (x, y) {
|
63 |
|
64 | return compareText(x, matrix(y))
|
65 | },
|
66 |
|
67 | 'DenseMatrix, any': function (x, y) {
|
68 | return algorithm14(x, y, _compareText, false)
|
69 | },
|
70 |
|
71 | 'any, DenseMatrix': function (x, y) {
|
72 | return algorithm14(y, x, _compareText, true)
|
73 | },
|
74 |
|
75 | 'Array, any': function (x, y) {
|
76 |
|
77 | return algorithm14(matrix(x), y, _compareText, false).valueOf()
|
78 | },
|
79 |
|
80 | 'any, Array': function (x, y) {
|
81 |
|
82 | return algorithm14(matrix(y), x, _compareText, true).valueOf()
|
83 | }
|
84 | })
|
85 |
|
86 | return compareText
|
87 | })
|
88 |
|
89 | export const createCompareTextNumber = factory(name, ['typed'], ({ typed }) => {
|
90 | return typed(name, {
|
91 | 'any, any': _compareText
|
92 | })
|
93 | })
|