{"id":18465182,"url":"https://github.com/sleexyz/callable","last_synced_at":"2025-04-30T22:15:50.097Z","repository":{"id":57192991,"uuid":"96714569","full_name":"sleexyz/callable","owner":"sleexyz","description":"Type-safe extendable function class","archived":false,"fork":false,"pushed_at":"2017-12-01T23:41:29.000Z","size":34,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-20T05:49:05.786Z","etag":null,"topics":["callable","es6","flow","flowtype","function"],"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/sleexyz.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-09T22:15:57.000Z","updated_at":"2023-05-08T13:25:39.000Z","dependencies_parsed_at":"2022-09-01T06:01:08.495Z","dependency_job_id":null,"html_url":"https://github.com/sleexyz/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/sleexyz%2Fcallable","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleexyz%2Fcallable/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleexyz%2Fcallable/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/sleexyz%2Fcallable/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/sleexyz","download_url":"https://codeload.github.com/sleexyz/callable/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251582976,"owners_count":21612740,"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":["callable","es6","flow","flowtype","function"],"created_at":"2024-11-06T09:12:15.193Z","updated_at":"2025-04-29T20:44:46.726Z","avatar_url":"https://github.com/sleexyz.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Callable\n\n[![NPM](https://nodei.co/npm/callable-class.png)](https://npmjs.org/package/callable-class)\n\n[![CircleCI](https://circleci.com/gh/sleexyz/callable.svg?style=svg)](https://circleci.com/gh/sleexyz/callable)\n\n\nAn extendable base class for callable classes, designed to work nicely with Flow.\n\n## Type definition:\n\n```js\n// @flow\ndeclare class Callable\u003cA, B\u003e extends Function {\n  // See https://github.com/facebook/flow/issues/3084\n  // (A): B\n  $call: A =\u003e B;\n  constructor(A =\u003e B): this;\n}\n```\n\n## Examples:\n\n#### Extend `Callable` with custom methods\n```js\n// @flow\nimport Callable from \"callable-class\";\n\nclass Composable\u003cA, B\u003e extends Callable\u003cA, B\u003e {\n  andThen(next: B =\u003e C): Composable\u003cA, B\u003e {\n    return new Composable(x =\u003e next(this(x)));\n  }\n}\n\nconst foo = new Composable(x =\u003e [...x, 1])\n  .andThen(x =\u003e [...x, 2])\n  .andThen(x =\u003e [...x, 3]);\n\nconsole.log(foo([])); // [1, 2, 3]\n```\n\n#### Extend `Callable` with custom fields and constructor\n```js\n// @flow\nimport Callable from \"callable-class\";\n\nclass ActionCreator\u003cType, A, B\u003e extends Callable\u003cA, B\u003e {\n  type: string;\n  constructor(type: Type, fn: A =\u003e B) {\n    super(fn);\n    this.type = type;\n  }\n}\n\nconst foo = new ActionCreator(\"foo\", x =\u003e x + 1);\n\nconsole.log(foo.type); // \"foo\"\nconsole.log(foo(0)); // 1\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleexyz%2Fcallable","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsleexyz%2Fcallable","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsleexyz%2Fcallable/lists"}