UNPKG

1.93 kBJavaScriptView Raw
1'use strict';
2
3Object.defineProperty(exports, '__esModule', { value: true });
4
5var veho = require('veho');
6
7/** @typedef {{head:*[],rows:*[][]}} TableObject */
8
9/**
10 *
11 * @param {*[]} head
12 * @param {*[][]} rows
13 * @returns {TableObject}
14 */
15
16const slice = ({
17 head,
18 rows
19}) => ({
20 head,
21 rows
22});
23/**
24 *
25 * @param {*[]} head
26 * @param {*[][]} rows
27 * @returns {TableObject}
28 */
29
30const shallow = ({
31 head,
32 rows
33}) => ({
34 head: head.slice(),
35 rows: rows.map(row => row.slice())
36});
37/**
38 *
39 * @param {*[]} head
40 * @param {*[][]} rows
41 * @returns {TableObject}
42 */
43
44const clone = ({
45 head,
46 rows
47}) => ({
48 head: head.slice(),
49 rows: veho.Mx.clone(rows)
50});
51
52/**
53 *
54 * @param {Object} o
55 * @returns {TableObject}
56 */
57
58const matchSlice = (o = {}) => {
59 var _o$head, _o$rows;
60
61 const head = (_o$head = o.head) !== null && _o$head !== void 0 ? _o$head : o.banner,
62 rows = (_o$rows = o.rows) !== null && _o$rows !== void 0 ? _o$rows : o.matrix;
63 return {
64 head,
65 rows
66 };
67};
68/**
69 *
70 * @param {Object} o
71 * @returns {TableObject}
72 */
73
74const matchShallow = (o = {}) => {
75 var _o$head2, _o$rows2;
76
77 const head = (_o$head2 = o.head) !== null && _o$head2 !== void 0 ? _o$head2 : o.banner,
78 rows = (_o$rows2 = o.rows) !== null && _o$rows2 !== void 0 ? _o$rows2 : o.matrix;
79 return {
80 head: head.slice(),
81 rows: rows.map(row => row.slice())
82 };
83};
84/**
85 *
86 * @param {Object} o
87 * @returns {TableObject}
88 */
89
90const matchClone = (o = {}) => {
91 var _o$head3, _o$rows3;
92
93 const head = (_o$head3 = o.head) !== null && _o$head3 !== void 0 ? _o$head3 : o.banner,
94 rows = (_o$rows3 = o.rows) !== null && _o$rows3 !== void 0 ? _o$rows3 : o.matrix;
95 return {
96 head: head.slice(),
97 rows: veho.Mx.clone(rows)
98 };
99};
100
101exports.clone = clone;
102exports.matchClone = matchClone;
103exports.matchShallow = matchShallow;
104exports.matchSlice = matchSlice;
105exports.shallow = shallow;
106exports.slice = slice;