Skip to content

Commit 9e562d4

Browse files
committed
update hyperapp to 2.0.3
1 parent b4df679 commit 9e562d4

File tree

4 files changed

+206
-249
lines changed

4 files changed

+206
-249
lines changed

frameworks/keyed/hyperapp/package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
2-
"name": "hyperapp-v1.2.0-js-benchmark",
2+
"name": "hyperapp-v2.0.3-js-benchmark",
33
"version": "1.0.0",
4-
"description": "hyperapp v1.2.0 js benchmark",
4+
"description": "hyperapp v2.0.3 js benchmark",
55
"main": "index.js",
66
"js-framework-benchmark": {
77
"frameworkVersionFromPackage": "hyperapp"
88
},
99
"dependencies": {
10-
"hyperapp": "1.2.9"
10+
"hyperapp": "2.0.3"
1111
},
1212
"devDependencies": {
1313
"babel-core": "^6.26.0",

frameworks/keyed/hyperapp/src/index.js

Lines changed: 81 additions & 117 deletions
Original file line numberDiff line numberDiff line change
@@ -2,124 +2,88 @@ import { h, app } from "hyperapp"
22
import { state, actions } from "./store"
33
import RowsView from "./rowsView"
44

5-
let startTime
6-
let lastMeasure
7-
8-
function startMeasure(name, cb) {
9-
startTime = performance.now()
10-
lastMeasure = name
11-
cb()
12-
}
13-
14-
function stopMeasure() {
15-
const last = lastMeasure
16-
17-
if (lastMeasure) {
18-
window.setTimeout(
19-
function metaStopMeasure() {
20-
lastMeasure = null
21-
const stop = performance.now()
22-
const duration = 0
23-
console.log(last + " took " + (stop - startTime))
24-
},
25-
0
26-
)
27-
}
28-
}
29-
30-
function view(state, actions) {
31-
stopMeasure()
32-
33-
return (
34-
<div class="container">
35-
<div class="jumbotron">
36-
<div class="row">
37-
<div class="col-md-6">
38-
<h1>HyperApp</h1>
39-
</div>
40-
<div class="col-md-6">
41-
<div class="row">
42-
<div class="col-sm-6 smallpad">
43-
<button
44-
type="button"
45-
class="btn btn-primary btn-block"
46-
id="run"
47-
onclick={_ =>
48-
startMeasure("run", actions.run)}>
49-
Create 1,000 rows
50-
</button>
51-
</div>
52-
<div class="col-sm-6 smallpad">
53-
<button
54-
type="button"
55-
class="btn btn-primary btn-block"
56-
id="runlots"
57-
onclick={_ =>
58-
startMeasure(
59-
"runLots",
60-
actions.runLots
61-
)}>
62-
Create 10,000 rows
63-
</button>
64-
</div>
65-
<div class="col-sm-6 smallpad">
66-
<button
67-
type="button"
68-
class="btn btn-primary btn-block"
69-
id="add"
70-
onclick={_ =>
71-
startMeasure("add", actions.add)}>
72-
Append 1,000 rows
73-
</button>
74-
</div>
75-
<div class="col-sm-6 smallpad">
76-
<button
77-
type="button"
78-
class="btn btn-primary btn-block"
79-
id="update"
80-
onclick={_ =>
81-
startMeasure("update", actions.update)}>
82-
Update every 10th row
83-
</button>
84-
</div>
85-
<div class="col-sm-6 smallpad">
86-
<button
87-
type="button"
88-
class="btn btn-primary btn-block"
89-
id="clear"
90-
onclick={_ =>
91-
startMeasure("clear", actions.clear)}>
92-
Clear
93-
</button>
94-
</div>
95-
<div class="col-sm-6 smallpad">
96-
<button
97-
type="button"
98-
class="btn btn-primary btn-block"
99-
id="swaprows"
100-
onclick={_ =>
101-
startMeasure(
102-
"swapRows",
103-
actions.swapRows
104-
)}>
105-
Swap Rows
106-
</button>
107-
</div>
108-
</div>
109-
</div>
110-
</div>
5+
function view(state) {
6+
return (
7+
<div class="container">
8+
<div class="jumbotron">
9+
<div class="row">
10+
<div class="col-md-6">
11+
<h1>HyperApp</h1>
12+
</div>
13+
<div class="col-md-6">
14+
<div class="row">
15+
<div class="col-sm-6 smallpad">
16+
<button
17+
type="button"
18+
class="btn btn-primary btn-block"
19+
id="run"
20+
onclick={actions.run}
21+
>
22+
Create 1,000 rows
23+
</button>
24+
</div>
25+
<div class="col-sm-6 smallpad">
26+
<button
27+
type="button"
28+
class="btn btn-primary btn-block"
29+
id="runlots"
30+
onclick={actions.runLots}
31+
>
32+
Create 10,000 rows
33+
</button>
34+
</div>
35+
<div class="col-sm-6 smallpad">
36+
<button
37+
type="button"
38+
class="btn btn-primary btn-block"
39+
id="add"
40+
onclick={actions.add}
41+
>
42+
Append 1,000 rows
43+
</button>
44+
</div>
45+
<div class="col-sm-6 smallpad">
46+
<button
47+
type="button"
48+
class="btn btn-primary btn-block"
49+
id="update"
50+
onclick={actions.update}
51+
>
52+
Update every 10th row
53+
</button>
54+
</div>
55+
<div class="col-sm-6 smallpad">
56+
<button
57+
type="button"
58+
class="btn btn-primary btn-block"
59+
id="clear"
60+
onclick={actions.clear}
61+
>
62+
Clear
63+
</button>
64+
</div>
65+
<div class="col-sm-6 smallpad">
66+
<button
67+
type="button"
68+
class="btn btn-primary btn-block"
69+
id="swaprows"
70+
onclick={actions.swapRows}
71+
>
72+
Swap Rows
73+
</button>
74+
</div>
11175
</div>
112-
<table class="table table-hover table-striped test-data">
113-
<tbody>
114-
<RowsView state={state} actions={actions} />
115-
</tbody>
116-
</table>
117-
<span
118-
class="preloadicon glyphicon glyphicon-remove"
119-
aria-hidden="true"
120-
/>
76+
</div>
12177
</div>
122-
)
78+
</div>
79+
<table class="table table-hover table-striped test-data">
80+
<tbody>
81+
<RowsView data={state.data} selected={state.selected} />
82+
</tbody>
83+
</table>
84+
<span class="preloadicon glyphicon glyphicon-remove" aria-hidden="true" />
85+
</div>
86+
)
12387
}
12488

125-
app(state, actions, view, document.getElementById("main"))
89+
app({ init: state, view, node: document.getElementById("main") })

frameworks/keyed/hyperapp/src/rowsView.js

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
import { h } from "hyperapp"
2+
import { actions } from "./store"
23

3-
export default ({ state, actions }) => state.data.map(({ id, label }, i) =>
4-
<tr key={id} class={id === state.selected ? "danger" : ""}>
4+
export default ({ data, selected }) => data.map(({ id, label }, i) =>
5+
<tr key={id} class={id === selected ? "danger" : ""}>
56
<td class="col-md-1">{id}</td>
67
<td class="col-md-4">
7-
<a onclick={_ => actions.select(id)}>{label}</a>
8+
<a onclick={[actions.select, id]}>{label}</a>
89
</td>
910
<td class="col-md-1">
10-
<a onclick={_ => actions.delete(id)}>
11+
<a onclick={[actions.delete, id]}>
1112
<span class="glyphicon glyphicon-remove" aria-hidden="true">
1213
</span>
1314
</a>

0 commit comments

Comments
 (0)