Giter Site home page Giter Site logo

Comments (4)

benjamingr avatar benjamingr commented on September 17, 2024

The reason we return null is to act similar to .exec which behaves this way. Personally I'd rather throw but I want to do what developers find the least surprising.

Any ideas how to communicate what we return better?

from js-restructure.

maniator avatar maniator commented on September 17, 2024

Personally I think that the parser function should throw some sort of an error of what went wrong instead of returning null so that I can structure my code better and always assume that the parser will return with the same type and never with null.

Otherwise when using the parser one has to add on a guard clause which I personally find to be a code smell.

It is all a matter of opinion though.

from js-restructure.

maniator avatar maniator commented on September 17, 2024

Also maybe returning an object with a _error key may work as well instead of throwing an error could work. with that key containing a reason of why it failed etc.

All just random ideas I am throwing out.

from js-restructure.

benjamingr avatar benjamingr commented on September 17, 2024

I've decided I'll wait for more user feedback before addressing this.

from js-restructure.

Related Issues (3)

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.