This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Class that keeps history of a value ~ past values. | |
| */ | |
| export class Snapshot<T> { | |
| private readonly initial: T; | |
| private readonly value: T; | |
| private readonly history: Snapshot<T>[]; | |
| private readonly current: number; | |
| private constructor( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function snapshotToArray(snapshot) { | |
| let returnArr = []; | |
| snapshot.forEach(childSnapshot => { | |
| let item = childSnapshot.val(); | |
| item.key = childSnapshot.key; | |
| returnArr.push(item); | |
| }); | |
| return returnArr; |