1.0.0 • Published 7 years ago

retransform v1.0.0

Weekly downloads
4
License
Apache-2.0
Repository
github
Last release
7 years ago

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