tset
v0.0.2
Published
A Simple Strongly Typed Set for Typescript
Downloads
11
Readme
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")
});