Less readable when a promise .then takes certain arguments
See original GitHub issueJust found about prettier this morning, looks like a great package! Playing with it and overall pretty pleased with the way things look. I did come across this issue that seems to be a bit less readable with the output.
Original
SomeService
.get('things')
.then(_.spread((firstThing, secondThing) => {
// do stuff with things
}));
Formatted output
SomeService.get("things").then(
_.spread((firstThing, secondThing) => {
// do stuff with things
})
);
Its harder to see in the formatted that _.spread
is doing the job of deconstructing a single argument into multiple arguments given to the callback to the .then
fn. It seems something that you could get used to, but is perhaps less ideal.
Issue Analytics
- State:
- Created 7 years ago
- Comments:7 (5 by maintainers)
Top Results From Across the Web
Using promises - JavaScript - MDN Web Docs
A Promise is an object representing the eventual completion or failure of an asynchronous operation. Since most people are consumers of ...
Read more >Can promises have multiple arguments to onFulfilled?
I'm following the spec here and I'm not sure whether it allows onFulfilled to be called with multiple arguments. Nope, just the first...
Read more >Promises Cheatsheet - Intermediate JavaScript
.then() accepts two function arguments. The first handler supplied to it will be called if the promise is resolved. The second one will...
Read more >Using .then(), .catch(), .finally() to Handle Errors in Javascript ...
then () method with Promises. .then takes a callback function and returns another Promise (!) and you can do nifty things like console.log...
Read more >Promise
To get some relief, you promise to send it to them when it's published. ... The first argument of .then is a function...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
We’re unlikely going to support treating _.spread specially since es6 spread exists and is properly printed, so I’m going to go ahead and close this issue. @kjbekkelund your issue has been fixed by #809
Thanks for the report, I think I know how to fix this. If there are more than one function, then don’t do the last argument expansion. I’ll try and implement it this week and see how it feels