{"_id":"join","_rev":"359236","name":"join","description":"The join / synchronize module of FuturesJS (Browser, Node.js, Bower, and Pakmanager)","dist-tags":{"latest":"3.0.0"},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"time":{"modified":"2024-06-18T08:42:53.000Z","created":"2011-07-13T20:21:41.202Z","3.0.0":"2014-01-13T23:09:10.156Z","2.3.2":"2014-01-13T18:17:32.200Z","2.3.1":"2012-05-31T15:34:48.411Z","2.3.0":"2011-07-15T17:15:04.511Z","2.1.1":"2011-07-13T20:21:41.202Z"},"users":{"jasoncmcg":true},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.com"},"repository":{"type":"git","url":"git://github.com/FuturesJS/join.git"},"versions":{"3.0.0":{"name":"join","version":"3.0.0","description":"The join / synchronize module of FuturesJS (Browser, Node.js, Bower, and Pakmanager)","homepage":"https://github.com/FuturesJS/join","keywords":["futuresjs","flow-control","async","asynchronous","futures","promises","deferreds","join","synchronize","util","browser"],"repository":{"type":"git","url":"git://github.com/FuturesJS/join.git"},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.com"},"main":"join.js","directories":{"lib":"."},"dependencies":{},"engines":{"node":"*","ender":">= 0.5.0"},"devDependencies":{},"optionalDependencies":{},"readmeFilename":"README.md","bugs":{"url":"https://github.com/FuturesJS/join/issues"},"_id":"join@3.0.0","dist":{"shasum":"cfb841db7b0a1dff132a07a582dbc06c21649713","tarball":"http://registry-npm.ywwl.com/join/download/join-3.0.0.tgz","integrity":"sha512-RtCMVccL9rDfwqgQHpRx8ewxRDPkN2eoPbElrBJYMZIt0pTW2x8p2km4svpFmLb/sOPPRfD+ZwlJwYmONVVZzA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDD94CRDQMqH7c65qXRj0dsyHy9b1SpDehxbtxqxEq84AIhAJ++lkDRvLHpBJ3+373VNgmUmXkhkAh7uFAiimbi5sgj"}],"size":6658,"noattachment":false,"key":"/join/-/join-3.0.0.tgz"},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"publish_time":1389654550156,"_cnpm_publish_time":1389654550156},"2.3.2":{"name":"join","version":"2.3.2","description":"The join / synchronize module of FuturesJS (Ender.JS and Node.JS)","homepage":"https://github.com/coolaj86/futures","keywords":["flow-control","async","asynchronous","futures","promises","deferreds","join","synchronize","util","browser"],"repository":{"type":"git","url":"git://github.com/coolaj86/futures.git"},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.info"},"main":"join.js","directories":{"lib":"."},"dependencies":{"future":"2.x"},"engines":{"node":"*","ender":">= 0.5.0"},"readmeFilename":"README.md","bugs":{"url":"https://github.com/coolaj86/futures/issues"},"_id":"join@2.3.2","dist":{"shasum":"53a5268e86be891904ca2bae5acf0b544b4714a9","tarball":"http://registry-npm.ywwl.com/join/download/join-2.3.2.tgz","integrity":"sha512-WiwswTAJWq4jeEqhey0lwEhKgVs5AojC2D9zLAFkVPc+VAu3w8n74MG1AKk8xpNcN67FRQrbQuuEl33mmuhNzw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDGyq6KTWYb2UOTVuiVtgNBiOMIrD8Yy/tvz7EdWQJbgIgaOOPl7qjyDU76qVBsQINaN9zHD3efB+d2HQCEtIFzuU="}],"size":2320,"noattachment":false,"key":"/join/-/join-2.3.2.tgz"},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"publish_time":1389637052200,"_cnpm_publish_time":1389637052200},"2.3.1":{"name":"join","version":"2.3.1","description":"The join / synchronize module of FuturesJS (Ender.JS and Node.JS)","homepage":"https://github.com/coolaj86/futures","keywords":["flow-control","async","asynchronous","futures","promises","deferreds","join","synchronize","util","browser"],"repository":{"type":"git","url":"git://github.com/coolaj86/futures.git"},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.info"},"main":"join.js","directories":{"lib":"."},"dependencies":{"future":">= 2.3.1"},"engines":{"node":"*","ender":">= 0.5.0"},"_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"_id":"join@2.3.1","devDependencies":{},"optionalDependencies":{},"_engineSupported":true,"_npmVersion":"1.1.21","_nodeVersion":"v0.6.18","_defaultsLoaded":true,"dist":{"shasum":"a3dfc8303c86e0d805d98283d4c08d8d649e420a","tarball":"http://registry-npm.ywwl.com/join/download/join-2.3.1.tgz","integrity":"sha512-SC4t+SjKyyvCgY1Xsi25UeDo972KSokDT7ggwP15PDknNzSkaFiqNpUY39LuXREG0I3l8wlbPM3rNz7/swWu2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDwV/IO24eFIphtgMJgqGVAgeB3fTXi7W6QnoLCaaxFGAiAr4NeK29nhgtiK9le4yfYdqLxjKK1Ajnwjl7h9JPb+tg=="}],"size":2324,"noattachment":false,"key":"/join/-/join-2.3.1.tgz"},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"publish_time":1338478488411,"_cnpm_publish_time":1338478488411},"2.3.0":{"name":"join","version":"2.3.0","description":"The join / synchronize module of FuturesJS (Ender.JS and Node.JS)","homepage":"https://github.com/coolaj86/futures","keywords":["flow-control","async","asynchronous","futures","promises","deferreds","join","synchronize","util","browser"],"repository":{"type":"git","url":"git://github.com/coolaj86/futures.git"},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.info"},"main":"join.js","directories":{"lib":"."},"dependencies":{"future":">= 2.1.1"},"engines":{"node":"*","ender":">= 0.5.0"},"_npmJsonOpts":{"file":"/Users/coolaj86/.npm/join/2.3.0/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"join@2.3.0","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"a8d26bb72abe506a5da0b42aa244a60d6a704699","tarball":"http://registry-npm.ywwl.com/join/download/join-2.3.0.tgz","integrity":"sha512-K6Fh6xPjx8LPEU/dWh/qfmYZXkSDKQ7x9ffmtg4UpJYCVZc04r27i1hYWJWefHnEV+2CHQY6p1icW54RU46osg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAST4Nkaa5mGIIjENG8nlUqg0NyMfsPr7sOq4TAjRewvAiApxmVGEBCGCqBz1xr6AbL75jSUFL1rVkBmqnUUVViJkA=="}],"size":1307,"noattachment":false,"key":"/join/-/join-2.3.0.tgz"},"scripts":{},"publish_time":1310750104511,"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"_cnpm_publish_time":1310750104511},"2.1.1":{"name":"join","version":"2.1.1","description":"The join / synchronize module of FuturesJS (Ender.JS and Node.JS)","homepage":"https://github.com/coolaj86/futures","keywords":["flow-control","async","asynchronous","futures","promises","deferreds","join","synchronize","util","browser"],"repository":{"type":"git","url":"git://github.com/coolaj86/futures.git"},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.info"},"main":"join.js","directories":{"lib":"."},"dependencies":{"future":">= 2.1.1"},"engines":{"node":"*","ender":">= 0.5.0"},"_npmJsonOpts":{"file":"/Users/coolaj86/.npm/join/2.1.1/package/package.json","wscript":false,"contributors":false,"serverjs":false},"_id":"join@2.1.1","devDependencies":{},"_engineSupported":true,"_npmVersion":"1.0.15","_nodeVersion":"v0.4.8","_defaultsLoaded":true,"dist":{"shasum":"95925e2097baba201f4930feca908894440130bb","tarball":"http://registry-npm.ywwl.com/join/download/join-2.1.1.tgz","integrity":"sha512-X4jAHKv4alO9EJP2rhbFOsiINX/CRna/OBmzstIf8b9v6BLVtXhAjO73fvih+/KsSXGrjqG9zzvSmM7w8uUhUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTYoS8JjcUkSpETmXDWDujpf94nZVcWD8yR1BbWmQqOAIgSx0ZA4XcTgxVH9pEnRS02C/i8eV9ZyiJPQd0aBMzdW4="}],"size":1275,"noattachment":false,"key":"/join/-/join-2.1.1.tgz"},"scripts":{},"publish_time":1310588501202,"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"_cnpm_publish_time":1310588501202}},"readme":"Join\n===\n\nJoins any number of asynchronous calls together -\nsimilar to how `pthread_join` works for C threads\nand `when()` works for Q-style promises.\n\nIt's basically a callback counter that lets you know when everything is done.\n\nInstallation\n---\n\nNode.JS (Server):\n\n```bash\nnpm install join\n```\n\nBrowser:\n\nYou can install from bower:\n\n```bash\nbower install join\n```\n\nOr download the raw file from \n<https://raw.github.com/FuturesJS/join/master/join.js>:\n\n```bash\nwget https://raw.github.com/FuturesJS/join/master/join.js\n```\n\nBrowser Usage\n---\n\n```html\n<script src=\"join.js\"></script>\n```\n\n```javascript\n;(function () {\n  'use strict';\n\n  var join = window.Join.create()\n    ;\n\n  // Use `join.add()` in place of a callback function\n  setTimeout(join.add(), 500, 'I', 'really');\n  setTimeout(join.add(), 700, 'really', 'LOVE');\n  setTimeout(join.add(), 200, 'JavaScript');\n\n  // Use `join.notify()` for incremental updates\n  join.notify(function (i, args) {\n    console.log(\n      'Callback #' + (i + 1) \n    + ' of ' + join.length \n    + ' completed', args\n    );\n  });\n\n  // Use `join.then(cb)` to fire `cb` when all of the `join.add()` callbacks have been called.\n  join.then(function (i, love, js) {\n    console.log('All of the timeouts have completed');\n    console.log(i, love, js);\n  });\n}());\n\n```\n\nNode.js Usage\n---\n\n```javascript\n'use strict';\n\nvar request = require('request')\n  , Join = require('join').Join\n  , join = Join.create()\n  ;\n\n// Use `join.add()` in place of a callback function\nrequest.get('https://www.google.com', join.add());\nrequest.get('http://www.yahoo.com', join.add());\nrequest.get('https://www.bing.com', join.add());\n\n// Use `join.notify()` for incremental updates\njoin.notify(function (i, args) {\n  console.log(\n    'Callback #' + (i + 1) \n  + ' of ' + join.length \n  + ' completed', args\n  );\n});\n\n// Use `join.then(cb)` to fire `cb` when all of the `join.add()` callbacks have been called.\njoin.then(function (googleArgs, yahooArgs, bingArgs) {\n  console.log('All of the requests have completed');\n  console.log(googleArgs[2]);\n  console.log(yahooArgs[2]);\n  console.log(bingArgs[2]);\n});\n```\n\nAPI\n---\n\nJoin\n\n  * `join = Join.create(defaultContext=null)` - create a Join that will count callbacks\n  * `join.add()` - creates a joinable callback that you can throw around\n  * `join.notify(progressCallback, context=null)`\n  * `join.then(finalCallback, context=null)`\n    * Fires `finalCallback` when all joined callbacks have completed\n    * Must be called after the last `add()`\n  * `join.length` - the number of times `join.add()` has been called\n\nPotential Gotchas\n---\n\n### Order matters\n\nThe arguments to `join.then(cb)` are in the order that the `join.add()` were called.\n\n```javascript\n  callbackA = join.add();\n  callbackB = join.add();\n\n  doAsyncStuff(callbackB);\n  doAsyncStuff(callbackA);\n\n  join.then(function (callbackAArgs, callbackBArgs) {\n    console.log(callbackAArgs, callbackBArgs);\n  });\n```\n\n### Callback within a callback\n\nIf you handle the join callback inside of another callback\nthen you'll need to place the join callback in the parent scope.\n\nFails:\n```javascript\n  request.get('http://www.yahoo.com', join.add());\n  setTimeout(function () {\n    request.get('https://www.bing.com', join.add());\n  }, 100);\n\n  join.then(function () {\n    console.log('all completed');\n  });\n```\n\n\nWorks as expected:\n```javascript\n  request.get('http://www.yahoo.com', join.add());\n  bingCallback = join.add()\n  setTimeout(function () {\n    request.get('https://www.bing.com', bingCallback);\n  }, 100);\n```\n\n### Losing `this`ness\n\nFails:\n```javascript\n  // `doStuff` loses the `this` binding to `myObject`\n  join.then(myObject.doStuff);\n```\n\nWorks as expected:\n```\n  // `doStuff` retains the `this` binding\n  join.then(myObject.doStuff, myObject);\n```\n\nAlso works as expected:\n```\n  // `doStuff` retains the `this` binding\n  join.then(function (argsA, argsB, argsC) {\n    myObject.doStuff(argsA, argsB, argsC);\n  });\n```\n","_attachments":{},"readmeFilename":"README.md","homepage":"https://github.com/FuturesJS/join","bugs":{"url":"https://github.com/FuturesJS/join/issues"}}