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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@quarterfall/parseidon

v1.0.4

Published

Knex.js based query builder to interpret design patterns in MermaidJS.

Downloads

11

Readme

parseidon

Knex.js based query builder to interpret design patterns in MermaidJS.

demo

You can try out the ParseidonJS node module at the link below!

ParseidonJS Demo

Database Structure

The database includes 4 tables, as shown in the diagram before. This database is queried to check for design patterns and relations in the class diagram.

 classDiagram
direction LR
Relations "1" --> "2" Classes
Classes "1" --> "0..*" Members
Classes "1" --> "0..*" Methods
class Relations {
int id
String first_class
String relation
String second_class
}
class Classes {
String id
int[] members
int[] methods
String type
}
class Members {
int id
String type
String name
String accessibility
String classifier
}
class Methods {
int id
String returnType
String name
String parameters
String accessibility
String classifier
}

Design Patterns

For the moment, ParseidonJS supports these design patterns software design patterns:

Singleton

Steps

  1. Singleton class has private static instance of own class
  2. Singleton class has a private constructor
  3. Singleton class has public static method returning the singleton class instance
  4. There is no instance of the singleton class in any other class
 classDiagram
    Animal <|-- Duck
    Animal <|-- Fish
    Animal <|-- Zebra
    Singleton --> Singleton
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
    Animal: +mate()
    class Duck{
        +String beakColor
        +swim()
        +quack()
    }
    class Fish{
        -int sizeInFeet
        -canEat()
    }
    class Zebra{
        +bool is_wild
        +run()
    }
    class Singleton{
      -Singleton singleton$
      -Singleton()
      +getInstance()$ Singleton
    }
 classDiagram
    Animal <|-- Duck
    Animal <|-- Fish
    Animal <|-- Zebra
    Singleton --> Singleton
    Animal : +int age
    Animal : +String gender
    Animal: +isMammal()
    Animal: +mate()
    class Duck{
        +String beakColor
        +swim()
        +quack()
    }
    class Fish{
        -int sizeInFeet
        -canEat()
    }
    class Zebra{
        +bool is_wild
        +run()
    }
    class Singleton{
      -Singleton singleton$
      -Singleton()
      +getInstance()$ Singleton
    }

Factory Method

Steps

  1. Have a "product" interface implemented by at least 1 "product'
  2. Have an abstract "creator" class with abstract method that returns "product" interface and at least 1 other method
  3. Have at least one class inheriting from "creator" class
 classDiagram
direction RL
    class Dialog {
        <<abstract>>
        +render()
        +createButton()* Button
    }
    class Button {
        <<interface>>
        +render()
        +onClick()
    }
    class WindowsDialog {
        +createButton(): Button
    }
WindowsDialog --|> Dialog
WindowsButton ..|> Button
Dialog --> Button
 classDiagram
    direction RL
    class Dialog {
        <<abstract>>
        +render()
        +createButton()* Button
    }
    class Button {
        <<interface>>
        +render()
        +onClick()
    }
    class WindowsDialog {
        +createButton(): Button
    }
    WindowsDialog --|> Dialog
    WindowsButton ..|> Button
    Dialog --> Button

Strategy

Steps

  1. Strategy interface with 1 method ( Strategy method )
  2. Context class with private Strategy interface member
  3. One class implementing the Strategy interface
 classDiagram
Context o-- Strategy
Context --> Strategy
ConcreteStrategy ..|> Strategy
class Strategy {
<<interface>>
+execute(data)
}
class ConcreteStrategy {
+execute(data)
}
class Context {
-Strategy strategy
+setStrategy(strategy)
+doSomething()
}
 classDiagram
    Context o-- Strategy
    Context --> Strategy
    ConcreteStrategy ..|> Strategy
    class Strategy{
        <<interface>>
        +execute(data)
    }
    class ConcreteStrategy{
        +execute(data)
    }
    class Context{
        -Strategy strategy
        +setStrategy(strategy)
        +doSomething()
    }

Adapter

Steps

  1. Adapter class that associates with the service and implements the client interface
  2. Service class, the client can't use it directly. Adapter class has an instance of it
 classDiagram
SquarePegAdapter ..|> RoundPeg
SquarePegAdapter --> SquarePeg

class SquarePegAdapter{
-SquarePeg peg
+SquarePegAdapter(SquarePeg peg)
+getRadius() int
}
class SquarePeg{
-int width
+SquarePeg(int width)
+getWidth() int
}
class RoundPeg{
<<interface>>
+getRadius() int
}
 classDiagram
    SquarePegAdapter ..|> RoundPeg
    SquarePegAdapter --> SquarePeg
    class SquarePegAdapter{
        -SquarePeg peg
        +SquarePegAdapter(SquarePeg peg)
        +getRadius() int
    }
    class SquarePeg{
        -int width
        +SquarePeg(int width)
        +getWidth() int
    }
    class RoundPeg{
        <<interface>>
        +getRadius() int
    }

