I have had a few places where I wanted to programmatically access another notebook’s cells. I think it’s quite a good way to add generic features to the ecosystem (e.g. SVG to GIF) without forcing people to change their notebooks to accommodate them.
Anyway, since I have implemented this poorly twice, I tried to implement a good standalone one for reuse.
This was better than previous attempts because in this new version, peek returns a generator (i.e. stream of values), which is, perhaps not immediately obviously though, the right representation.
Previously in all my applications I so far I just wanted to read a single value, so made bad hacks to do that. For reading a single value I have peekFirst resolve to a promise, but in the general case it should be implemented with generators. Its trivial to turn a generator to a promise, but impossible the other way around, and the general case kinda mandates generators.
Anyway, I personally don’t find generators easy to work with, especially the nuance like passing an error through a generator, so I hope people will find value in this notebook. It’s done the right way, even error handling. You probably just want to use peekFirst in most cases though.
Let me know if you want more features. I could, e.g., add the ability to inject values into the target notebook before peeking.