![Angular code in editor.ts. A component with selector 'app-editor', imports: [DatePipe], and host: { '(document:keydown.control.s)': 'save($event)', '(document:keydown.meta.s)': 'save($event)' }. The template: <textarea #area [value]="draft()" (input)="draft.set(area.value)"></textarea>, then @if (savedAt(); as time) { <small>Saved at {{ time | date: 'shortTime' }}</small> }. In class Editor: readonly draft = signal(localStorage.getItem('draft') ?? ''); readonly savedAt = signal<Date | null>(null). The method save(event: Event) calls event.preventDefault(), localStorage.setItem('draft', this.draft()) and this.savedAt.set(new Date()). The two host listener lines are highlighted.](https://pbs.twimg.com/media/HWb1rJ6W4AA3daC.jpg?name=small&format=webp)
ALT Angular code in editor.ts. A component with selector 'app-editor', imports: [DatePipe], and host: { '(document:keydown.control.s)': 'save($event)', '(document:keydown.meta.s)': 'save($event)' }. The template: <textarea #area [value]="draft()" (input)="draft.set(area.value)"></textarea>, then @if (savedAt(); as time) { <small>Saved at {{ time | date: 'shortTime' }}</small> }. In class Editor: readonly draft = signal(localStorage.getItem('draft') ?? ''); readonly savedAt = signal<Date | null>(null). The method save(event: Event) calls event.preventDefault(), localStorage.setItem('draft', this.draft()) and this.savedAt.set(new Date()). The two host listener lines are highlighted.
![JavaScript code in folder.js. A class Folder has a constructor(name, children = []) that stores this.name and this.children. It has a generator method *[Symbol.iterator]() (highlighted) that does yield this; then, for (const child of this.children), yield* child. Usage: const src = new Folder('src', [new Folder('app', [new Folder('pages')]), new Folder('assets')]). Then [...src].map((folder) => folder.name) gives ['src', 'app', 'pages', 'assets'].](https://pbs.twimg.com/media/HWR4fanWcAA5L0P.jpg?name=small&format=webp)
ALT JavaScript code in folder.js. A class Folder has a constructor(name, children = []) that stores this.name and this.children. It has a generator method *[Symbol.iterator]() (highlighted) that does yield this; then, for (const child of this.children), yield* child. Usage: const src = new Folder('src', [new Folder('app', [new Folder('pages')]), new Folder('assets')]). Then [...src].map((folder) => folder.name) gives ['src', 'app', 'pages', 'assets'].




