Composite

Steps

  1. Component interface with at least one method
  2. Two classes implementing the Component interface (Leaf and Container)
  3. One class(Container) with an array of interface type, methods to add and remove members of the array
 classDiagram
Dot ..|> Graphic
CompoundGraphic ..|> Graphic
class Graphic {
<<interface>>
+move(int x,int y)
+draw()
}
class Dot {
+Dot(int x, int y)
+move(int x, int y)
+draw()
}
class CompoundGraphic {
-Graphic[] children
+add(Graphic child)
+remove(Graphic child)
+move(int x, int y)
+draw()
}
 classDiagram
    Dot ..|> Graphic
    CompoundGraphic ..|> Graphic
    class Graphic {
        <<interface>>
        +move(int x,int y)
        +draw()
    }
    class Dot {
        +Dot(int x, int y)
        +move(int x, int y)
        +draw()
    }
    class CompoundGraphic {
        -Graphic[] children
        +add(Graphic child)
        +remove(Graphic child)
        +move(int x, int y)
        +draw()
    }

Proxy

Steps

  1. Interface implemented by at least two classes (Proxy and Service)
  2. Proxy class has instance of service class
  3. Proxy class constructor has parameter of type service class
  4. Proxy class has association to Service
 classDiagram
   class ThirdPartyYTLib{
        +listVideos()
        +getVideoInfo(id)
        +downloadVideo(id)
   }
   class CachedYTClass{
        -ThirdPartyYTClass service
        +CachedYTClass(ThirdPartyYTClass s)
        +listVideos()
        +getVideoInfo(id)
        +downloadVideo(id)
   }
   class ThirdPartyYTClass{
        +listVideos()
        +getVideoInfo(id)
        +downloadVideo(id)
   }
   CachedYTClass ..|> ThirdPartyYTLib
   ThirdPartyYTClass ..|> ThirdPartyYTLib
   CachedYTClass o--> ThirdPartyYTLib
 classDiagram
   class ThirdPartyYTLib{
        +listVideos()
        +getVideoInfo(id)
        +downloadVideo(id)
   }
   class CachedYTClass{
        -ThirdPartyYTClass service
        +CachedYTClass(ThirdPartyYTClass s)
        +listVideos()
        +getVideoInfo(id)
        +downloadVideo(id)
   }
   class ThirdPartyYTClass{
        +listVideos()
        +getVideoInfo(id)
        +downloadVideo(id)
   }
   CachedYTClass ..|> ThirdPartyYTLib
   ThirdPartyYTClass ..|> ThirdPartyYTLib
   CachedYTClass o--> ThirdPartyYTLib

Observer

Steps

  1. Interface (Subscriber) implemented by at least one class (concrete subscribers)
  2. Interface has aggregation with a class (Publisher)
  3. Publisher class has array of interface (Subscriber) type
  4. Publisher class has two methods with parameter of interface (Subscriber) type
 classDiagram
    class EventManager{
        -EventListeners listeners[]
        +subscribe(EventListeners l)
        +unsubscribe(EventListeners l)
        +notify(EventType event, String data)
    }
    class EventListeners{
        <<interface>>
        +update(String filename)
    }
    class EmailAlertsListener{
        +update(String filename)
    }
    class LoggingListener{
        +update(String filename)
    }
    EventManager o--> EventListeners
    EmailAlertsListener ..|> EventListeners
    LoggingListener ..|> EventListeners
 classDiagram
    class EventManager{
        -EventListeners listeners[]
        +subscribe(EventListeners l)
        +unsubscribe(EventListeners l)
        +notify(EventType event, String data)
    }
    class EventListeners{
        +update(String filename)
    }
    class EmailAlertsListener{
        +update(String filename)
    }
    class LoggingListener{
        +update(String filename)
    }
    EventManager o--> EventListeners
    EmailAlertsListener ..|> EventListeners
    LoggingListener ..|> EventListeners
 classDiagram
    class EventManager{
        -EventListeners listeners[]
        +subscribe(EventListeners l)
        +unsubscribe(EventListeners l)
        +notify(EventType event, String data)
    }
    class EventListeners{
        +update(String filename)
    }
    class EmailAlertsListener{
        +update(String filename)
    }
    class LoggingListener{
        +update(String filename)
    }
    EventManager o--> EventListeners
    EmailAlertsListener ..|> EventListeners
    LoggingListener ..|> EventListeners