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?