{"id":19124443,"url":"https://github.com/panates/putil-callable","last_synced_at":"2026-06-25T09:31:24.432Z","repository":{"id":23597816,"uuid":"96895070","full_name":"panates/putil-callable","owner":"panates","description":"A callable class implementation","archived":false,"fork":false,"pushed_at":"2023-01-09T06:41:32.000Z","size":187,"stargazers_count":1,"open_issues_count":2,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-02-04T21:43:37.562Z","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/panates.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":"2017-07-11T13:18:02.000Z","updated_at":"2023-04-07T02:29:24.000Z","dependencies_parsed_at":"2023-01-13T23:32:59.861Z","dependency_job_id":null,"html_url":"https://github.com/panates/putil-callable","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/panates%2Fputil-callable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fputil-callable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fputil-callable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/panates%2Fputil-callable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/panates","download_url":"https://codeload.github.com/panates/putil-callable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240183761,"owners_count":19761439,"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-09T05:29:11.621Z","updated_at":"2026-06-05T21:30:19.992Z","avatar_url":"https://github.com/panates.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# putil-callable\n\n[![NPM Version][npm-image]][npm-url]\n[![NPM Downloads][downloads-image]][downloads-url]\n[![Build Status][travis-image]][travis-url]\n[![Test Coverage][coveralls-image]][coveralls-url]\n[![DevDependencies][devdependencies-image]][devdependencies-url]\n\nThis package contains two very handy callable class implementations.\nCallable: Base extensible callable class\nCallableEventEmitter: Mixin of Callable and EventEmitter classes. \n\n## Installation\n\n  - `$ npm install putil-callable --save`\n\n## Usage\n\nExtend Callable in ES6\n```javascript\nconst {Callable} = require('putil-callable');\n\nclass MyCallable extends Callable {\n\n  constructor() {\n    super('handle');\n  }\n\n  handle(msg) {\n    console.log('MyCallable:', msg);\n  }\n}\nconst obj1 = new MyCallable();\nobj1('This is a callable class');\n```\nExtend Callable in ES5\n```javascript\nconst Callable = require('putil-callable').Callable;\n\nfunction MyCallable() {  \n  return Callable.call(this, 'handle');  \n}\nMyCallable.prototype = Object.create(Callable.prototype);\nMyCallable.prototype.constructor = MyCallable;\nMyCallable.prototype.handle = function(msg) {\n    console.log('MyCallable:', msg);\n};\n\nconst obj1 = new MyCallable();\nobj1('This is a callable class');\n```\n\nExtend CallableEventEmitter in ES6\n```js\nconst {CallableEventEmitter} = require('putil-callable');\n\nclass MyCallable extends CallableEventEmitter {\n\n  constructor() {\n    super();\n  }\n\n  __call__(msg) {\n    this.emit('msg', msg);\n  }\n}\n\nconst obj2 = new MyCallable();\n\nobj2.on('msg', function(msg) {\n  console.log('CallableEventEmitter:', msg);\n});\n\n```\n\n## Node Compatibility\n\n  - node `\u003e= 1`;\n  \n### License\n[MIT](LICENSE)\n\n[npm-image]: https://img.shields.io/npm/v/putil-callable.svg\n[npm-url]: https://npmjs.org/package/putil-callable\n[travis-image]: https://img.shields.io/travis/panates/putil-callable/master.svg\n[travis-url]: https://travis-ci.org/panates/putil-callable\n[coveralls-image]: https://img.shields.io/coveralls/panates/putil-callable/master.svg\n[coveralls-url]: https://coveralls.io/r/panates/putil-callable\n[downloads-image]: https://img.shields.io/npm/dm/putil-callable.svg\n[downloads-url]: https://npmjs.org/package/putil-callable\n[devdependencies-image]: https://david-dm.org/panates/putil-callable/dev-status.svg\n[devdependencies-url]:https://david-dm.org/panates/putil-callable?type=dev\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanates%2Fputil-callable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpanates%2Fputil-callable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpanates%2Fputil-callable/lists"}