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

dizy

v0.5.0

Published

A lightweight Vanilla JavaScript Dependency Injection implementation with lifecycles.

Downloads

20

Readme

Getting Started

Installation

npm install dizy

Simple usage

import { ContextContainerFactory, SingletoneConfig } from "dizy";

// Create array of di object configurations
const diObjectsConfigs = [
     // Singletone object config
    new SingletoneConfig(
        'carService', // name of DI Object
        CarService // DI Object class or function
    ),
    new SingletoneConfig('engineService', EngineService),
];

// Class of your app where you want to use DI
// It's just an example, you can use it anywhere
class App {
    constructor() {
        // Next to lines of code is needed for configuring your DI Context
        this.context = ContextContainerFactory.createContainer(diObjectsConfigs, 'appContext');
        this.context.init(); // Runs the context
    }

    start() {
        const carService = this.context.getInstance('carService'); // Getting instance of your DI Object
        carService.check();
    }
}

class CarService {
    constructor(engineService) { // name of constructor parameter must be equal to name of object in DI Context
        this.engineService = engineService;
    }

    check() {
        this.engineService.pressure();
    }
}

class EngineService {
    constructor() { }

    pressure() {
        console.log('Pressure is high!');
    }
}

Introduction

Welcome to the documentation of Dizy! This library provides a powerful and flexible solution for managing dependencies in your applications, making it easier to write maintainable and testable code.

Dependency injection is a design pattern that allows you to decouple components from their dependencies, making them more reusable and easier to test. With our DI library, you can easily inject dependencies into your components, allowing them to focus on their core functionality.

The library offers a simple and intuitive API, making it easy to get started with dependency injection.

In this documentation, we'll cover everything you need to know about using Dizy. We'll start with an overview of the library's features and how they can benefit your projects. Then, we'll dive into specific examples of how to use the library in different scenarios. Finally, we'll provide some tips and best practices for working with the library effectively.

Let's get started and explore the power of dependency injection with Dizy!

Goals

  1. Help the developer write more reliable and easy to read code.
  2. Simplify and speed up the development process.
  3. Allow you to commit the results of architectural analysis in the software objects form.
  4. Provide the ability to quickly replace or disable software objects.
  5. Ensure compliance with the lifecycle of objects and provide an opportunity to create special lifecycles.
  6. Provide tools for configuring objects

Review of approaches

Service Locator

Dependency Injection

Dizy multilifecycle

Other implementations and performance overview

Authors

Supporters

Become a sponsor on patreon

Become a sponsor on opencollective to get your company in front of future thousands of engaged developers and help us out!

Love Dizy? Give our repo a star :star: :arrow_up:.