Comments (4)
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.
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.
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.
I've decided I'll wait for more user feedback before addressing this.
from js-restructure.
Related Issues (3)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from js-restructure.