varianter
Version:
Simple variants/tagged unions/discriminated unions in TypeScript
3 lines (2 loc) • 363 B
JavaScript
var n=function(){var n=function(n,r){return function(t){if(n in t)return(0,t[n])(r);if("_"in t)return t._(r);throw new Error("Property doesn't exist in variant, and no fallthrough was specified")}};return new Proxy({},{get:function(r,t){return function(r){return{type:t,data:r,map:n(t,r)}}}})};export{n as createVariant};
//# sourceMappingURL=index.module.js.map