1 | import { cloneArray } from '@vect/clone';
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 | const slice = ({
|
13 | head,
|
14 | rows
|
15 | }) => ({
|
16 | head,
|
17 | rows
|
18 | });
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 | const shallow = ({
|
27 | head,
|
28 | rows
|
29 | }) => ({
|
30 | head: head.slice(),
|
31 | rows: rows.map(row => row.slice())
|
32 | });
|
33 |
|
34 |
|
35 |
|
36 |
|
37 |
|
38 |
|
39 |
|
40 | const clone = ({
|
41 | head,
|
42 | rows
|
43 | }) => ({
|
44 | head: head.slice(),
|
45 | rows: cloneArray(rows)
|
46 | });
|
47 |
|
48 |
|
49 |
|
50 |
|
51 |
|
52 |
|
53 |
|
54 |
|
55 |
|
56 |
|
57 |
|
58 | const matchSlice = (o = {}) => {
|
59 | const head = o.head ?? o.banner,
|
60 | rows = o.rows ?? o.matrix;
|
61 | return {
|
62 | head,
|
63 | rows
|
64 | };
|
65 | };
|
66 |
|
67 |
|
68 |
|
69 |
|
70 |
|
71 |
|
72 | const matchShallow = (o = {}) => {
|
73 | const head = o.head ?? o.banner,
|
74 | rows = o.rows ?? o.matrix;
|
75 | return {
|
76 | head: head.slice(),
|
77 | rows: rows.map(row => row.slice())
|
78 | };
|
79 | };
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 | const matchClone = (o = {}) => {
|
87 | const head = o.head ?? o.banner,
|
88 | rows = o.rows ?? o.matrix;
|
89 | return {
|
90 | head: head.slice(),
|
91 | rows: cloneArray(rows)
|
92 | };
|
93 | };
|
94 |
|
95 | export { clone, matchClone, matchShallow, matchSlice, shallow, slice };
|