Overview
molecule is a small singleton helper for nested “bags” that mix atoms, plain data, and methods (forms, stores, scope instances). It walks objects and arrays, visits every Mates atom, and skips non-atoms.
every / some mirror Array.prototype (including short-circuit). each runs a visitor on every atom. The walker does not recurse into atom values, and it guards against circular references.
molecule vs manual walks
|
Approach
|
Tracks atoms?
|
Prefer when
|
|---|---|---|
molecule.*
| Yes | Deep bags with mixed fields — forms, stores, scopes. |
| Hand-rolled Object.keys | Easy to miss nest | Only for flat, known shapes. |
effect on known deps
| Reactive | When you already list the atoms you care about. |
every + some on a form bag
Nested score atom is included. every/some short-circuit like Array methods.
each — bump every atom
Visitor mutates each atom found in the nested bag.