3 ms·
There was a library adding macros to JS that was a thing long ago. I always thought that `cond` would make JSX way better, though JS + macros sounds terrifying
by code_biologist 3y ago
There was a library adding macros to JS that was a thing long ago. I always thought that `cond` would make JSX way better, though JS + macros sounds terrifying in general.
Code example below, `cond` is an example in their tutorial: https://www.sweetjs.org/doc/tutorial.html#sweet-cond https://www.sweetjs.org/doc/tutorial.html#sweet-cond
let realTypeof = cond {
case x === null: 'null'
case Array.isArray(x): 'array'
case typeof x === 'object': 'object'
default: typeof x
}
Discussed in 2017 on HN: https://news.ycombinator.com/item?id=14695495 https://news.ycombinator.com/item?id=14695495