{"id":20671135,"url":"https://github.com/allnulled/hook-by-priority","last_synced_at":"2026-06-05T05:31:47.298Z","repository":{"id":57266507,"uuid":"266794706","full_name":"allnulled/hook-by-priority","owner":"allnulled","description":"Hooking system using priority numbers.","archived":false,"fork":false,"pushed_at":"2020-05-25T14:49:30.000Z","size":3,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-18T09:39:48.831Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"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/allnulled.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}},"created_at":"2020-05-25T14:05:11.000Z","updated_at":"2021-11-07T19:38:34.000Z","dependencies_parsed_at":"2022-08-25T03:41:06.545Z","dependency_job_id":null,"html_url":"https://github.com/allnulled/hook-by-priority","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fhook-by-priority","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fhook-by-priority/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fhook-by-priority/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/allnulled%2Fhook-by-priority/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/allnulled","download_url":"https://codeload.github.com/allnulled/hook-by-priority/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242889644,"owners_count":20201998,"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-11-16T20:25:23.384Z","updated_at":"2025-12-16T04:43:03.116Z","avatar_url":"https://github.com/allnulled.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# hook-by-priority\n\nHooking system using priority numbers.\n\n## Advantages\n\n - **Asynchronous hooks.**\n - **Parameters passed along the cycle of hooks.**\n - **Less than 50 lines of code.**\n - **For `node.js` or `browser`.**\n - **No dependencies at all.**\n\n## Installation\n\n`$ npm install -s hook-by-priority`\n\n## Usage\n\nThis example appends a character for each hook asynchronously.\n\nIt also uses `priority` option to order the `hooks` added to the created hooks-manager.\n\n```js\nconst Hooks = require(\"hook-by-priority\");\nconst hooks = Hooks.create();\n\nconst add = function(char, data) {\n\treturn new Promise(function(ok, fail) {\n\t\tdata.msg += char;\n\t\tsetTimeout(ok, 100);\n\t});\n};\n\nhooks.add(\"on:init\", async params =\u003e await add(\"e\", params), 90);\nhooks.add(\"on:init\", async params =\u003e await add(\"!\", params), 50);\nhooks.add(\"on:init\", async params =\u003e await add(\"l\", params), 70);\nhooks.add(\"on:init\", async params =\u003e await add(\"o\", params), 60);\nhooks.add(\"on:init\", async params =\u003e await add(\"l\", params), 80);\nhooks.add(\"on:init\", async params =\u003e await add(\"H\", params), 100);\nhooks.use(\"on:init\", { msg: \"\" }).then(output =\u003e console.log(output.msg));\n```\n\nThis script is also under `test/readme.test.js` file of the project.\n\n## License\n\nThis project is released under [WTFPL (or *What The Fuck Public License*)](https://es.wikipedia.org/wiki/WTFPL), which means **do what you want**.\n\n## Issues\n\nPlease, address your issues [here](https://github.com/allnulled/hook-by-priority/issues).","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fhook-by-priority","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fallnulled%2Fhook-by-priority","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fallnulled%2Fhook-by-priority/lists"}