Functional-style object transformation tool.
- Curried
- Recursive: supports nested objects and arrays
npm install retransform
var updateRequest = retransform({
url: x => `http://mydomain.com/comments/${x.id}`
method: 'PUT'
body: {
author: x => x.user,
data: x => x.comment
}
});
var formatResponse = retransform({
comments: data => data,
status: 'ok'
});
// Somewhere in controller
const onEditComment = pipe(
updateRequest,
sendToBackend,
formatResponse,
dispatch
);npm test