{"id":17677436,"url":"https://github.com/unadlib/glaive","last_synced_at":"2025-07-23T21:34:25.252Z","repository":{"id":86376662,"uuid":"103663211","full_name":"unadlib/glaive","owner":"unadlib","description":"Trying to build a new dependency module injector","archived":false,"fork":false,"pushed_at":"2017-09-25T05:55:04.000Z","size":191,"stargazers_count":3,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-03-15T09:45:02.463Z","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":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/unadlib.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"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":"2017-09-15T13:57:35.000Z","updated_at":"2017-09-25T01:18:54.000Z","dependencies_parsed_at":"2023-05-02T08:03:46.271Z","dependency_job_id":null,"html_url":"https://github.com/unadlib/glaive","commit_stats":{"total_commits":27,"total_committers":1,"mean_commits":27.0,"dds":0.0,"last_synced_commit":"a5f6b0f1027d5a220a6174c640abd1f0577264c0"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unadlib%2Fglaive","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unadlib%2Fglaive/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unadlib%2Fglaive/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/unadlib%2Fglaive/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/unadlib","download_url":"https://codeload.github.com/unadlib/glaive/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":246357551,"owners_count":20764359,"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-24T07:28:41.771Z","updated_at":"2025-03-30T17:41:53.160Z","avatar_url":"https://github.com/unadlib.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Glaive\nTrying to build a new dependency module Injector\n\n[![Travis](https://img.shields.io/travis/unadlib/glaive.svg)](https://travis-ci.org/unadlib/glaive)\n[![Coverage Status](https://coveralls.io/repos/github/unadlib/glaive/badge.svg?branch=master)](https://coveralls.io/github/unadlib/glaive?branch=master)\n[![npm](https://img.shields.io/npm/v/glaive.svg)](https://www.npmjs.com/package/glaive)\n[![npm](https://img.shields.io/npm/dt/glaive.svg)](https://www.npmjs.com/package/glaive)\n[![npm](https://img.shields.io/npm/l/glaive.svg)](https://www.npmjs.com/package/glaive)\n\n## Features\n* Overall process async dependency module\n* After/before inject process\n* Functional inject \u0026 decorator inject\n* Custom Injector\n* Implement module initialization lifecycle\n* Inheritance of module\n* Inheritance of module injector\n* Override of module injector\n* Merge options for value provider\n* Custom options distribute to module\n* Custom rule distribute to dependency module\n* Custom distribute module name to dependency module\n* Before injection use `preInject`\n* Commons mount Params use `mountParams`\n* Dependencies Module `preDistribute`\n\n## Usage\n```bash\nyarn add glaive // or `npm install --save glaive`\n```\n\n## Example\n```javascript\nimport { Injector as getInjector, Module, Decorator } from \"glaive\"\n\nconst Injector = getInjector(class BaseModule {})\n\nclass Call extends Module {}\n\n@Decorator({\n  deps: [\"Environment\"],\n  after: environment =\u003e {\n    console.log(environment)\n  },\n})\nclass NetWork extends Module {}\n\nclass HighSpeedNetWork extends NetWork {}\n\nclass Environment extends Module {\n  constructor(...args){\n    super(...args)\n    this.system = 'ios'\n  }\n}\n\nclass Storage extends Module {\n  constructor(...args) {\n    super(...args)\n  }\n  async initialize() {\n    await new Promise(resolve=\u003esetTimeout(resolve, 0))\n  }\n}\n\n// All aysnc functions support sync.\n\nclass Phone extends Injector {\n  constructor(...args) {\n    super(...args)\n    this.inject([\n        {\n          module: Environment,\n          key: \"env\"\n        },\n        {\n          module: Storage,\n          deps: ['Environment'],\n          before: async (environment,storage) =\u003e {\n            console.log(environment,storage)\n            await new Promise(resolve=\u003esetTimeout(resolve, 0))\n          }\n        },\n        {\n          module: NetWork,\n        },\n        {\n          module: Call,\n          deps: ['Environment','Storage','NetWork'],\n          after: async () =\u003e {\n            await new Promise(resolve=\u003esetTimeout(resolve, 0)) // this time is after call init.\n          }\n        }\n      ])\n  }\n}\n\nclass Mobile extends Phone {\n    constructor(...args){\n      super(...args)\n      this.inject([\n        {\n          module: HighSpeedNetWork,\n          key: '$_HighSpeedNetWork',\n          deps: ['Storage']\n        }\n      ])\n    }\n}\n\nconst mobile = new Mobile({\n  state: 'CN',\n  done: done =\u003e {\n    console.log('\\n')\n    console.log(`done is ${done}!\\n`, mobile)\n  },\n})\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funadlib%2Fglaive","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Funadlib%2Fglaive","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Funadlib%2Fglaive/lists"}