Skip to content

Instantly share code, notes, and snippets.

@gaizka-allende
Created September 2, 2016 08:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gaizka-allende/9e61b8a0919ee558fa64f5f8304291a8 to your computer and use it in GitHub Desktop.
Save gaizka-allende/9e61b8a0919ee558fa64f5f8304291a8 to your computer and use it in GitHub Desktop.
Moving list element to first place using Ramda
const recurringAddons = [{description: 'limited calls'}, {description: 'unlimited calls'}];
const hasUnlimitedCalls = R.propEq('description', 'unlimited calls');
const unlimitedCallsAddon = R.find(hasUnlimitedCalls)(recurringAddons)
const moveItFirst = addon => R.pipe(R.without([addon]), R.prepend(addon))
moveItFirst(unlimitedCallsAddon)(recurringAddons);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment