@@ -14,10 +14,10 @@ export const createVanillaTemporal = <TState>(
1414 pastStates : options ?. pastStates || [ ] ,
1515 futureStates : options ?. futureStates || [ ] ,
1616 undo : ( steps = 1 ) => {
17- // Fastest way to clone an array on Chromium. Needed to create a new array reference
18- const pastStates = get ( ) . pastStates . slice ( ) ;
19- const futureStates = get ( ) . futureStates . slice ( ) ;
20- if ( pastStates . length ) {
17+ if ( get ( ) . pastStates . length ) {
18+ // Fastest way to clone an array on Chromium. Needed to create a new array reference
19+ const pastStates = get ( ) . pastStates . slice ( ) ;
20+ const futureStates = get ( ) . futureStates . slice ( ) ;
2121 // Based on the steps, get values from the pastStates array and push them to the futureStates array
2222 while ( steps -- ) {
2323 const pastState = pastStates . pop ( ) ;
@@ -30,10 +30,10 @@ export const createVanillaTemporal = <TState>(
3030 }
3131 } ,
3232 redo : ( steps = 1 ) => {
33- // Fastest way to clone an array on Chromium. Needed to create a new array reference
34- const pastStates = get ( ) . pastStates . slice ( ) ;
35- const futureStates = get ( ) . futureStates . slice ( ) ;
36- if ( futureStates . length ) {
33+ if ( get ( ) . futureStates . length ) {
34+ // Fastest way to clone an array on Chromium. Needed to create a new array reference
35+ const pastStates = get ( ) . pastStates . slice ( ) ;
36+ const futureStates = get ( ) . futureStates . slice ( ) ;
3737 // https://stackoverflow.com/questions/5349425/whats-the-fastest-way-to-loop-through-an-array-in-javascript
3838 // https://stackoverflow.com/a/10993837/9931154
3939 // Based on the steps, get values from the futureStates array and push them to the pastStates array
0 commit comments