{"_id":"join","_rev":"22-f745cb063f69510c05d00513505e73bb","name":"join","description":"The join / synchronize module of FuturesJS (Browser, Node.js, Bower, and Pakmanager)","dist-tags":{"latest":"3.0.0"},"versions":{"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":"https://registry.npmjs.org/join/-/join-2.1.1.tgz","integrity":"sha512-X4jAHKv4alO9EJP2rhbFOsiINX/CRna/OBmzstIf8b9v6BLVtXhAjO73fvih+/KsSXGrjqG9zzvSmM7w8uUhUw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQDTYoS8JjcUkSpETmXDWDujpf94nZVcWD8yR1BbWmQqOAIgSx0ZA4XcTgxVH9pEnRS02C/i8eV9ZyiJPQd0aBMzdW4="}]},"scripts":{}},"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":"https://registry.npmjs.org/join/-/join-2.3.0.tgz","integrity":"sha512-K6Fh6xPjx8LPEU/dWh/qfmYZXkSDKQ7x9ffmtg4UpJYCVZc04r27i1hYWJWefHnEV+2CHQY6p1icW54RU46osg==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIAST4Nkaa5mGIIjENG8nlUqg0NyMfsPr7sOq4TAjRewvAiApxmVGEBCGCqBz1xr6AbL75jSUFL1rVkBmqnUUVViJkA=="}]},"scripts":{}},"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":"https://registry.npmjs.org/join/-/join-2.3.1.tgz","integrity":"sha512-SC4t+SjKyyvCgY1Xsi25UeDo972KSokDT7ggwP15PDknNzSkaFiqNpUY39LuXREG0I3l8wlbPM3rNz7/swWu2w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIDwV/IO24eFIphtgMJgqGVAgeB3fTXi7W6QnoLCaaxFGAiAr4NeK29nhgtiK9le4yfYdqLxjKK1Ajnwjl7h9JPb+tg=="}]},"readme":"Join\n===\n\nJoins asynchronous calls together similar to how `pthread_join` works for threads.\n\nInstallation\n---\n\nNode.JS (Server):\n\n    npm install join\n\nEnder.JS (Browser):\n\n    ender build join\n\nStandalone Usage\n---\n\n    var Join = require('join')\n      , join = Join.create()\n      , callbackA = join.add()\n      , callbackB = join.add()\n      , callbackC = join.add()\n      ;\n\n    function abcComplete(aArgs, bArgs, cArgs) {\n      console.log(aArgs[1] + bArgs[1] + cArgs[1]);\n    }\n\n    setTimeout(function () {\n      callbackA(null, 'Hello');\n    }, 300);\n\n    setTimeout(function () {\n      callbackB(null, 'World');\n    }, 500);\n\n    setTimeout(function () {\n      callbackC(null, '!');\n    }, 400);\n\n\n    // this must be called after all \n    join.when(abcComplete);\n\nUsage with Futures\n---\n\n    var Future = require('futures')\n      , join = require('join').create()\n      , fArray = [\n            Future.create()\n          , Future.create()\n          , Future.create()\n        ]\n      , e\n      ;\n\n    setTimeout(function () { fArr[1].deliver(e, \"World\"); }, 100);\n    setTimeout(function () { fArr[0].deliver(e, \"Hi\"); }, 300);\n    setTimeout(function () { fArr[0].deliver(e, \"Hello\"); }, 500);\n    setTimeout(function () { fArr[2].deliver(e, \"!\", \"!\"); }, 700);\n\n    // * join.add() -- creates a callback that you can pass in to another function\n    //\n    //    $.get('/xyz.json', join.add());\n\n    // * join.add(<future>) -- adds a single future\n    //\n    //    var f1 = Future.create()\n    //      , f2 = Future.create()\n    //      ;\n    //    join.add(f1, f2); // or join.add(f1).add(f2);\n\n    // * join.add([<future>, ...]) -- adds an array of futures\n    //\n    //   join.add(fArr);\n\n    join.add(fArr);\n    join.when(function (f0Args, f1Args, f2Args) {\n      console.log(f1Args[1], f2Args[1], f3Args[1], f2Args[2]);\n    });\n\nAPI\n---\n\nCreates a Future-ish object for the purpose of synchronizing other Futures.\n\n**Core**\n\n  * `join = Join.create(globalContext=null)` - create a Future and modifies it\n  * `join.add()` - creates a joinable callback that you can throw around\n  * `join.add(future0, future1, ...)` - add one or more `Future`s which to join\n  * `join.add([future0, future2, ...])` - add an array of `Future`s\n  * `join.when(finalCallback)`\n    * Fires `finalCallback` when all joined callbacks have completed\n    * Must be called after the last `add()`\n    * See `Future#when`\n  * `join.whenever(eventCallback)`\n    * Fires `eventCallback` each time all callbacks have completed at least once\n    * Must be called after the last `add()`\n    * see `Future#whenever`\n  * `join.isJoin` - a best-effort guess as to whether or not an object is a Join\n\n**Inherited-ish**\n\n  * `when` - see `Future#when`\n  * `whenever` - see `Future#whenever`\n\nNote: All `add(future)`s must be done before calling `when` or `whenever` on the join object.\n","maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}]},"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"},"readme":"Join\n===\n\nJoins asynchronous calls together similar to how `pthread_join` works for threads.\n\nInstallation\n---\n\nNode.JS (Server):\n\n    npm install join\n\nEnder.JS (Browser):\n\n    ender build join\n\nStandalone Usage\n---\n\n    var Join = require('join')\n      , join = Join.create()\n      , callbackA = join.add()\n      , callbackB = join.add()\n      , callbackC = join.add()\n      ;\n\n    function abcComplete(aArgs, bArgs, cArgs) {\n      console.log(aArgs[1] + bArgs[1] + cArgs[1]);\n    }\n\n    setTimeout(function () {\n      callbackA(null, 'Hello');\n    }, 300);\n\n    setTimeout(function () {\n      callbackB(null, 'World');\n    }, 500);\n\n    setTimeout(function () {\n      callbackC(null, '!');\n    }, 400);\n\n\n    // this must be called after all \n    join.when(abcComplete);\n\nUsage with Futures\n---\n\n    var Future = require('futures')\n      , join = require('join').create()\n      , fArray = [\n            Future.create()\n          , Future.create()\n          , Future.create()\n        ]\n      , e\n      ;\n\n    setTimeout(function () { fArr[1].deliver(e, \"World\"); }, 100);\n    setTimeout(function () { fArr[0].deliver(e, \"Hi\"); }, 300);\n    setTimeout(function () { fArr[0].deliver(e, \"Hello\"); }, 500);\n    setTimeout(function () { fArr[2].deliver(e, \"!\", \"!\"); }, 700);\n\n    // * join.add() -- creates a callback that you can pass in to another function\n    //\n    //    $.get('/xyz.json', join.add());\n\n    // * join.add(<future>) -- adds a single future\n    //\n    //    var f1 = Future.create()\n    //      , f2 = Future.create()\n    //      ;\n    //    join.add(f1, f2); // or join.add(f1).add(f2);\n\n    // * join.add([<future>, ...]) -- adds an array of futures\n    //\n    //   join.add(fArr);\n\n    join.add(fArr);\n    join.when(function (f0Args, f1Args, f2Args) {\n      console.log(f1Args[1], f2Args[1], f3Args[1], f2Args[2]);\n    });\n\nAPI\n---\n\nCreates a Future-ish object for the purpose of synchronizing other Futures.\n\n**Core**\n\n  * `join = Join.create(globalContext=null)` - create a Future and modifies it\n  * `join.add()` - creates a joinable callback that you can throw around\n  * `join.add(future0, future1, ...)` - add one or more `Future`s which to join\n  * `join.add([future0, future2, ...])` - add an array of `Future`s\n  * `join.when(finalCallback)`\n    * Fires `finalCallback` when all joined callbacks have completed\n    * Must be called after the last `add()`\n    * See `Future#when`\n  * `join.whenever(eventCallback)`\n    * Fires `eventCallback` each time all callbacks have completed at least once\n    * Must be called after the last `add()`\n    * see `Future#whenever`\n  * `join.isJoin` - a best-effort guess as to whether or not an object is a Join\n\n**Inherited-ish**\n\n  * `when` - see `Future#when`\n  * `whenever` - see `Future#whenever`\n\nNote: All `add(future)`s must be done before calling `when` or `whenever` on the join object.\n","readmeFilename":"README.md","bugs":{"url":"https://github.com/coolaj86/futures/issues"},"_id":"join@2.3.2","dist":{"shasum":"53a5268e86be891904ca2bae5acf0b544b4714a9","tarball":"https://registry.npmjs.org/join/-/join-2.3.2.tgz","integrity":"sha512-WiwswTAJWq4jeEqhey0lwEhKgVs5AojC2D9zLAFkVPc+VAu3w8n74MG1AKk8xpNcN67FRQrbQuuEl33mmuhNzw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCDGyq6KTWYb2UOTVuiVtgNBiOMIrD8Yy/tvz7EdWQJbgIgaOOPl7qjyDU76qVBsQINaN9zHD3efB+d2HQCEtIFzuU="}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}]},"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":{},"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","readmeFilename":"README.md","bugs":{"url":"https://github.com/FuturesJS/join/issues"},"_id":"join@3.0.0","dist":{"shasum":"cfb841db7b0a1dff132a07a582dbc06c21649713","tarball":"https://registry.npmjs.org/join/-/join-3.0.0.tgz","integrity":"sha512-RtCMVccL9rDfwqgQHpRx8ewxRDPkN2eoPbElrBJYMZIt0pTW2x8p2km4svpFmLb/sOPPRfD+ZwlJwYmONVVZzA==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDD94CRDQMqH7c65qXRj0dsyHy9b1SpDehxbtxqxEq84AIhAJ++lkDRvLHpBJ3+373VNgmUmXkhkAh7uFAiimbi5sgj"}]},"_from":"./","_npmVersion":"1.3.11","_npmUser":{"name":"coolaj86","email":"coolaj86@gmail.com"},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}]}},"maintainers":[{"name":"coolaj86","email":"coolaj86@gmail.com"}],"time":{"modified":"2022-06-19T04:43:17.791Z","created":"2011-07-13T20:21:40.830Z","2.1.1":"2011-07-13T20:21:41.202Z","2.3.0":"2011-07-15T17:15:04.511Z","2.3.1":"2012-05-31T15:34:48.411Z","3.0.0":"2014-01-13T23:09:10.156Z","2.3.2":"2014-01-13T18:17:32.200Z"},"author":{"name":"AJ ONeal","email":"coolaj86@gmail.com","url":"http://coolaj86.com"},"repository":{"type":"git","url":"git://github.com/FuturesJS/join.git"},"users":{"jasoncmcg":true}}