🚀 DAY 5 OF LAUNCH WEEK:Introducing Webhook Events for Alert Changes.Learn more →
Socket
Book a DemoInstallSign in
Socket

@xapp/patterns

Package Overview
Dependencies
Maintainers
5
Versions
136
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@xapp/patterns

Patterns for TypeScript

latest
npmnpm
Version
2.0.2
Version published
Maintainers
5
Created
Source

@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,
    };
  }
}
  • Example - Unit Test
  • Example - Real World
  • Builder Pattern - Wikipedia

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.

FAQs

Package last updated on 06 Feb 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts