{"id":17983474,"url":"https://github.com/techjacker/abstract-factory","last_synced_at":"2025-07-06T18:33:10.430Z","repository":{"id":8920487,"uuid":"10648267","full_name":"techjacker/abstract-factory","owner":"techjacker","description":"Super simple dependency injection","archived":false,"fork":false,"pushed_at":"2013-07-29T10:49:54.000Z","size":184,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-08T22:11:28.275Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/techjacker.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}},"created_at":"2013-06-12T17:43:24.000Z","updated_at":"2013-11-07T18:06:18.000Z","dependencies_parsed_at":"2022-08-27T22:31:39.177Z","dependency_job_id":null,"html_url":"https://github.com/techjacker/abstract-factory","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/techjacker/abstract-factory","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fabstract-factory","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fabstract-factory/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fabstract-factory/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fabstract-factory/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/techjacker","download_url":"https://codeload.github.com/techjacker/abstract-factory/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/techjacker%2Fabstract-factory/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263951857,"owners_count":23534821,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-10-29T18:17:21.630Z","updated_at":"2025-07-06T18:33:10.412Z","avatar_url":"https://github.com/techjacker.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# abstract-factory\n\n[![Build Status](https://secure.travis-ci.org/techjacker/abstract-factory.png)](http://travis-ci.org/techjacker/abstract-factory)\n\n## Description\nInterface for abstracting classes in your modules; IoC container.\n\n### How does using it help you?\n- Make your tests easier\n- Cheap dependency injection; no monolothic libs needed\n\n\n## Install\n```Shell\nnpm install abstract-factory\n```\n\n\n## Full Example\n\n```JavaScript\nvar AbstractFactory = require('abstract-factory');\nvar assert = require('assert');\n\n\n// var AbstractFactory = require('abstract-factory');\nvar originalApi = {\n\t\treturnData: function () {\n\t\t\treturn 'lots of data';\n\t\t}\n\t},\n\tcheaperApi = {\n\t\treturnData: function () {\n\t\t\treturn 'less data';\n\t\t}\n\t};\n\nvar App = function (AbFactory) {\n\tthis.myInterface = AbFactory;\n};\nApp.prototype.getData = function () {\n\t// instead of referencing api directly, eg originalApi.returnData();\n\treturn this.myInterface.getFactory('api').returnData();\n};\n\n\n// you've just received funding for your great new idea\n// from YCombinator, and you launch your first version, fantastic!\nvar MyAppAlpha = new App(new AbstractFactory({\n\tapi: originalApi\n}));\n\n// oh dear your investors cut the funding suddenly...\n// ...that's okay, all you have to do is swap out a single dependency\n// when instantiating your app; no need to go hunting for methods\n// buried deep in your lib dir\nvar MyAppBeta = new App(new AbstractFactory({\n\tapi: cheaperApi\n}));\n\nassert.equal(MyAppAlpha.getData(), 'lots of data', 'alpha app returns correct data from api');\nassert.equal(MyAppBeta.getData(), 'less data', 'beta app returns correct data from api');\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fabstract-factory","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Ftechjacker%2Fabstract-factory","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Ftechjacker%2Fabstract-factory/lists"}