{"id":29189369,"url":"https://github.com/coderaiser/execon","last_synced_at":"2025-07-01T23:07:21.503Z","repository":{"id":23702023,"uuid":"27074222","full_name":"coderaiser/execon","owner":"coderaiser","description":"Patterns of function calls","archived":false,"fork":false,"pushed_at":"2015-10-23T06:36:25.000Z","size":448,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2025-06-04T03:57:22.500Z","etag":null,"topics":["function","javascript"],"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/coderaiser.png","metadata":{"files":{"readme":"README.md","changelog":"ChangeLog","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":"2014-11-24T12:08:09.000Z","updated_at":"2018-03-20T09:36:23.000Z","dependencies_parsed_at":"2022-08-30T16:11:42.306Z","dependency_job_id":null,"html_url":"https://github.com/coderaiser/execon","commit_stats":null,"previous_names":[],"tags_count":14,"template":false,"template_full_name":null,"purl":"pkg:github/coderaiser/execon","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fexecon","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fexecon/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fexecon/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fexecon/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/coderaiser","download_url":"https://codeload.github.com/coderaiser/execon/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/coderaiser%2Fexecon/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":262188335,"owners_count":23272329,"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":["function","javascript"],"created_at":"2025-07-01T23:07:20.763Z","updated_at":"2025-07-01T23:07:21.429Z","avatar_url":"https://github.com/coderaiser.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Execon [![License][LicenseIMGURL]][LicenseURL] [![NPM version][NPMIMGURL]][NPMURL] [![Dependency Status][DependencyStatusIMGURL]][DependencyStatusURL] [![BuildStatusIMGURL]][BuildStatusURL]\n\nPatterns of function calls.\n\n## Install\n![NPM_INFO][NPM_INFO_IMG]\n```\nnpm i execon --save\n# or\nbower i execon --save\n```\n\n## Api\n\n```js\nvar exec = require('execon');\n```\n\n### exec\nCheck is parameter is function, if it's - executes it with given parameters\n\nWas:\n\n```js\nfunction(callback, p1, p2, pN) {\n    if (typeof callback === 'function')\n        callback(p1, p2, pN);\n}\n```\n\nNow\n\n```js\nfunction(callback, p1, p2, pN) {\n    exec(callback, p1, p2, pN);\n}\n```\n\nor just\n\n```js\nexec.ret(callback, p1, p2, pN);\n```\n\n### exec.if\nConditional execution one of two functions\n\nPreconditions:\n\n```js\nfunction one() {\n    console.log(1);\n}\n\nfunction two(callback) {\n    setTimeout(callback, 1000);\n}\n```\n\n\nBefore:\n\n```js\nif (2 \u003e 3)\n    one();\nelse\n    two(one);\n    \n```\n\nAfter:\n\n```js\nexec.if(2 \u003e 3, one, two);\n```\n\n### exec.parallel\nif a you need a couple async operation do same work, and then call callback, this function for you.\n\n**Node.js example**.\n\n```js\nvar fs      = require('fs'),\n    Util    = require('execon');\n\nexec.parallel([\n    function(callback) {\n        fs.readFile('file1', callback);\n    },\n    function(callback) {\n        fs.readFile('file2',  callback);\n    }\n], function(error, data1, data2) {\n    if (error)\n        console.log(error)\n    else\n        console.log(data1, data2);\n});\n```\n**Vanilla js example.**\n\n```js\nvar ONE_SECOND  = 1000,\n    TWO_SECONDS = 2000,\n    func        = function(time, str, callback) {\n        setTimeout(function() {\n            console.log(str);\n            callback(null, str);\n        }, time);\n    },\n    \n    func1       = func.bind(null, TWO_SECONDS, 'first'),\n    func2       = func.bind(null, ONE_SECOND, 'second');\n\nexec.parallel([func1, func2], function(error, str1, str2) {\n    console.log(str1, str2);\n});\n```\n\n### exec.series\nexecutes functions one-by-one\n\n```js\nfunction one(callback){\n    setTimeout(function() {\n        console.log(1)\n        callback();\n    }, 1000);\n}\n\nfunction two(callback) {\n    console.log(2);\n    callback();\n}\n\nexec.series([one, two], function(error) {\n    console.log(error || 'done');\n});\n```\n\n## License\n\nMIT\n\n[NPM_INFO_IMG]:             https://nodei.co/npm/execon.png?downloads=true\u0026\u0026stars\u0026\u0026downloadRank \"npm install rendy\"\n[NPMIMGURL]:                https://img.shields.io/npm/v/execon.svg?style=flat\n[DependencyStatusIMGURL]:   https://img.shields.io/gemnasium/coderaiser/execon.svg?style=flat\n[LicenseIMGURL]:            https://img.shields.io/badge/license-MIT-317BF9.svg?style=flat\n[NPMURL]:                   https://npmjs.org/package/execon \"npm\"\n[BuildStatusURL]:           https://travis-ci.org/coderaiser/execon  \"Build Status\"\n[DependencyStatusURL]:      https://gemnasium.com/coderaiser/execon \"Dependency Status\"\n[LicenseURL]:               https://tldrlegal.com/license/mit-license \"MIT License\"\n[BuildStatusIMGURL]:        https://img.shields.io/travis/coderaiser/execon/master.svg?style=flat\n[BuildStatusURL]:           https://travis-ci.org/coderaiser/execon  \"Build Status\"\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Fexecon","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcoderaiser%2Fexecon","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcoderaiser%2Fexecon/lists"}