AotDS, captain log 6

January 19th, 2021
aotdsmicroblog
#aotds, captain log 6: A quick pause of the glamour of the UI. I'm taking a moment to throw in some functionality to [my fork of updeep](https://www.npmjs.com/package/@yanick/updeep).

From now on, u.if mostly uses lodash’s matches for its predicate, and there are two new function, u.mapWhen and u.mapWhenElse for extra array manipulation goodness.

For example, altering weapon orders that already exist or create a new one if they don’t, will be able to switch from

$store = u({
  bogeys: u.map(
    u.if(
      fp.matches({id: bogey_id}),
      u.updateIn('orders.weapons',
        weapons => [
            ...fp.reject({weapon_id}, weapons),
            {firecon_id, weapon_id}
        ]
      )
    )
)}, $store);

to

$store = u({
  bogeys: u.mapWhen(
    {id: bogey_id},
    u.updateIn('orders.weapons',
      u.mapWhenElse(
        {weapon_id}, {firecon_id}, { weapon_id, firecon_id }
      )
    )
  )
}, $store);

Still not for the faint of heart. But then, neither is the darkest sea.