@xapp/patterns
v2.0.2
Published
Patterns for TypeScript
Downloads
5,868
Keywords
Readme
@xapp/patterns
Common TypeScript design patterns and data structures.
Builder
Extend the AbstractBuilder
to leverage your own builder pattern.
import { AbstractBuilder } from "@xapp/patterns";
export interface MyObject {
foo: string;
}
export class MyBuilder extends AbstractBuilder<MyObject> {
private foo: string = "defaultFooValue";
public withFoo(foo: string): MyBuilder {
return this;
}
public build(): MyObject {
const { foo } = this;
return {
foo,
};
}
}
Graph
A graph is an abstract data type with vertices and edges that make the connections between them.
Tree
A tree is a data structure with a root and nodes that then expand from the root.