Skip to content

Issue with _.partial and placeholders #3016

Description

@eauchat

Thanks for the amazing library!!!
Hope this issue can be of any use for improving it, if so this will be my tiny tiny contribution to a tool I've benefited so much for very long :)

I'm having an issue with using the default placeholder with _.partial.

Here is a code example of the issue:

var _ = require("underscore");

const add1 = (a, b, c, d) => { return a + b + c + d }
let myFunc1 = _.partial(add1, 10, 100, _, 5)
console.log(myFunc1(1000))
// "110[object Object]5"

_.partial.placeholder = _

const add2 = (a, b, c, d) => { return a + b + c + d }
let myFunc2 = _.partial(add2, 10, 100, _, 5)
console.log(myFunc2(1000))
// 1115

The following:

console.log(_.partial.placeholder)
_.partial.placeholder = _
console.log(_.partial.placeholder)

seem to log twice the underscore object/function but they look slightly different:
first log:

function _8(obj)
    VERSION: "1.13.8"
​    _: function _8(obj)
​    after: function after4(times7, func)
    ...

second log:

Object
    VERSION: "1.13.8"
​    __esModule: true
​    after: function after4(times7, func)
    ...

I'm wondering if the issue comes from the bundler I use (esbuild), but this issue does not occur with underscore 1.13.2 so I'm wondering what may provoke this change and if it is desired.
Feel free to close if that seem out of underscore's scope, but I'd love to understand what could be causing this issue.

Note that the issue is not so hard to resolve, just need the _.partial.placeholder = _ line. But without it, placeholder won't work, the underscore function will be passed as argument.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions