npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

design-patterns-typescript

v1.0.5

Published

Library for implement structural design patterns

Downloads

11

Readme

design-patterns-typescript

This npm package is developed for support the design patterns in typescript. We can use these design patterns in our frontend web development.

Installation

Install design-patterns-typescript with npm

  npm i design-patterns-typescript

Badges

Add badges from somewhere like: shields.io

MIT License

Usage/Examples

Using Flyweight design pattern

import {FlyweightFactory} from 'design-patterns-typescript'

const factory = new FlyweightFactory([
    ['Chevrolet', 'Camaro2018', 'pink'],
    ['Mercedes Benz', 'C300', 'black'],
    ['Mercedes Benz', 'C500', 'red'],
    ['BMW', 'M5', 'red'],
    ['BMW', 'X6', 'white'],
    
]);

factory.listFlyweights();



function addCarToPoliceDatabase(
    ff: FlyweightFactory, plates: string, owner: string,
    brand: string, model: string, color: string,
) {
    console.log('\nClient: Adding a car to database.');
    const flyweight = ff.getFlyweight([brand, model, color]);

    
    flyweight.operation([plates, owner]);
}

addCarToPoliceDatabase(factory, 'CL234IR', 'James Doe', 'BMW', 'M5', 'red');

addCarToPoliceDatabase(factory, 'CL234IR', 'James Doe', 'BMW', 'X1', 'red');

factory.listFlyweights();

Features

These Structural design patterns are implemented and you can just import them and use.

  • Adapter

    Allows objects with incompatible interfaces to collaborate.

  • Composite

    Lets you compose objects into tree structures and then work with these structures as if they were individual objects.

  • Decorator

    Lets you attach new behaviors to objects by placing these objects inside special wrapper objects that contain the behaviors.

  • Flyweight

    Lets you fit more objects into the available amount of RAM by sharing common parts of state between multiple objects instead of keeping all of the data in each object.

  • Proxy

    Lets you provide a substitute or placeholder for another object. A proxy controls access to the original object, allowing you to perform something either before or after the request gets through to the original object.

These Creational design patterns are implemented and you can just import them and use.

  • Prototype

    Lets you copy existing objects without making your code dependent on their classes.

Contributing

Contributions are always welcome!

.

License

MIT

Keywords

design-patterns typescript react node