@vuu-ui/vuu-utils 0.5.10 → 0.5.14
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/LICENSE +201 -0
- package/cjs/index.js +2 -0
- package/cjs/index.js.map +7 -0
- package/esm/index.js +2 -0
- package/esm/index.js.map +7 -0
- package/package.json +13 -12
- package/types/packages/vuu-utils/src/DataWindow.d.ts +39 -0
- package/types/packages/vuu-utils/src/array-utils.d.ts +3 -0
- package/types/packages/vuu-utils/src/column-utils.d.ts +32 -0
- package/types/packages/vuu-utils/src/data-utils.d.ts +9 -0
- package/types/packages/vuu-utils/src/date-utils.d.ts +1 -0
- package/types/packages/vuu-utils/src/event-emitter.d.ts +19 -0
- package/types/packages/vuu-utils/src/getUniqueId.d.ts +1 -0
- package/{src/index.ts → types/packages/vuu-utils/src/index.d.ts} +0 -0
- package/types/packages/vuu-utils/src/input-utils.d.ts +2 -0
- package/types/packages/vuu-utils/src/invariant.d.ts +1 -0
- package/types/packages/vuu-utils/src/nanoid/index.d.ts +1 -0
- package/types/packages/vuu-utils/src/range-utils.d.ts +21 -0
- package/types/packages/vuu-utils/src/round-decimal.d.ts +1 -0
- package/types/packages/vuu-utils/src/row-utils.d.ts +10 -0
- package/types/packages/vuu-utils/src/sort-utils.d.ts +5 -0
- package/types/packages/vuu-utils/src/text-utils.d.ts +1 -0
- package/types/showcase/src/examples/DataGrid/columnMetaData.d.ts +233 -0
- package/src/DataWindow.ts +0 -111
- package/src/array-utils.ts +0 -37
- package/src/column-utils.ts +0 -224
- package/src/data-utils.ts +0 -60
- package/src/date-utils.ts +0 -4
- package/src/event-emitter.ts +0 -139
- package/src/getUniqueId.ts +0 -1
- package/src/input-utils.ts +0 -50
- package/src/invariant.ts +0 -10
- package/src/nanoid/index.ts +0 -30
- package/src/range-utils.ts +0 -72
- package/src/round-decimal.ts +0 -126
- package/src/row-utils.ts +0 -44
- package/src/sort-utils.ts +0 -71
- package/src/text-utils.ts +0 -9
- package/test/DataWindow.test.ts +0 -108
- package/tsconfig-emit-types.json +0 -10
package/test/DataWindow.test.ts
DELETED
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
import { beforeEach, describe, expect, it } from "vitest";
|
|
2
|
-
import { DataRow, DataWindow } from "../src/DataWindow";
|
|
3
|
-
|
|
4
|
-
describe("DataWindow", () => {
|
|
5
|
-
let dataWindow: DataWindow;
|
|
6
|
-
|
|
7
|
-
beforeEach(() => {
|
|
8
|
-
dataWindow = new DataWindow({ from: 0, to: 10 });
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
it("is initialised with a array large enough to store data in range", () => {
|
|
12
|
-
expect(dataWindow.data.length).to.equal(10);
|
|
13
|
-
});
|
|
14
|
-
|
|
15
|
-
describe("addRow", () => {
|
|
16
|
-
it("ignores rows outside current range", () => {
|
|
17
|
-
dataWindow.setRowCount(100);
|
|
18
|
-
const row: DataRow = [100];
|
|
19
|
-
dataWindow.add(row);
|
|
20
|
-
expect(dataWindow.data.length).to.equal(10);
|
|
21
|
-
expect(dataWindow.data.findIndex((d) => d === row)).to.equal(-1);
|
|
22
|
-
});
|
|
23
|
-
|
|
24
|
-
it("adds a row to internal data, at location determined by row index", () => {
|
|
25
|
-
dataWindow.setRowCount(100);
|
|
26
|
-
const row0: DataRow = [0];
|
|
27
|
-
const row1: DataRow = [1];
|
|
28
|
-
const row2: DataRow = [2];
|
|
29
|
-
dataWindow.add(row0);
|
|
30
|
-
dataWindow.add(row1);
|
|
31
|
-
dataWindow.add(row2);
|
|
32
|
-
expect(dataWindow.data.length).to.equal(10);
|
|
33
|
-
expect(dataWindow.data.findIndex((d) => d === row0)).to.equal(0);
|
|
34
|
-
expect(dataWindow.data.findIndex((d) => d === row1)).to.equal(1);
|
|
35
|
-
expect(dataWindow.data.findIndex((d) => d === row2)).to.equal(2);
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
describe("setRange", () => {
|
|
40
|
-
it("discards rows outside the new range", () => {
|
|
41
|
-
dataWindow.setRowCount(100);
|
|
42
|
-
const rows = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9].map(
|
|
43
|
-
(index) => [index] as DataRow
|
|
44
|
-
);
|
|
45
|
-
rows.forEach((row) => dataWindow.add(row));
|
|
46
|
-
dataWindow.setRange(5, 15);
|
|
47
|
-
expect(dataWindow.data.length).to.equal(10);
|
|
48
|
-
expect(dataWindow.data[0][0]).to.equal(5);
|
|
49
|
-
expect(dataWindow.data[4][0]).to.equal(9);
|
|
50
|
-
expect(dataWindow.data[5]).to.equal(undefined);
|
|
51
|
-
});
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
describe("getAtIndex", () => {
|
|
55
|
-
it("returns the row at specified index", () => {
|
|
56
|
-
dataWindow.setRowCount(100);
|
|
57
|
-
const row0: DataRow = [0];
|
|
58
|
-
dataWindow.add(row0);
|
|
59
|
-
const result = dataWindow.getAtIndex(0);
|
|
60
|
-
expect(result).to.equal(row0);
|
|
61
|
-
});
|
|
62
|
-
|
|
63
|
-
it("translates index to correct offset within current window", () => {
|
|
64
|
-
dataWindow.setRowCount(100);
|
|
65
|
-
const row8: DataRow = [8];
|
|
66
|
-
dataWindow.add(row8);
|
|
67
|
-
dataWindow.setRange(5, 15);
|
|
68
|
-
const result = dataWindow.getAtIndex(8);
|
|
69
|
-
expect(result).to.equal(row8);
|
|
70
|
-
});
|
|
71
|
-
});
|
|
72
|
-
|
|
73
|
-
describe("isWithinRange", () => {
|
|
74
|
-
it("checks index against current window", () => {
|
|
75
|
-
dataWindow.setRowCount(100);
|
|
76
|
-
expect(dataWindow.isWithinRange(0)).to.equal(true);
|
|
77
|
-
expect(dataWindow.isWithinRange(5)).to.equal(true);
|
|
78
|
-
expect(dataWindow.isWithinRange(9)).to.equal(true);
|
|
79
|
-
expect(dataWindow.isWithinRange(10)).to.equal(false);
|
|
80
|
-
dataWindow.setRange(5, 15);
|
|
81
|
-
expect(dataWindow.isWithinRange(0)).to.equal(false);
|
|
82
|
-
expect(dataWindow.isWithinRange(5)).to.equal(true);
|
|
83
|
-
expect(dataWindow.isWithinRange(9)).to.equal(true);
|
|
84
|
-
expect(dataWindow.isWithinRange(10)).to.equal(true);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe("setRowCount", () => {
|
|
89
|
-
it("starts at 0", () => {
|
|
90
|
-
expect(dataWindow.rowCount).toEqual(0);
|
|
91
|
-
});
|
|
92
|
-
it("stores rowCount", () => {
|
|
93
|
-
dataWindow.setRowCount(100);
|
|
94
|
-
expect(dataWindow.rowCount).toEqual(100);
|
|
95
|
-
});
|
|
96
|
-
it("does not affect data, when rowCount greater than current range", () => {
|
|
97
|
-
dataWindow.setRowCount(100);
|
|
98
|
-
expect(dataWindow.data.length).toEqual(10);
|
|
99
|
-
});
|
|
100
|
-
it("truncates data, when rowCount less than current range", () => {
|
|
101
|
-
dataWindow.setRowCount(4);
|
|
102
|
-
expect(dataWindow.data.length).toEqual(4);
|
|
103
|
-
expect(dataWindow.isWithinRange(5)).to.equal(false);
|
|
104
|
-
});
|
|
105
|
-
});
|
|
106
|
-
// describe("hasData", () => {});
|
|
107
|
-
// describe("getData", () => {});
|
|
108
|
-
});
|