How do you chain functions using lodash?

前端 未结 4 1614
伪装坚强ぢ
伪装坚强ぢ 2020-12-23 19:36

I have an object that looks like

var foundUser = {
    charData: []
}

which then I load an object from a database using mysql and then I ca

4条回答
  •  我在风中等你
    2020-12-23 19:51

    Chain is the best equivalence to pipe in lodash.

    _.chain(foundUser)
     .assignIn(rows[0])
     .omit(['blah'])
     .value()
    

    You can also chain some custom function by .tap or .thru, e.g.:

    _.chain(foundUser)
     .assignIn(rows[0])
     .tap(console.log)
     .omit(['blah'])
     .value()
    

提交回复
热议问题