@@ -12,51 +12,48 @@ import { build_getter } from '../../utils.js';
1212
1313export class Memoizer {
1414 /** @type {Array<{ id: Identifier, expression: Expression }> } */
15- sync = [ ] ;
15+ # sync = [ ] ;
1616
1717 /** @type {Array<{ id: Identifier, expression: Expression }> } */
18- async = [ ] ;
18+ # async = [ ] ;
1919
2020 /**
2121 * @param {Expression } expression
2222 * @param {boolean } has_await
2323 */
2424 add ( expression , has_await ) {
25- const id = b . id ( `#` ) ; // filled in later
25+ const id = b . id ( '#' ) ; // filled in later
2626
27- ( has_await ? this . async : this . sync ) . push ( { id, expression } ) ;
27+ ( has_await ? this . # async : this . # sync) . push ( { id, expression } ) ;
2828
2929 return id ;
3030 }
3131
3232 apply ( ) {
33- const all = [ ...this . async , ...this . sync ] ;
34-
35- all . forEach ( ( memo , i ) => {
33+ return [ ...this . #async, ...this . #sync] . map ( ( memo , i ) => {
3634 memo . id . name = `$${ i } ` ;
35+ return memo . id ;
3736 } ) ;
38-
39- return all ;
4037 }
4138
4239 deriveds ( runes = true ) {
43- return this . sync . map ( ( memo ) =>
40+ return this . # sync. map ( ( memo ) =>
4441 b . let ( memo . id , b . call ( runes ? '$.derived' : '$.derived_safe_equal' , b . thunk ( memo . expression ) ) )
4542 ) ;
4643 }
4744
4845 async_ids ( ) {
49- return this . async . map ( ( memo ) => memo . id ) ;
46+ return this . # async. map ( ( memo ) => memo . id ) ;
5047 }
5148
5249 async_values ( ) {
53- if ( this . async . length === 0 ) return ;
54- return b . array ( this . async . map ( ( memo ) => b . thunk ( memo . expression , true ) ) ) ;
50+ if ( this . # async. length === 0 ) return ;
51+ return b . array ( this . # async. map ( ( memo ) => b . thunk ( memo . expression , true ) ) ) ;
5552 }
5653
5754 sync_values ( ) {
58- if ( this . sync . length === 0 ) return ;
59- return b . array ( this . sync . map ( ( memo ) => b . thunk ( memo . expression ) ) ) ;
55+ if ( this . # sync. length === 0 ) return ;
56+ return b . array ( this . # sync. map ( ( memo ) => b . thunk ( memo . expression ) ) ) ;
6057 }
6158}
6259
@@ -163,13 +160,13 @@ export function build_template_chunk(
163160export function build_render_statement ( state ) {
164161 const { memoizer } = state ;
165162
166- const all = state . memoizer . apply ( ) ;
163+ const ids = state . memoizer . apply ( ) ;
167164
168165 return b . stmt (
169166 b . call (
170167 '$.template_effect' ,
171168 b . arrow (
172- all . map ( ( { id } ) => id ) ,
169+ ids ,
173170 state . update . length === 1 && state . update [ 0 ] . type === 'ExpressionStatement'
174171 ? state . update [ 0 ] . expression
175172 : b . block ( state . update )
0 commit comments