Skip to content

Instantly share code, notes, and snippets.

@krisselden
Created July 12, 2019 19:38
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisselden/c49f8180dce81a10ecf453b8f3d29680 to your computer and use it in GitHub Desktop.
Save krisselden/c49f8180dce81a10ecf453b8f3d29680 to your computer and use it in GitHub Desktop.
// Monomorphic wrapper for polymorphic value
wrapper = {
type,
value
}
// CheckMap wrapper for .type lookup monomorphic
if (wrapper.type === 1) {
// CheckMap value for .somefield lookup monomorphic because in branch for one type
wrapper.value.somefield
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment