Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Placeholder doesn't work for converted functions unless explicitly recurried #3440

@daedalus28

Description

@daedalus28

When using convert on functions from lodash fp, they seem to lose their support for using _ as a placeholder. If I explicitly call curry on the result, they regain their placeholder support. Here's a full test case showing a failing test:

import _ from 'lodash/fp'

describe('lodash test', () => {
  it('placeholder for converted functions', () => {
    let mutableUnset = _.unset.convert({ immutable: false })
    let x = {
      a: 1,
      b: 1
    }
    console.log(mutableUnset.placeholder) // <-- Seems to be lodash
    console.log(mutableUnset.placeholder == _) // <-- false

    let unsetInX = mutableUnset(_, x)
    unsetInX('a') // <--- throws `TypeError: unsetInX is not a function`
    console.log(x)
  })
  it('placeholder for explicitly curried converted functions', () => {
    let mutableUnset = _.curryN(2, _.unset.convert({ immutable: false }))
    let x = {
      a: 1,
      b: 1
    }
    console.log(mutableUnset.placeholder) // <-- Seems to be lodash
    console.log(mutableUnset.placeholder == _) // <-- true

    let unsetInX = mutableUnset(_, x)
    unsetInX('a') // <--- works because of the explicit curry above
    console.log(x) // { b: 1}
  })
})

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions