This repository was archived by the owner on May 19, 2023. It is now read-only.
File tree 3 files changed +22
-20
lines changed
3 files changed +22
-20
lines changed Original file line number Diff line number Diff line change 1
1
import { DIRECTIVE_PREFIX , UnknownKV } from '../models/generics' ;
2
2
import { Directives , ASTNode , ASTNodeType } from '../models/structs' ;
3
3
import { rawDirectiveSplitRE } from './utils/patterns' ;
4
- import timeSlice from './utils/timeSlice ' ;
4
+ import concurrent from './utils/concurrent ' ;
5
5
6
6
import { renderDirective } from './directive' ;
7
7
@@ -14,10 +14,9 @@ const render = (
14
14
if ( typeof changedProps === 'string' ) changedProps = [ changedProps ] ;
15
15
const legalDirectiveNames = Object . keys ( directives ) ;
16
16
17
- timeSlice ( function * ( ) {
18
- for ( let i = 0 ; i < ast . length ; i ++ ) {
17
+ function * traverse ( ) {
18
+ for ( const node of ast ) {
19
19
yield ;
20
- const node = ast [ i ] ;
21
20
if ( node . type === ASTNodeType . NULL ) continue ;
22
21
23
22
const isStatic = node . type === ASTNodeType . STATIC ;
@@ -47,6 +46,7 @@ const render = (
47
46
node,
48
47
state,
49
48
} ;
49
+ yield ;
50
50
renderDirective ( directiveProps , directives ) ;
51
51
52
52
if ( isStaticDirective || isMaskDirective ) {
@@ -58,7 +58,9 @@ const render = (
58
58
}
59
59
}
60
60
}
61
- } ) ( ) ;
61
+ }
62
+
63
+ concurrent ( traverse ) ( ) ;
62
64
} ;
63
65
64
66
export default render ;
Original file line number Diff line number Diff line change
1
+ export const concurrent = ( generatorFunction : ( ) => Generator < undefined , void , unknown > ) => {
2
+ const generator = generatorFunction ( ) ;
3
+ return function next ( ) {
4
+ const start = performance . now ( ) ;
5
+ let task = null ;
6
+ do {
7
+ task = generator . next ( ) ;
8
+ } while ( performance . now ( ) - start < 20 && ! task . done ) ;
9
+
10
+ if ( task . done ) return ;
11
+ setTimeout ( next ) ;
12
+ } ;
13
+ } ;
14
+
15
+ export default concurrent ;
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments