{"name":"execon","version":"1.2.1","author":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com","url":"https://github.com/coderaiser"},"description":"Patterns of function calls","homepage":"http://github.com/coderaiser/execon","repository":{"type":"git","url":"git://github.com/coderaiser/execon.git"},"dependencies":{},"license":"MIT","engines":{"node":">=0.8"},"main":"lib/exec.js","gitHead":"208bb6e7706f810fe49722c8d118fdbc0579f79b","bugs":{"url":"https://github.com/coderaiser/execon/issues"},"_id":"execon@1.2.1","scripts":{},"_shasum":"e5205530205d1e1bec58fd915ad98348bbf072a7","_from":".","_npmVersion":"2.11.0","_nodeVersion":"2.2.1","_npmUser":{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"},"maintainers":[{"name":"coderaiser","email":"mnemonic.enemy@gmail.com"}],"dist":{"shasum":"e5205530205d1e1bec58fd915ad98348bbf072a7","tarball":"http://registry-npm.ywwl.com/execon/download/execon-1.2.1.tgz","integrity":"sha512-ks2x6KJH7FA+oayqPf+koMoINBL18HdHObeb6sPncEJqkw5GcLbUYDRPKEYLzbjXRgRW58tN8ak4dSMwwxACTw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCd2+NzW6I9U7p4aWbkel194OHbhBhAjFM0fL5odGqv6wIhAJ3imVAnlgob6JiOBlQnfXQKRdpFYShsbBMId2CSvYq6"}],"size":3873,"noattachment":false,"key":"/execon/-/execon-1.2.1.tgz"},"directories":{},"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 > 3)\n    one();\nelse\n    two(one);\n    \n```\n\nAfter:\n\n```js\nexec.if(2 > 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&&stars&&downloadRank \"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","publish_time":1433511042240,"_cnpm_publish_time":1433511042240,"dist-tags":{"latest":"1.2.9"}}