{"id":28795608,"url":"https://github.com/bakerface/take-action","last_synced_at":"2025-07-10T20:37:58.054Z","repository":{"id":65514264,"uuid":"67825607","full_name":"bakerface/take-action","owner":"bakerface","description":"A fast, unopinionated, minimalist action framework for JavaScript.","archived":false,"fork":false,"pushed_at":"2016-10-12T17:24:06.000Z","size":24,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-06-18T03:09:33.897Z","etag":null,"topics":[],"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/bakerface.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}},"created_at":"2016-09-09T19:14:27.000Z","updated_at":"2016-10-02T04:29:25.000Z","dependencies_parsed_at":"2023-01-26T20:55:13.459Z","dependency_job_id":null,"html_url":"https://github.com/bakerface/take-action","commit_stats":null,"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"purl":"pkg:github/bakerface/take-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakerface%2Ftake-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakerface%2Ftake-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakerface%2Ftake-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakerface%2Ftake-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bakerface","download_url":"https://codeload.github.com/bakerface/take-action/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bakerface%2Ftake-action/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264653120,"owners_count":23644390,"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":"2025-06-18T03:09:34.315Z","updated_at":"2025-07-10T20:37:58.049Z","avatar_url":"https://github.com/bakerface.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# take-action\n[![build](https://img.shields.io/travis/bakerface/take-action.svg?flat-square)](https://travis-ci.org/bakerface/take-action)\n[![npm](https://img.shields.io/npm/v/take-action.svg?flat-square)](https://npmjs.com/package/take-action)\n[![downloads](https://img.shields.io/npm/dm/take-action.svg?flat-square)](https://npmjs.com/package/take-action)\n[![climate](https://img.shields.io/codeclimate/github/bakerface/take-action.svg?flat-square)](https://codeclimate.com/github/bakerface/take-action)\n[![coverage](https://img.shields.io/codeclimate/coverage/github/bakerface/take-action.svg?flat-square)](https://codeclimate.com/github/bakerface/take-action)\n\n### Action.create(action)\nCreates an action with the given definition. Returns a function that accepts `jacks` and `props` as arguments, respectively. This function will validate the jacks using `jackTypes` and the props using `propTypes` before performing the action. Additionally, defaults can be supplied by providing `getDefaultJacks` and `getDefaultProps` functions.\n\n``` javascript\nvar Action = require('take-action');\n\nvar createUser = Action.create({\n  name: 'createUser',\n  description: 'Creates a new user account',\n\n  jackTypes: {\n    users: Action.Types.shape({\n      add: Action.Types.func.isRequired\n    }).isRequired\n  },\n\n  propTypes: {\n    id: Action.Types.string.isRequired,\n    created: Action.Types.date.isRequired,\n    email: Action.Types.email.isRequired,\n    isAdmin: Action.Types.bool\n  }\n\n  getDefaultProps: function () {\n    return {\n      id: uuid.v4(),\n      created: Date.now()\n    };\n  },\n\n  perform: function (jacks, props) {\n    return jacks.users.add(props);\n  }\n});\n\n// a jack is an interface for external objects\n// a plug is an implementation of a jack\nvar jacks = {\n  users: new RedisUserPlug()\n};\n\nvar props = {\n  email: 'john@doe.com'\n};\n\ncreateUser(jacks, props);\n```\n\n### Action.bindActionsToJacks(actions, jacks)\nReturns a new set of actions, each bound to `jacks`, accepting `props` as the only argument.\n\n``` javascript\nvar Action = require('take-action');\n\nvar actions = {\n  hello: function (jacks, props) {\n    jacks.lang.hello(props.name);\n  },\n\n  goodbye: function (jacks, props) {\n    jacks.lang.goodbye(props.name);\n  },\n};\n\nvar jacks = {\n  lang: {\n    hello: function (name) {\n      console.log('Hello, ' + name);\n    },\n\n    goodbye: function (name) {\n      console.log('Goodbye, ' + name);\n    }\n  }\n};\n\nvar Greetings = Action.bindActionsToJacks(actions, jacks);\n\nvar user = {\n  name: 'John'\n};\n\nGreetings.hello(user);   // Hello, John\nGreetings.goodbye(user); // Goodbye, John\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbakerface%2Ftake-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbakerface%2Ftake-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbakerface%2Ftake-action/lists"}