{"id":13464751,"url":"https://github.com/riktar/uncino","last_synced_at":"2025-03-25T11:32:07.773Z","repository":{"id":58391149,"uuid":"528400769","full_name":"riktar/uncino","owner":"riktar","description":"Fast, tiny and solid hooks system for Javascript and Node.js","archived":false,"fork":false,"pushed_at":"2023-09-07T07:55:13.000Z","size":30,"stargazers_count":210,"open_issues_count":2,"forks_count":5,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T17:55:03.486Z","etag":null,"topics":["hooks","javascript","javascript-hooks","javascript-hooks-system","node","nodejs-hook"],"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/riktar.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}},"created_at":"2022-08-24T11:52:03.000Z","updated_at":"2024-08-12T19:09:41.000Z","dependencies_parsed_at":"2024-01-16T05:39:19.734Z","dependency_job_id":"6f46f16a-7d2c-4500-8a71-1b155b17527d","html_url":"https://github.com/riktar/uncino","commit_stats":{"total_commits":21,"total_committers":1,"mean_commits":21.0,"dds":0.0,"last_synced_commit":"132f7bfded1eeb20b9051774c3d4942d2ced450f"},"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riktar%2Funcino","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riktar%2Funcino/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riktar%2Funcino/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/riktar%2Funcino/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/riktar","download_url":"https://codeload.github.com/riktar/uncino/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":245454173,"owners_count":20617988,"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":["hooks","javascript","javascript-hooks","javascript-hooks-system","node","nodejs-hook"],"created_at":"2024-07-31T14:00:49.725Z","updated_at":"2025-03-25T11:32:05.735Z","avatar_url":"https://github.com/riktar.png","language":"JavaScript","funding_links":["https://github.com/sponsors/riktar"],"categories":["JavaScript"],"sub_categories":[],"readme":"# Uncino 🪝\n\n\u003e Fast, tiny and solid hooks system for Javascript and NodeJS\n\u003e \n\u003e **Uncino** is italian word for *hook*\n\n![Uncino - Fast, tiny and solid hooks system for Javascript and NodeJS](https://cdn.hashnode.com/res/hashnode/image/upload/v1662032725209/-hgyTmeyd.jpg?w=1600\u0026h=840\u0026fit=crop\u0026crop=entropy\u0026auto=compress,format\u0026format=webp)\n\nDo you know Wordpress hooks system? Uncino is a hooks system highly inspired to it!\n\n- Async / Await support\n- Node or Browser support\n- Actions / Hooks system\n- Easy to use\n- No Dependencies\n\n## Support this project\n\n[Buy me a coffee](https://github.com/sponsors/riktar)\n\n## Installation\n\n`npm i uncino` or `yarn add uncino`\n\n## Quick example\n\n```js index.js\nconst uncino = require('uncino')\nconst hooks = uncino()\n\nhooks.addHook('test', 'namespace', async (number) =\u003e {\n  return number + 10\n})\n\nhooks.addHook('test', 'namespace', async (number) =\u003e {\n  return number + 20\n})\n\nasync function testHook(myNumber) {\n  const newNumber = await hooks.runHook('test', myNumber)\n  console.log(myNumber, newNumber)\n}\n\ntestHook(3)  // 3 33\ntestHook(10)  // 10 40\n```\n\n## Philosophy\n\nUncino permit to your code to interact/modify another piece of code at specific, pre-defined spots.\n\nUncino has two types of hooks: **Actions and Hooks**. To use either, you need to write a custom function, and then register for a specific action or hook.\n\n**Actions** allow you to add data or change how your code operates. Actions will run at a specific point in the execution. Callback functions for Actions can perform some kind of a task, like echoing output to the user or inserting something into the database. Callback functions for an Action do not return anything back to the calling Action hook.\n\n**Hooks** give you the ability to change data during the execution of your code. Callback functions for Hooks will accept a variable, modify it, and return it. They are meant to work in an isolated manner, and should never have side effects such as affecting global variables and output. Hooks expect to have something returned back to them.\n\nWith Uncino you can create your own hook spots so that other developers can extend and modify your code or you can create your pluggable core.\n\n## Hooks API\n\nMethod Name           | Arguments                                        | Description\n----------------------|--------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------\n`addHook `            | `hookName, namespace, callback, priority`        | Register `callback` as new `hook` for `hookName` in `namespace` with `priority` (default: `10`).\n`removeHook`          | `hookName, namespace`                            | Remove hook for `hookName` in `namespace`\n`hasHook `            | `hookName, namespace`                            | Check if hook for `hookName` in `namespace` exists\n`removeAllHooks`      | `hookName`                                       | Remove all hooks for `hookName`\n`runHook`             | `hookName, params`                               | Run hook for `hookName` with `params`.  It returns a `Promise` with the hook result\n\n## Actions API\n\nMethod Name             | Arguments                                    | Description\n------------------------|----------------------------------------------|------------------------------------------------------------------------------------------------------------------------------\n`addAction `            | `actionName, namespace, callback, priority`  | Register `callback` as new `action` for `actionName` in `namespace` with `priority` (default: `10`).\n`removeAction`          | `actionName, namespace`                      | Remove hook for `actionName` in `namespace`\n`hasAction `            | `actionName, namespace`                      | Check if hook for `actionName` in `namespace` exists\n`removeAllActions`      | `actionName`                                 | Remove all actionss for `actionName`\n`runAction`             | `actionName, params`                         | Run action for `actionName` with `params`.  It returns a `Promise` with void value\n\n## Example\nClone the repo and look in the `test` folder\n\n## Develop\nClone the repo then use `npm install` for download all the dependencies then launch `npm run build` for build the project\n\n## Pull Requests?\nI'd love them!\n\n## Comments?\nLet's hear them! (The nice ones please!)\n\n## Me?\nIn case you're interested I'm [@argonautadev](http://twitter.com/argonautadev)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friktar%2Funcino","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Friktar%2Funcino","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Friktar%2Funcino/lists"}