Coder Social home page Coder Social logo

`.ifError()` name is misleading about ava HOT 8 CLOSED

avajs avatar avajs commented on September 20, 2024
`.ifError()` name is misleading

from ava.

Comments (8)

sindresorhus avatar sindresorhus commented on September 20, 2024

This is just inherited from the Node.js assert module.
Can you bring this up on the Node.js issue tracker first?

That assert method is pretty irrelvant with promises though.

from ava.

alebelcor avatar alebelcor commented on September 20, 2024

I see, but looking at the assert documentation it states that ifError "throws value if value is truthy".

If I got that right I think AVA's ifError is inverted. It throws the value if it's falsy.

from ava.

Qix- avatar Qix- commented on September 20, 2024

Can you write a quick test case @alebelcor?

from ava.

floatdrop avatar floatdrop commented on September 20, 2024

@Qix- ava have test case for this.

@alebelcor judging by test case ifError behaves correctly (throws, if value is truthy - double negative is always tough, thou).

from ava.

alebelcor avatar alebelcor commented on September 20, 2024

OK, then (unless I'm mistaken) this just means that the readme.md is inaccurate.

It should read:

.ifError(error, [message])

Asserts that error is truthy.

from ava.

floatdrop avatar floatdrop commented on September 20, 2024

Asserts that error is truthy.

Well, no. It asserts that error is falsy. It throws if error is truthy.

from ava.

sindresorhus avatar sindresorhus commented on September 20, 2024

@alebelcor If you have any good suggestions for a better name we might consider adding an alias, but I don't really care much tbh, as the future is promises and async functions which makes this assert method moot.

from ava.

sindresorhus avatar sindresorhus commented on September 20, 2024

Related: nodejs/node#3398

from ava.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.