0.0.2 • Published 6 years ago

tset v0.0.2

Weekly downloads
1
License
MIT
Repository
-
Last release
6 years ago

tset : A simple strongly typed set for typescript

Example

import {TSet} from ".";

//Helper that can be used to help with type inference
function infer<T>(): T {
  return (null as any) as T
}

test('TSet create works', () => {

  const t = TSet(
    //The type of the elements
    // 'null as any as TypeOfElements'
    infer<{
      name: string
    }>(),
    fn => ({
      a: fn({name: "this-is-a"}),
      b: fn({name: "this-is-b"}),
    }))

  expect(t.proto.a.id).toBe("a")
  expect(t.proto.b.id).toBe("b")
  expect(t.proto.a.name).toBe("this-is-a")
  expect(t.proto.b.name).toBe("this-is-b")

});