{"id":16890305,"url":"https://github.com/marak/prototype-hooks","last_synced_at":"2025-04-11T13:09:21.953Z","repository":{"id":65994074,"uuid":"79708252","full_name":"Marak/prototype-hooks","owner":"Marak","description":"add before and after hooks to any JavaScript prototype chain","archived":false,"fork":false,"pushed_at":"2017-01-25T05:00:16.000Z","size":7,"stargazers_count":10,"open_issues_count":0,"forks_count":0,"subscribers_count":5,"default_branch":"master","last_synced_at":"2024-10-29T11:58:20.910Z","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/Marak.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}},"created_at":"2017-01-22T09:38:20.000Z","updated_at":"2022-03-23T23:30:11.000Z","dependencies_parsed_at":"2023-07-07T05:31:26.781Z","dependency_job_id":null,"html_url":"https://github.com/Marak/prototype-hooks","commit_stats":{"total_commits":10,"total_committers":1,"mean_commits":10.0,"dds":0.0,"last_synced_commit":"6c0748869e3337a0fa467f7c44348ce8185941f8"},"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marak%2Fprototype-hooks","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marak%2Fprototype-hooks/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marak%2Fprototype-hooks/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Marak%2Fprototype-hooks/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Marak","download_url":"https://codeload.github.com/Marak/prototype-hooks/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239648449,"owners_count":19674375,"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-13T17:02:21.061Z","updated_at":"2025-02-19T11:30:23.852Z","avatar_url":"https://github.com/Marak.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# prototype-hooks\n\nAdds `before` and `after` hooks to any JavaScript protoype chain.\n\n## Installation\n\n```\nnpm install --save prototype-hooks\n```\n\n## Features\n\n  - Adds `.before()` hook for all existing prototype methods\n  - Adds `.after` hook for all existing prototype methods\n  - Quickly enables Apsect-oriented Programming [AOP](https://en.wikipedia.org/wiki/Aspect-oriented_programming) patterns for JavaScript\n\n## Example Usage\n\n```js\nvar hooks = require('protoype-hooks');\n\nvar Creature = function (opts) {\n  this.name = opts.name;\n};\n\nCreature.prototype.talk = function (data, cb) {\n  cb(null, this.name + ' says ' + data.text);\n};\n\nhooks(Creature);\n\nvar larry = new Creature({ name: \"Larry\" });\n\nlarry.before('talk', function(data, next) {\n  data.text = data.text + \"!\";\n  next(null, data);\n});\n\nlarry.after('talk', function(text, next) {\n  text = text + ' ... ';\n  next(null, text);\n});\n\nlarry.talk({ text: 'hi'}, function (err, result){\n  console.log(err, result);\n  // outputs: 'Larry says hi! ... '\n})\n\n```","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarak%2Fprototype-hooks","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmarak%2Fprototype-hooks","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmarak%2Fprototype-hooks/lists"}