Skip to content

Commit a0890ac

Browse files
committed
feat: add alins
1 parent d011937 commit a0890ac

File tree

12 files changed

+616
-0
lines changed

12 files changed

+616
-0
lines changed

frameworks/keyed/alins/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
* @Author: chenzhongsheng
3+
* @Date: 2023-08-10 15:16:55
4+
* @Description: Coding something
5+
-->
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
<head>
9+
<meta charset="UTF-8">
10+
<title>Alins</title>
11+
<link href="/css/currentStyle.css" rel="stylesheet"/>
12+
</head>
13+
<body>
14+
<!-- <script src="alins.iife.min.js"></script> -->
15+
<div id="main" class="container"></div>
16+
<script src='dist/main.js'></script>
17+
</body>
18+
</html>

frameworks/keyed/alins/package.json

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "js-framework-benchmark-keyed-alins",
3+
"version": "1.0.0",
4+
"description": "Benchmark for alins framework",
5+
"js-framework-benchmark": {
6+
"frameworkVersion": "0.0.28",
7+
"frameworkHomeURL": ""
8+
},
9+
"keywords": [
10+
"alins"
11+
],
12+
"scripts": {
13+
"build-dev": "rollup -c -w",
14+
"build-prod": "rollup -c --environment production"
15+
},
16+
"devDependencies": {
17+
"rollup": "2.45.2",
18+
"alins": "0.0.28",
19+
"rollup-plugin-commonjs": "10.0.0",
20+
"rollup-plugin-node-resolve": "5.0.3",
21+
"rollup-plugin-svelte": "7.1.0",
22+
"rollup-plugin-terser": "7.0.2",
23+
"rollup-plugin-alins": "0.0.27"
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* @Author: chenzhongsheng
3+
* @Date: 2023-09-07 11:54:42
4+
* @Description: Coding something
5+
*/
6+
import alins from 'rollup-plugin-alins';
7+
import resolve from 'rollup-plugin-node-resolve';
8+
import commonjs from 'rollup-plugin-commonjs';
9+
import { terser } from 'rollup-plugin-terser';
10+
11+
const plugins = [resolve(), commonjs(), alins()];
12+
13+
if (process.env.production) {
14+
plugins.push(terser());
15+
}
16+
17+
export default {
18+
input: 'src/main.js',
19+
output: {
20+
file: 'dist/main.js',
21+
format: 'iife',
22+
name: 'main'
23+
},
24+
plugins
25+
};

frameworks/keyed/alins/src/app.jsx

Lines changed: 159 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,159 @@
1+
2+
3+
/*
4+
* @Author: chenzhongsheng
5+
* @Date: 2023-08-10 16:07:29
6+
* @Description: Coding something
7+
*/
8+
import {buildData} from './data';
9+
10+
let selected = -1;
11+
let rows = [];
12+
function add () {
13+
rows.push(...buildData());
14+
}
15+
16+
window.selected = ()=>{
17+
selected;
18+
debugger;
19+
}
20+
21+
function remove (id) {
22+
rows.splice(
23+
rows.findIndex((d) => d.id === id),
24+
1
25+
);
26+
}
27+
28+
function select (id) {
29+
selected = id;
30+
}
31+
32+
function run () {
33+
rows = buildData();
34+
selected = -1;
35+
}
36+
37+
function update () {
38+
const n = rows.length;
39+
for (let i = 0; i < n; i += 10) {
40+
rows[i].label += ' !!!';
41+
}
42+
}
43+
44+
function runLots () {
45+
rows = buildData(10000);
46+
console.timeEnd();
47+
}
48+
49+
function clear () {
50+
rows = [];
51+
selected = -1;
52+
}
53+
54+
function swapRows () {
55+
if (rows.length > 998) {
56+
const d1 = rows[1];
57+
rows[1] = rows[998];
58+
rows[998] = d1;
59+
}
60+
}
61+
62+
document.body.appendChild(<div>
63+
<div class="jumbotron">
64+
<div class="row">
65+
<div class="col-md-6">
66+
<h1>Alins (keyed)</h1>
67+
</div>
68+
<div class="col-md-6">
69+
<div class="row">
70+
<div class="col-sm-6 smallpad">
71+
<button
72+
type="button"
73+
class="btn btn-primary btn-block"
74+
id="run"
75+
onclick={run}
76+
>
77+
Create 1,000 rows
78+
</button>
79+
</div>
80+
<div class="col-sm-6 smallpad">
81+
<button
82+
type="button"
83+
class="btn btn-primary btn-block"
84+
id="runlots"
85+
onclick={runLots}
86+
>
87+
Create 10,000 rows
88+
</button>
89+
</div>
90+
<div class="col-sm-6 smallpad">
91+
<button
92+
type="button"
93+
class="btn btn-primary btn-block"
94+
id="add"
95+
onclick={add}
96+
>
97+
Append 1,000 rows
98+
</button>
99+
</div>
100+
<div class="col-sm-6 smallpad">
101+
<button
102+
type="button"
103+
class="btn btn-primary btn-block"
104+
id="update"
105+
onclick={update}
106+
>
107+
Update every 10th row
108+
</button>
109+
</div>
110+
<div class="col-sm-6 smallpad">
111+
<button
112+
type="button"
113+
class="btn btn-primary btn-block"
114+
id="clear"
115+
onclick={clear}
116+
>
117+
Clear
118+
</button>
119+
</div>
120+
<div class="col-sm-6 smallpad">
121+
<button
122+
type="button"
123+
class="btn btn-primary btn-block"
124+
id="swaprows"
125+
onclick={swapRows}
126+
>
127+
Swap Rows
128+
</button>
129+
</div>
130+
</div>
131+
</div>
132+
</div>
133+
</div>
134+
<table class="table table-hover table-striped test-data">
135+
<tbody>
136+
<For data={rows}>
137+
<tr
138+
class={{danger: $item.id === selected}}
139+
data-label={$item.label}
140+
>
141+
<td class="col-md-1">{ $item.id }</td>
142+
<td class="col-md-4">
143+
<a onclick={() => select($item.id)}>{ $item.label }</a>
144+
</td>
145+
<td class="col-md-1">
146+
<a onclick={() => remove($item.id)}>
147+
<span class="glyphicon glyphicon-remove" aria-hidden="true"></span>
148+
</a>
149+
</td>
150+
<td class="col-md-6"></td>
151+
</tr>
152+
</For>
153+
</tbody>
154+
</table>
155+
<span
156+
class="preloadicon glyphicon glyphicon-remove"
157+
aria-hidden="true"
158+
></span>
159+
</div>);

frameworks/keyed/alins/src/data.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
let ID = 1
2+
3+
function _random(max) {
4+
return Math.round(Math.random() * 1000) % max
5+
}
6+
7+
export function buildData(count = 1000) {
8+
const adjectives = [
9+
'pretty',
10+
'large',
11+
'big',
12+
'small',
13+
'tall',
14+
'short',
15+
'long',
16+
'handsome',
17+
'plain',
18+
'quaint',
19+
'clean',
20+
'elegant',
21+
'easy',
22+
'angry',
23+
'crazy',
24+
'helpful',
25+
'mushy',
26+
'odd',
27+
'unsightly',
28+
'adorable',
29+
'important',
30+
'inexpensive',
31+
'cheap',
32+
'expensive',
33+
'fancy'
34+
]
35+
const colours = [
36+
'red',
37+
'yellow',
38+
'blue',
39+
'green',
40+
'pink',
41+
'brown',
42+
'purple',
43+
'brown',
44+
'white',
45+
'black',
46+
'orange'
47+
]
48+
const nouns = [
49+
'table',
50+
'chair',
51+
'house',
52+
'bbq',
53+
'desk',
54+
'car',
55+
'pony',
56+
'cookie',
57+
'sandwich',
58+
'burger',
59+
'pizza',
60+
'mouse',
61+
'keyboard'
62+
]
63+
const data = []
64+
for (let i = 0; i < count; i++)
65+
data.push({
66+
id: ID++,
67+
label:
68+
adjectives[_random(adjectives.length)] +
69+
' ' +
70+
colours[_random(colours.length)] +
71+
' ' +
72+
nouns[_random(nouns.length)]
73+
})
74+
return data
75+
}

frameworks/keyed/alins/src/main.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
/*
2+
* @Author: chenzhongsheng
3+
* @Date: 2023-08-10 15:16:55
4+
* @Description: Coding something
5+
*/
6+
import './app.jsx';

frameworks/non-keyed/alins/index.html

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<!--
2+
* @Author: chenzhongsheng
3+
* @Date: 2023-08-10 15:16:55
4+
* @Description: Coding something
5+
-->
6+
<!DOCTYPE html>
7+
<html lang="en">
8+
<head>
9+
<meta charset="UTF-8">
10+
<title>Alins</title>
11+
<link href="/css/currentStyle.css" rel="stylesheet"/>
12+
</head>
13+
<body>
14+
<!-- <script src="alins.iife.min.js"></script> -->
15+
<div id="main" class="container"></div>
16+
<script src='dist/main.js'></script>
17+
</body>
18+
</html>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
{
2+
"name": "js-framework-benchmark-non-keyed-alins",
3+
"version": "1.0.0",
4+
"description": "Benchmark for alins framework",
5+
"js-framework-benchmark": {
6+
"frameworkVersion": "0.0.28",
7+
"frameworkHomeURL": ""
8+
},
9+
"keywords": [
10+
"alins"
11+
],
12+
"scripts": {
13+
"build-dev": "rollup -c -w",
14+
"build-prod": "rollup -c --environment production"
15+
},
16+
"devDependencies": {
17+
"rollup": "2.45.2",
18+
"alins": "0.0.28",
19+
"rollup-plugin-commonjs": "10.0.0",
20+
"rollup-plugin-node-resolve": "5.0.3",
21+
"rollup-plugin-svelte": "7.1.0",
22+
"rollup-plugin-terser": "7.0.2",
23+
"rollup-plugin-alins": "0.0.27"
24+
}
25+
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
/*
2+
* @Author: chenzhongsheng
3+
* @Date: 2023-09-07 11:54:42
4+
* @Description: Coding something
5+
*/
6+
import alins from 'rollup-plugin-alins';
7+
import resolve from 'rollup-plugin-node-resolve';
8+
import commonjs from 'rollup-plugin-commonjs';
9+
import { terser } from 'rollup-plugin-terser';
10+
11+
const plugins = [resolve(), commonjs(), alins()];
12+
13+
if (process.env.production) {
14+
plugins.push(terser());
15+
}
16+
17+
export default {
18+
input: 'src/main.js',
19+
output: {
20+
file: 'dist/main.js',
21+
format: 'iife',
22+
name: 'main'
23+
},
24+
plugins
25+
};

0 commit comments

Comments
 (0)