Skip to content

Commit 050707f

Browse files
committed
Merge branch 'mutraction' of https://github.com/tomtheisen/js-framework-benchmark-mutraction into tomtheisen-mutraction
2 parents c4cd5c3 + 699a082 commit 050707f

File tree

3 files changed

+18
-18
lines changed

3 files changed

+18
-18
lines changed

frameworks/non-keyed/mutraction/package-lock.json

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

frameworks/non-keyed/mutraction/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"build-prod": "npm run build",
1414
"build": "npx tsc && npm run transform && npm run bundle",
1515
"transform": "npx babel out -d out2",
16-
"bundle": "npx esbuild out2/index.js --bundle --format=esm --outfile=dist/index.js"
16+
"bundle": "npx esbuild out2/index.js --bundle --format=esm --outfile=dist/index.js --minify"
1717
},
1818
"author": "Tom Theisen",
1919
"license": "MIT",
@@ -25,6 +25,6 @@
2525
"typescript": "^5.1.6"
2626
},
2727
"dependencies": {
28-
"mutraction-dom": "0.24.0"
28+
"mutraction-dom": "0.25.0"
2929
}
3030
}

frameworks/non-keyed/mutraction/src/index.tsx

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,46 +1,46 @@
11
import { track, defaultTracker, ForEach } from "mutraction-dom";
22
import { buildData, type RowItem } from "./build-dummy-data.js";
3-
4-
defaultTracker.setOptions({ trackHistory: false });
3+
defaultTracker.setOptions({ trackHistory: false, compactOnCommit: false });
54

65
const model = track({
7-
items: [] as RowItem[],
86
selected: undefined as RowItem | undefined,
97
});
8+
const items = track([] as RowItem[]);
109

1110
function select(item: RowItem) {
1211
model.selected = item;
1312
}
1413

1514
function create(n: number) {
16-
model.items.splice(0, model.items.length, ...buildData(n));
15+
items.splice(0, items.length, ...buildData(n));
1716
}
1817

1918
function append(n: number) {
20-
model.items.push(...buildData(n));
19+
items.push(...buildData(n));
2120
}
2221

2322
function update() {
2423
defaultTracker.startTransaction();
25-
for (let i = 0; i < model.items.length; i += 10) {
26-
model.items[i].label += " !!!";
24+
for (let i = 0, found = 0; i < items.length; i++) {
25+
if (!(i in items)) continue;
26+
if (found++ % 10 === 0) items[i].label += " !!!";
2727
}
2828
defaultTracker.commit();
2929
}
3030

3131
function clear() {
32-
model.items.length = 0;
32+
items.length = 0;
3333
}
3434

3535
function swapRows() {
36-
if (model.items.length > 998) {
36+
if (items.length > 998) {
3737
const i1 = 1, i2 = 998;
38-
[model.items[i1], model.items[i2]] = [model.items[i2], model.items[i1]];
38+
[items[i1], items[i2]] = [items[i2], items[i1]];
3939
}
4040
}
4141

4242
function remove(i: number) {
43-
model.items.splice(i, 1);
43+
delete items[i];
4444
}
4545

4646
const app =
@@ -76,7 +76,7 @@ const app =
7676
</div>
7777
<table className="table table-hover table-striped test-data">
7878
<tbody id="tbody">
79-
{ ForEach(model.items, (item, i) =>
79+
{ ForEach(items, (item, i) =>
8080
<tr classList={{ danger: item === model.selected }}>
8181
<td className="col-md-1">{ item.id }</td>
8282
<td className="col-md-4">

0 commit comments

Comments
 (0)