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

Bluebird.props for empty Map returns an Object #1338

Closed
alanhoff opened this issue Feb 13, 2017 · 4 comments
Closed

Bluebird.props for empty Map returns an Object #1338

alanhoff opened this issue Feb 13, 2017 · 4 comments

Comments

@alanhoff
Copy link

@alanhoff alanhoff commented Feb 13, 2017

  1. What version of bluebird is the issue happening on?
    v3.4.7

  2. What platform and version?
    v7.5.0
    Darwin Alans-MacBook-Pro.local 15.6.0 Darwin Kernel Version 15.6.0: Mon Jan 9 23:07:29 PST 2017; root:xnu-3248.60.11.2.1~1/RELEASE_X86_64 x86_64

  3. Did this issue happen with earlier version of bluebird?
    Yes

Bluebird.props should return an empty ES6 Map instead of a plain object {} when called with an empty Map:

screenshot 2017-02-13 15 10 54

@benjamingr
Copy link
Collaborator

@benjamingr benjamingr commented Feb 14, 2017

I'm not sure I agree. Promise.props is just for returning multiple named values and passing it a map as configuration is a nice bonus - but Bluebird can't be expected to deal with every case.

@alanhoff
Copy link
Author

@alanhoff alanhoff commented Feb 14, 2017

@benjamingr I don't think it's about dealing with every case (empty Map only?) but not being predictable is what hurts the most. I'm ok with it if we add it to the docs:

The promise's fulfilment value is an object or a Map with fulfilment values at respective keys to the original object or a Map unless it's an empty Map, in this case it will return an empty object.

Don't you think it seems highly inconvenient? The resolved value depends on the number of items inside a Map

@bsiddiqui
Copy link

@bsiddiqui bsiddiqui commented Feb 14, 2017

@benjamingr seems like odd behavior that Promise.props called with a Map sometimes returns a Map and sometimes returns an Object.

You're totally right that passing it a map as a configuration is a nice bonus but feels like if Bluebird is going to include that functionality it should be consistent and predictable.

@spion
Copy link
Collaborator

@spion spion commented Feb 15, 2017

👍 different return value types are strange

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

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.