3 ms·
One dark and stormy night I decided to finally learn about JavaScript Proxies. So I started reading and noticed that it was possible to inspect parameters befo
by steen_hansen 5y ago
One dark and stormy night I decided to finally learn about JavaScript Proxies.
So I started reading and noticed that it was possible to inspect parameters before
function execution, and results after function returns; just like
Clojure Spec https://news.ycombinator.com/item?id=24432461 https://news.ycombinator.com/item?id=24432461 does.
At first I thought that I would be confined to type checking plain JavaScript functions, but I managed
to handle constructors and methods inside classes, closures, and IIFEs.
Thus TypeCzech was born with an odd but unique searchable name.
Why you might want to use:
- Type signtures are JavaScript strings, arrays, and objects; thus can be constants
- No complilation, no dependencies, no new syntax, easy to decouple
- Throw exceptions or just console.log errors
More live examples than you can shake a stick
at at https://jsfiddle.net/steen_hansen/1Lshcept/?Example-Contents https://jsfiddle.net/steen_hansen/1Lshcept/?Example-Contents