{"id":16731684,"url":"https://github.com/spearwolf/jab","last_synced_at":"2026-06-30T09:31:11.909Z","repository":{"id":66459125,"uuid":"77219656","full_name":"spearwolf/jab","owner":"spearwolf","description":"an async dependency injection framework for modern javascript apps","archived":false,"fork":false,"pushed_at":"2017-04-29T09:34:15.000Z","size":43,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-10-11T04:22:42.998Z","etag":null,"topics":["async","dependency-injection","es6","javascript"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/spearwolf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-23T10:55:18.000Z","updated_at":"2017-02-15T16:28:22.000Z","dependencies_parsed_at":"2023-02-28T19:46:01.771Z","dependency_job_id":null,"html_url":"https://github.com/spearwolf/jab","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/spearwolf/jab","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fjab","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fjab/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fjab/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fjab/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/spearwolf","download_url":"https://codeload.github.com/spearwolf/jab/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/spearwolf%2Fjab/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34961541,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-30T02:00:05.919Z","response_time":92,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","dependency-injection","es6","javascript"],"created_at":"2024-10-12T23:38:32.643Z","updated_at":"2026-06-30T09:31:11.890Z","avatar_url":"https://github.com/spearwolf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"\u003e aysnc dependency injections and components on steroids for es2015+ javascript applications!\n\n[![Build Status](https://img.shields.io/travis/spearwolf/jab.svg)](https://travis-ci.org/spearwolf/jab) [![bitHound Overall Score](https://www.bithound.io/github/spearwolf/jab/badges/score.svg)](https://www.bithound.io/github/spearwolf/jab)\n\n### Install\n\n*jab* can be installed using npm:\n\n```bash\nnpm install spearwolf/jab\n```\n\n### Usage Example:\n\n```javascript\n    import { App } from '@spearwolf/jab';\n\n    class Foo {\n\n        constructor (plah, data) {\n            this.plah = plah;\n            this.data = data;\n        }\n\n    }\n\n    App.Component(Foo, {  // A Component is like an ordinary class, you can create multiple entities from it\n                          // (an Entity is an instance of a Component)\n\n        construct: ['plah', 'data!'], // Define the services which shall be used as arguments for Foo constructor\n                                      // data has an exclamation mark, so the construction of Foo will be delayed\n                                      // until 'data' is resolved\n\n        inject: ['bar', 'fooBar!'],  // After object creation, add (create) these Components\n                                     // as properties to our object\n\n        // Remember: construct services \u0026 inject components\n\n        provider: {  // our Component has some extra providers which are not defined in the App\n                     // providers are hierachical so they can override providers with same name from the App\n\n            data: fetch('https://example.com/123.json')   // Every Promise can be used as provider!\n\n        }\n\n    });\n\n\n    class Plah { }\n    // no annotations here!\n    // without any annotations a class will be act as Service (which is a Compoment singelton)\n\n    class Bar {\n        constructor () {\n            return new Promise(resolve =\u003e setTimeout(resolve(this), 4));\n        }\n        // ooops, our constructor returns a Promise!\n        // this will tell our App to wait for the Service initialization until\n        // the Promise is resolved (with an instance of Bar as value)\n\n        afterInitialized () {               // [optional] will be called after object construction\n            console.log('4ms later..');\n\n            return new Promise(resolve =\u003e setTimeout(resolve(this), 4));\n                                            // returning a Promise is optional but very helpful\n                                            // when you want to do some async stuff here\n        }\n    }\n\n    App.Component(Bar);\n\n\n    class FooBar {\n        constructor (parent) {\n            this.foo = parent;\n        }\n    }\n\n    App.Component(FooBar, { construct: ['parent'] })\n                                // Foo asks for 'fooBar' after object creation,\n                                // so *parent* will be an instance of Foo in this case,\n                                // otherwise *parent* will be null\n\n\n    const app = new App({\n        provider: {\n            foo    : Foo,\n            plah   : Plah,\n            bar    : Bar,\n            fooBar : FooBar\n        }\n    });\n\n    app.createEntity('foo').then(foo =\u003e {\n\n        foo.plah().then(plah =\u003e {\n            // do something with service plah\n        });\n\n        console.log(foo.data);  // log json data\n\n        foo.bar().then(bar =\u003e {  // create a new Bar entity\n            // [8ms later] do something fantastic with bar\n        });\n\n        console.log(foo.fooBar);  // fooBar is an initialized FooBar entity\n\n    });\n\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspearwolf%2Fjab","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fspearwolf%2Fjab","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fspearwolf%2Fjab/lists"}