The basis of all union data types.
This API is still experimental, so it may change or be removed in future versions. You should not rely on it for production applications.
The basis of all union data types.
Union is used basically to share some methods for refining data structures created by this module, derivation being one of them.
Allows a function to provide functionality to variants in an union.
{
/*~
* type: |
* Union . (...(Variant, Union) => Any) => Union
*/
derive(...derivations) {
derivations.forEach(derivation => {
this.variants.forEach(variant => derivation(variant, this));
});
return this;
}
}