Skip to content
This repository was archived by the owner on Nov 17, 2024. It is now read-only.

Commit 5869274

Browse files
author
Cosmo Myzrail Gorynych
committed
⚡ Add mutators to timer blocks
1 parent 7f01545 commit 5869274

File tree

1 file changed

+26
-2
lines changed

1 file changed

+26
-2
lines changed

src/node_requires/catnip/stdLib/timers.ts

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,35 @@ const makeTimerGetter = (index: number): IBlockComputedDeclaration => ({
3737
});
3838

3939
const blocks: (IBlockCommandDeclaration | IBlockComputedDeclaration)[] = [];
40+
const setters: IBlockCommandDeclaration[] = [],
41+
getters: IBlockComputedDeclaration[] = [];
42+
4043
for (let i = 1; i <= 6; i++) {
41-
blocks.push(makeTimerSetter(i));
44+
const block = makeTimerSetter(i);
45+
blocks.push(block);
46+
setters.push(block);
4247
}
4348
for (let i = 1; i <= 6; i++) {
44-
blocks.push(makeTimerGetter(i));
49+
const block = makeTimerGetter(i);
50+
blocks.push(block);
51+
getters.push(block);
52+
}
53+
54+
for (const getter of getters) {
55+
getter.mutators = getters
56+
.filter(m => m.code !== getter.code)
57+
.map(g => ({
58+
lib: g.lib,
59+
code: g.code
60+
}));
61+
}
62+
for (const setter of setters) {
63+
setter.mutators = setters
64+
.filter(m => m.code !== setter.code)
65+
.map(s => ({
66+
lib: s.lib,
67+
code: s.code
68+
}));
4569
}
4670

4771
export default blocks;

0 commit comments

Comments
 (0)