

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: State
incomplete
2: PokeAPI
incomplete
3: Caching
incomplete
4: Explore
incomplete
5: Catch
incomplete
6: Inspect
incomplete
This lesson's interactive features are locked, please to keep using them
As we add more commands, the statefulness of our program is going to increase. We're going to shove all that state into a State object. There are a few goals for this object:
commands registry (looking at you help command)readline interface created with createInterface so that the exit command can clean up after itselfIn the future there will be even more shared state, and we want a simple function signature that all the callbacks can conform to, namely:
callback: (state: State) => void;
import { createInterface, type Interface } from "readline";
Now that we've done all this... nothing's changed! Our code should still work the exact same way. Womp womp. Welcome to refactoring! Refactoring is actually a super important skill that you'll spend a lot of time doing as a developer. It's all about updating the structure (but not behavior) of your code to make it easier to read, maintain, and extend.
Run and submit the CLI tests.