.map(): Optic
ts
Optic<A extends any[]>.map: () => Optic<A[number], mapped>;
ts
Optic<A extends any[]>.map: () => Optic<A[number], mapped>;
This method returns a new mapped optic from an optic focused on an array.
Example:
ts
constnumbersOptic =createState ([1, 2, 3, 4, 5]);constnumbersMappedOptic =numbersOptic .map ();numbersMappedOptic .set ((prev ) =>prev * 2);numbersMappedOptic .get (); // [2, 4, 6, 8, 10]
ts
constnumbersOptic =createState ([1, 2, 3, 4, 5]);constnumbersMappedOptic =numbersOptic .map ();numbersMappedOptic .set ((prev ) =>prev * 2);numbersMappedOptic .get (); // [2, 4, 6, 8, 10]