-
Notifications
You must be signed in to change notification settings - Fork 28
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Next releae #31
Next releae #31
Conversation
Fix the expected exception when passing wrong type to caseOn
rawCase should not extract fields for the default case
Reintegrate next
Fix the expected exception when passing wrong type to caseOn
rawCase should not extract fields for the default case
I spotted a typo in the title: |
Rather than use |
I would also like to see the process.env part go in favor of something more explicit! I would even prefer no switch at all just as long as some environment variable does not change the behavior of some library somewhere in my stack. |
function isFunction(f) { return typeof f === 'function'; } | ||
var isArray = Array.isArray || function(a) { return 'length' in a; }; | ||
if (process.env.NODE_ENV !== 'production') { | ||
var isString = function(s) { return typeof s === 'string'; }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is there any reason to not use R.is
?
var is = require('ramda/src/is');
var isString = R.is(String);
var isNumber = R.is(Number);
...
either that or just use R.is
directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The only reason is to keep the external dependencies as low as possible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I get that, but Ramda is already a dependency anyway ;)
my vim complains about mixed indentation hehe. @paldepind I wonder if you would be open for a PR adding linting via eslint for the sake of consistency and error checking. We could use the same settings that I introduced to Ramda: ramda/ramda#1529 |
}; | ||
} | ||
|
||
function valueToArray(value) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I honestly lost the ability the parse for loops without getting a headache .. How about:
const valueToArray = (value) => value.keys.map((x, index) => value[value.keys[index]]);
: undefined; | ||
if (name === undefined) { | ||
throw new Error('unhandled value passed to case'); | ||
function extractValues(keys, obj) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Again I would probably prefer to use map and es6 syntax here:
const extractValues = (keys, obj) => keys.map((x, index) => obj[keys[index]]);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we are not using es6:
function extractValues (keys, obj) {
return keys.map(function (x, index) {
return obj[keys[index]];
});
};
Admittedly not as nice ;) Maybe we could add es6 transpiling at some point ;)
I very much agree. But one advantage of using
It's the darn Emacs. Using linting would be great. |
@paldepind Do you mean |
Yes. Indeed. I think |
@paldepind if you |
@kwijibo The latter, each value as argument. |
Thanks. I'm looking forward to this release. I started using Glad to see the prototype stuff; presumably |
|
That is a good point @kwijibo. On the other hand it would not be as nice for people not using ECMAScript 6. I'm glad you enjoy the library. |
Anything I can contribute to move this forward ? The one thing that still bugs me is the use of As for minifying - the code is so small already I don't care about those few bytes more or less and value the code being correct and behaviour explicit. My suggestion would be to either remove the ability to switch checks on or off completely or follow the suggestion made by @davidchambers to pass in a predicate function. All other changes are probably minor and could thus be followed as minor version updates (glad to provide an eslint PR later on for example). |
Merged and released. Type checking is disabled by doing |
Thanks to great ideas from @alexeygolev, help from @gilligan and inspiration from @scott-christopher's work here I'm planning to do a new breaking release. I'd really like some feedback and opinions 😄
New features include
Fields can be accessed like normal properties. Eg.
circle.radius
. Records support destruction and pattern matching like regular union types.I'm also considering deprecating
switch
andswitchOn
and renaming them tomatch
andmatchOn
. If anyone has a better name thanmatchOn
I'd love to hear it.