@xapp/patterns
TypeScript icon, indicating that this package has built-in type declarations

2.0.2 • Public • Published

@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.

/@xapp/patterns/

    Package Sidebar

    Install

    npm i @xapp/patterns

    Weekly Downloads

    1,521

    Version

    2.0.2

    License

    Apache-2.0

    Unpacked Size

    42.2 kB

    Total Files

    39

    Last publish

    Collaborators

    • petehaas
    • michaelmyers
    • chrsdietz
    • xappbot
    • opendog