Skip to content

Instantly share code, notes, and snippets.

@szmeku
Last active February 20, 2020 11:36
Show Gist options
  • Save szmeku/452fb7ed6800284991f03a551d685292 to your computer and use it in GitHub Desktop.
Save szmeku/452fb7ed6800284991f03a551d685292 to your computer and use it in GitHub Desktop.
// from [{barcode: 'aaa', valid: true, ....}, {barcode: 'bbb', valid: false, ....}]
// to {'aaa': {valid: true}, 'bbb': {valid:false}}
_.pipe(
_.map(_.pipe(
_.juxt([
_.prop('barcode'),
_.dissoc('barcode')
]),
_.apply(_.objOf)
)),
_.mergeAll
)(input)
// rename prop
_.pipe(
_.juxt([
_.dissoc('oldName'),
_.pipe(_.prop('oldName'), _.objOf('newName'))
]),
_.merge
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment