Skip to content

machobearstudio/retransform

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

retransform

Functional-style object transformation tool.

Features

  • Curried
  • Recursive: supports nested objects and arrays

Installation

npm install retransform

Usage

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
);

Testing

npm test

About

Recursive object transformer

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors