Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@xapp/patterns

michaelmyers5.8kApache-2.02.0.2TypeScript support: included

Patterns for TypeScript

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.