question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Less readable when a promise .then takes certain arguments

See original GitHub issue

Just 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:closed
  • Created 7 years ago
  • Comments:7 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
vjeuxcommented, Mar 1, 2017

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

1reaction
vjeuxcommented, Feb 14, 2017

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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found