I have a users object am trying to use the lodash map() method on it to have it return only the userIds, while filtering out any users with the currentUserId. I wanted to avoid using chain() since it pulls in the entire library, so it seemed that the flow() method is perfect, yet it's not mapping to an array of Id's.
import { map, filter, flow, } from 'lodash'; const users = { 123: { uid: 123 }, 456: { uid: 456 } }; const currentUserId = 123; const userIds = flow( map(user => user.uid), filter(userId => userId !== currentUserId), )(users); Unfortunately, this is returning the same object as was passed into it. How can I get an array with the ids of all the users that are not the current user?
_.map(user => user.uid)is evaluated before_.flow()is even called._.mapbe the curried invocation that creates a new function that expects an object to execute the mapping against? Unless OP is not using the lodash in its functional form, then the_.mapshouldn't executing right after_.flow()method expects to be passed an array of function references. That's not what's being done in the posted code._.map(user => user.uid)is a function call, not a function.