varianter
Version:
Simple variants/tagged unions/discriminated unions in TypeScript
3 lines (2 loc) • 530 B
JavaScript
!function(n,e){"object"==typeof exports&&"undefined"!=typeof module?e(exports):"function"==typeof define&&define.amd?define(["exports"],e):e((n=n||self).varianter={})}(this,function(n){n.createVariant=function(){var n=function(n,e){return function(t){if(n in t)return(0,t[n])(e);if("_"in t)return t._(e);throw new Error("Property doesn't exist in variant, and no fallthrough was specified")}};return new Proxy({},{get:function(e,t){return function(e){return{type:t,data:e,map:n(t,e)}}}})}});
//# sourceMappingURL=index.umd.js.map