{"id":25620781,"url":"https://github.com/codewell/chain","last_synced_at":"2026-06-17T18:04:25.272Z","repository":{"id":35111640,"uuid":"208064050","full_name":"codewell/chain","owner":"codewell","description":"Chaning function in JavaScript","archived":false,"fork":false,"pushed_at":"2023-03-04T04:43:11.000Z","size":372,"stargazers_count":0,"open_issues_count":3,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2024-10-16T11:04:15.044Z","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":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/codewell.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,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-12T13:58:35.000Z","updated_at":"2022-03-01T09:55:36.000Z","dependencies_parsed_at":"2024-08-23T05:00:50.802Z","dependency_job_id":"6cb1229e-0708-433d-8dba-7a631d15530c","html_url":"https://github.com/codewell/chain","commit_stats":{"total_commits":26,"total_committers":3,"mean_commits":8.666666666666666,"dds":0.2692307692307693,"last_synced_commit":"f725dc54f4bccd3d532c9288307ca94463ad3446"},"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewell%2Fchain","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewell%2Fchain/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewell%2Fchain/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/codewell%2Fchain/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/codewell","download_url":"https://codeload.github.com/codewell/chain/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239937695,"owners_count":19721484,"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-02-22T07:28:02.128Z","updated_at":"2026-05-25T06:30:16.484Z","avatar_url":"https://github.com/codewell.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# @codewell/chain\n\nJavaScript function for chaining functions\n\n## Description\n\nThe chaining function takes an arbitrary number of arguments. The first argument is of any type, the rest should all be functions sychronous or asychronous. Chain automatically returns a promise if one or more arguments is an async function. The first parameter is passed as input to the second argument (a funciton) which in turn is passed its return value to the next funciton and so on. E.g.\n\n```JavaScript\nchain(0,\n  (n) =\u003e n + 1, // =\u003e 0 + 1\n  (n) =\u003e n + 1 // =\u003e 1 + 1\n);\n// =\u003e 2\n```\n\nA requirement is therefore that all functions passed as arguments to the `chain` function has a return value (functions included).\n\n## Installation\n\n```\nnpm install @codewell/chain\n```\n\n## Basic usage\n\n```JavaScript\nimport chain from '@codewell/chain';\n\nconst addThree = n =\u003e n + 3;\nconst multiplyByFive = m =\u003e m * 5;\n\nchain(1, addThree, multiplyByFive);\n// =\u003e 20\n```\n\n```JavaScript\n// Async example\nimport chain from '@codewell/chain';\n\nconst addThreeAsync = (n) =\u003e new Promise((resolve, reject) =\u003e {\n  resolve(n + 3);\n})\n\nconst multiplyByFiveAsync = (m) =\u003e new Promise((resolve, reject) =\u003e {\n  resolve(m * 5);\n})\n\nchain(1, addThreeAsync, multiplyByFiveAsync)\n  .then(result =\u003e {\n    // Handle result somehow...\n  })\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewell%2Fchain","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcodewell%2Fchain","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcodewell%2Fchain/lists"}