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.

Inconsistent naming between .resolve() and .fulfilled()

See original GitHub issue

Hello,

I noticed an inconsistency between the aliases of the “return a resolved promise, immediately” method: One is named .resolve(), and the other .fulfilled(). I would expect .resolve() to be called .resolved() (or .fulfilled() -> .fulfill()). By contrast, the “return a rejected promise” method exists as both .rejected() and .reject().

I’ve tried to do .resolved() on more than one occasion, so I thought I’d post this. It isn’t a huge deal, but seeing as this is a beautiful and (otherwise) very consistent library, it might be worth it to create the .fulfill() and .resolved() aliases.

Issue Analytics

  • State:closed
  • Created 9 years ago
  • Comments:10 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
spioncommented, Aug 14, 2015

Here is the state tree of Promises:

          Pending
Promise /
        \            Locked-in 
          Resolved /
                   \           Fulfilled
                     Settled /
                             \ 
                               Rejected
  • Pending - value not known yet, can be changed via resolve or reject
  • Resolved - resolve and reject not working anymore
    • Locked-in - … and value not known yet, but it will be the same as the value of another promise
    • Settled - … and value is known
      • Fulfilled - … and value is a fulfilment value (i.e. a normal value, i.e. of “Right” type)
      • Rejected - … and value is a rejection value (i.e. a catchable error, i.e. of “Left” type)

Therefore, fulfil is simply the wrong word. Because the method takes a promise as an argument, and that promise may be rejected with an error (and therefore not fulfilled) resolved is the right word to use - it will either lock-in the promise to another, or settle it with a normal (“Right”) value.

The first version of bluebird used a different terminology, then @domenic made a push to standardise the basic words to be consistent with other libraries, but there are some remaining materials here and there that still use the original method names…

edit: I updated the article to resolve this (no pun intended). Thanks!

0reactions
berguscommented, Aug 16, 2015

@spion Oh of course it’s there: http://www.ecma-international.org/ecma-262/6.0/#sec-promise-objects - and I even have cited that section in my SO answer. I just forgot they used the term “locked in” in the standard.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Does "resolve" consistently mean something distinct from ...
No, there is no inconsistency here, the terms in the spec are ... There is a Promise.reject() method, but no Promise.fulfill() method.
Read more >
How to Handle the Incompatible Types Error in Java - Rollbar
The Java incompatible types error happens when a value assigned to a variable or returned by a method is incompatible with the one...
Read more >
await - JavaScript - MDN Web Docs
The await operator is used to wait for a Promise and get its fulfillment value. ... The expression is resolved in the same...
Read more >
FindBugs Bug Descriptions - SourceForge
Eq: Abstract class defines covariant equals() method, Bad practice ... Nm: Class names shouldn't shadow simple name of superclass ...
Read more >
Teacher Expectations and Self-Fulfilling Prophecies
Teacher Expectations and Self-Fulfilling Prophecies: Knowns and Unknowns, Resolved and Unresolved Controversies. Lee Jussim and Kent D. HarberView all ...
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