DEV Community

Discussion on: filterMap - JavaScript filter and map in O(n)

Collapse
 
vonheikemen profile image
Heiker

If you can put the arr argument last then it would be easier to do partial application.

const isSubscribed = user => user.is_subscribed;
const getFullName = user => `${user.first_name} ${user.last_name}`;
const getSubscribed = filterMap.bind(null, isSubscribed, getFullName);

const subscribedUsersNames = getSubscribed(users);

// then you could also use it as a callback

fetch('some-url')
  .then(res => res.json())
  .then(getSubscribed)