const R = require('ramda');
const sesNotification = {
"notificationType": "Delivery",
"mail": {
"headers": [
{
"name": "Content-Type",
"value": "text/html"
},
{
"name": "List-Unsubscribe",
"value": "http://somedomain.com"
},
{
"name": "X-Moonmail-User-ID",
"value": "google-oauth2|12345"
}
]
}
};
const tapLog = (...tags) => R.tap(
(...values) => console.log(...tags, ...values))
const filterByHeaderName = R.curry((notification, header) =>
R.pipe(
R.path(['mail', 'headers']),
R.find(R.propEq('name', header)),
R.prop('value')
)(notification)
);
const results = filterByHeaderName(sesNotification)('Content-Type');
console.log(results);
Last active
March 6, 2018 13:17
-
-
Save karloscodes/22ddcbadb47e389154cbc6ff6d5c481b to your computer and use it in GitHub Desktop.
First steps using the Ramda library. Ramda, Javascript, Functional Programming
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment