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

@botorjs/boot

v0.0.1

Published

Boot of framework Botorjs

Downloads

44

Readme

Boot

Build Status Coverage Status

Library that core of Botorjs include IoC, Loader and Alias

Installation

npm install @botorjs/boot --save

Setup and Example

  • Example

    import { Boot, Injectable, ServiceProvider } from '@botorjs/boot';

    var app = new Boot();
    class Service {
        public i: number = 1;
    }

    @Injectable()
    class TestClass {
        constructor(private _service: Service) {}

        public get service(): Service {
            return this._service;
        }
    }

    class ProviderTest extends ServiceProvider{
        register(app: Boot) {
            app.ioc.singleton(Service.name, Service);
            app.ioc.bind(TestClass.name, TestClass);
        }

        boot(app: Boot) {
            const service = app.get<Service>(Service);
            service.i++;
        }
    }

    // using ServicerProvider provider resource to app
    app.loader.add(ProviderTest);
    app.preload();
    var test = app.get<TestClass>(TestClass);
    expect(test.service.i).to.eql(2);

    // resolve class with inject
    var test2: TestClass = app.resolve(TestClass);
    expect(test2.service.i).to.eql(2);

    // using alias
    app.alias.add("test", "test1");
    app.ioc.bind("test1", "test_2");
    var val = app.get<string>("test");
    expect(val).to.eql("test_2");

    //
    app = new Boot();
    app.hook.on("app:preload:end", () => {
        console.log("work");
    })
    app.preload();

API

Boot

| Property | Description | Return | |---------- |:-------------|------| | hook | Hook event in Boot | Hook | | alias | centered | Alias | | ioc | as ioc | IoC | | loader | as ioc fake | IoC | | resolve(target) | resolve a class target have inject | object | | get(target) | Get target in ioc | any | | preload() | preload of Boot | void |

Hook

  • Hook event of Boot

| Property | Description | |---------- |:-------------| | on(name, callback) | listen event | | emit(name, data) | emit event |

Alias

  • Alias name or fuction in Ioc

| Property | Description | |---------- |-------------| | get(target) | get target was alias | | add(tagert, alias) | add new alias or overwrite aslias exits with same target name or function | | has(tagert) | check alias have exist |

IoC

  • IoC manager container and inject the dependencies, now manager

| Property | Description | |---------- |-------------| | get(target) | get target was alias | | resolve(target) | get target was alias | | singleton(name, tagert, [type = TypeContainer.Check]) | add singleton container | | bind(name, tagert, [type = TypeContainer.Check]) | add bind container | | has(tagert) | check a container have exist in ioc | | remove(name) | remove a container in ioc with name container |

Loader

  • Loader provider resource to app , example as Ioc, Listen hook, register component to app

| Property | Description | |---------- |:-------------| | add(provider) | add new Provider, if app before preload will add provider waiti unitl preload, if app after preload will addd provider and regiser and boot right away | preload() | preload of Loader |