Skip to content

Releases: twop/ts-union

v2.3.0

10 Oct 03:59
Compare
Choose a tag to compare

v2.2.1...v2.3.0

corrected stale section of README

05 Jun 23:07
Compare
Choose a tag to compare

reworked internal representation of union values

05 Jun 22:59
Compare
Choose a tag to compare
  • added pika version script 27dc298
  • reworked internal representation 7c1c417

v2.1.1...v2.2.0

There should be no public breaking changes, but I changed the underlying data structure (again!? and again!?) to be {k: string, p0: any, p1: any, p2: any, a: number}, where k is a case name like "CreditCard", p0-p2 passed in parameters and a is how many parameters were passed in. So if you stored the values somewhere (localStorage?) then please migrate accordingly.

const oldShape = { k: 'CreditCard', p: ['Visa', '1111-566-...'] };
const newShape = {
  k: 'CreditCard',
  p0: 'Visa',
  p1: '1111-566-...',
  p2: undefined,
  a: 2,
};

motivation for this is potential perf wins avoiding dealing with (...args) => {...}. The current approach should be more friendly for JIT compilers (arguments and ...args are hard to optimize). That kinda aligns with my local perf results:

old shape

Creation
    baseline: 8.39 ms
    unionize: 17.32 ms
    ts-union: 11.10 ms

Matching with inline object
    baseline: 1.97 ms
    unionize: 5.96 ms
    ts-union: 7.32 ms

Matching with preallocated function
    baseline: 2.20 ms
    unionize: 4.21 ms
    ts-union: 4.52 ms

Mapping
    baseline: 2.02 ms
    unionize: 2.98 ms
    ts-union: 1.69 ms

new shape

Creation
    baseline: 6.90 ms
    unionize: 15.62 ms
    ts-union: 6.38 ms

Matching with inline object
    baseline: 2.33 ms
    unionize: 6.26 ms
    ts-union: 5.19 ms

Matching with preallocated function
    baseline: 1.67 ms
    unionize: 4.44 ms
    ts-union: 3.88 ms

Mapping
    baseline: 1.96 ms
    unionize: 2.93 ms
    ts-union: 1.39 ms

Changed underlying data structure

10 Jun 22:59
Compare
Choose a tag to compare
  • now you can define NoData variants with either of<void>() or just of().

Breaking changes from 1.1:

  • t function to define shapes is renamed to of.
  • There is a different underlying data structure. So if you persisted the values somewhere it won't be compatible with the new version.