Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Print transform function #1

Closed
1 of 2 tasks
bahmutov opened this issue Jul 20, 2017 · 2 comments
Closed
1 of 2 tasks

Print transform function #1

bahmutov opened this issue Jul 20, 2017 · 2 comments

Comments

@bahmutov
Copy link
Owner

Is this a bug report or a feature request?

  • bug report
  • feature request

We should form a "nice" function with names of steps. Similar to rambo it should keep track of functions it combines into a single one to give nice

const f = change(source, destination)
f.toString()
// copy "foo"
// trim "bar"
@bahmutov
Copy link
Owner Author

Version 1.7.0 has been published to NPM. The full release note can be found at change-by-example/releases/tag/v1.7.0.

Tip: safely upgrade dependency change-by-example in your project using next-update

@bahmutov
Copy link
Owner Author

const source = {
  name: 'john',
  age: '42',
  occupation: 'mechanic'
}
const destination = {
  name: 'John',
  age: 42
}
const change = require('change-by-example')
const t = change(source, destination)
console.log(t.toString())
/*
name: _.capitalize(name)
age: _.parseInt(age)
*/

Similarly, deep paths will be shown using dots

const input = {
  name: 'foo',
  other: {
    info: {
      age: '42'
    }
  }
}
const output = {
  name: {
    first: 'foo'
  },
  age: 42
}
const t = change(input, output)
console.log(t.toString())
/*
name.first: R.identity(name)
age: _.parseInt(other.info.age)
*/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant