Comparing version 2.2.0 to 2.2.1
{ | ||
"name": "ts-union", | ||
"description": "ADT (sum type) in typescript inspired by ML language family", | ||
"version": "2.2.0", | ||
"version": "2.2.1", | ||
"license": "MIT", | ||
@@ -6,0 +6,0 @@ "files": [ |
@@ -220,8 +220,8 @@ # ts-union | ||
console.log(PaymentMethod.Check(15566909)); | ||
// {k:'Check', p:[15566909]} | ||
// {k:'Check', p0:15566909, p1: undefined, p2: undefined, a: 1} | ||
``` | ||
This is because union values are objects under the hood. The `k` element is the key and the `p` is the payload array. I decided not to expose that through typings but I might reconsider that in the future. You **cannot** use it for redux actions, however you can **safely use it for redux state**. | ||
This is because union values are objects under the hood. The `k` element is the key, `p0` - `p1` are passed in parameters and `a` is the number of parameters. I decided not to expose that through typings but I might reconsider that in the future. You **cannot** use it for redux actions, however you can **safely use it for redux state**. | ||
Note that in version 2.0 it was a tuple. But [benchmarks](https://github.com/twop/ts-union/tree/master/benchmarks) showed that object are more efficient (I have no idea why arrays cannot be jitted efficiently). | ||
Note that in version 2.0 it was a tuple. But [benchmarks](https://github.com/twop/ts-union/tree/master/benchmarks) showed that object are more efficient (I have no idea why arrays cannot be jitted efficiently). You can find more details below | ||
@@ -228,0 +228,0 @@ ### API |
50431