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

Compose breaks curry (or vice versa) #1160

Closed
cbdumas opened this issue Apr 22, 2015 · 2 comments
Closed

Compose breaks curry (or vice versa) #1160

cbdumas opened this issue Apr 22, 2015 · 2 comments
Labels

Comments

@cbdumas
Copy link

cbdumas commented Apr 22, 2015

I'm not sure which one is breaking the other, but the snippet below will repro the issue I'm having.

Essentially the curried function appears to be returning undefined when used inside compose. The function curry_unique_names returns [undefined] instead of the unique names as expected

// The following two functions work the same
function pluck_names(arr){
    return _.pluck(arr, 'name');
}
var curry_pluck_names = _.curry(_.pluck)(_, 'name');

// But these two do not :(
var unique_names = _.compose(_.uniq, pluck_names);
var curry_unique_names = _.compose(_.uniq, curry_pluck_names);

var named = [{name:'asdf'}, {name:'qwer'}, {name:'asdf'}, {name:'qwer'}];

console.log('Plucked names:\t', pluck_names(named));
console.log('Plucked names w/ curry: ', curry_pluck_names(named));

console.log('Unique names: \t', unique_names(named));
console.log('Unique names with curry: \t', curry_unique_names(named));
@jdalton jdalton added the bug label Apr 23, 2015
@jdalton
Copy link
Member

jdalton commented Apr 23, 2015

Thanks @cbdumas!

@lock
Copy link

lock bot commented Jan 20, 2019

This thread has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Jan 20, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants