Closed gilligan closed 8 years ago
I made a fork and rebased next on master - Two failing tests that I am looking into now ...
I am afraid I am stuck. After my rebase rawCase looks like this :
function rawCase(type, cases, value, arg) {
var name = value.name in cases ? value.name : '_';
if (process.env.NODE_ENV !== 'production') {
if (!type.isPrototypeOf(value)) throw new Error('Non-exhaustive patterns in a function');
if (!(name in cases)) {
throw new Error('unhandled value passed to case');
}
}
return cases[name].apply(undefined, arg !== undefined ? valueToArray(value).concat([arg]) : value);
}
What fails now is the test does not extract fields when matching _
- Trying to make sense of the code :)
edit: I guess this might work then :
function rawCase(type, cases, value, arg) {
var name = value.name in cases ? value.name : '_';
if (process.env.NODE_ENV !== 'production') {
if (!type.isPrototypeOf(value)) throw new Error('Non-exhaustive patterns in a function');
if (!(name in cases)) {
throw new Error('unhandled value passed to case');
}
}
if (name === '_') return arg;
return cases[name].apply(undefined, arg !== undefined ? valueToArray(value).concat([arg]) : value);
}
https://github.com/gilligan/union-type/tree/reintegrate all tests passing now.
Created a PR. I would really love to use the new features. Please let me know what needs to be done for this to go forward ;)
I just added union-type to our codebase the other day and I quite like - I am very interested in what you have been working on in the next branch - what are your plans in regarding a new release merging next into master ? What does it take for this to be merged ? How could I help ?