Created
February 28, 2023 03:36
-
-
Save onosendi/3feeafb8265256259fe5c5b9f6f6b737 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const R = require('ramda'); | |
const userRegAttrs = [ | |
{ reg_id: 1, attr_name: 'foo', attr_value: 1 }, | |
{ reg_id: 1, attr_name: 'bar', attr_value: 3 }, | |
]; | |
const user_id = 1; | |
const res = R.pipe( | |
R.map(R.omit(['reg_id'])), | |
R.map(R.mergeRight({ user_id })), | |
)(userRegAttrs); | |
console.log(res); | |
// [ | |
// { user_id: 1, attr_name: 'foo', attr_value: 1 }, | |
// { user_id: 1, attr_name: 'bar', attr_value: 3 } | |
// ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment