{"jam":{"main":"src/trier.js"},"bugs":{"url":"https://github.com/philbooth/trier.js/issues"},"dist":{"shasum":"58b67b23955429f3e3e01b6e5fef677bcd929964","tarball":"https://registry.npmjs.org/trier/-/trier-0.1.0.tgz","integrity":"sha512-EUJfldF/hrGR+OjS+xnsC6d1n3qx4WZ5le6h3VhFzE3n/CSuQgmM5ca5Z0ibiMwmyXgt2v/pVoi5KOHhmJo3Gg==","signatures":[{"sig":"MEUCIBT0pCqB0bT/ysFVEHspn2Ku97BeOFYCgypDzzN7JHGWAiEAzjw2qRMPe8cYjiJL+WyrpTWTKbNEmNe1wojurH1azE8=","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"./src/trier","name":"trier","_from":".","ender":"noop","author":{"name":"Phil Booth","email":"pmbooth@gmail.com"},"readme":"# trier.js\n\n[![Build status][ci-image]][ci-status]\n\nBecause everyone loves a trier!\nConditional\nand repeated\ntask invocation\nfor node\nand browser.\n\n## License\n\n[MIT][license]\n\n## Installation\n\n### Via NPM\n\n```\nnpm install trier\n```\n\n### Via Jam\n\n```\njam install trier\n```\n\n### Via Git\n\n```\ngit clone git@github.com:philbooth/trier.js.git\n```\n\n## Usage\n\n### Loading the library\n\nBoth\nCommonJS\n(e.g.\nif you're running on [Node.js][node]\nor if you're in the browser with [Browserify])\nand AMD\n(e.g. if you're using [Require.js][require])\nloading styles are supported.\nIf neither system is detected,\nthe library defaults to\nexporting it's interface globally\nas `trier`.\n\n### Calling the library\n\ntrier.js exports two public functions,\n`when` and `until`.\n\n#### trier.when (options)\n\nPerforms some action\nwhen prerequesite conditions\nare met.\n\nAccepts a single options object,\nwhich supports the following properties:\n\n* `predicate`: Callback function used to test precondition.\n  Should return `false` to postpone `action` or `true` to perform it.\n  Defaults to nop.\n* `action`: The function you want to call. Defaults to nop.\n* `fail`: Callback function to be invoked if `limit` tries are reached.\n  Defaults to nop.\n* `context`: Context object used when applying `predicate`, `action` and `fail`.\n  Defaults to `{}`.\n* `args`: Arguments array used when applying `predicate`, `action` and `fail`.\n  Defaults to `[]`.\n* `interval`: Retry interval in milliseconds.\n  Use negative numbers to indicate that subsequent retries should wait for twice the preceding interval\n  (i.e. exponential waits).\n  Defaults to -1000.\n* `limit`: Maximum retry count, at which point the call fails and retry iterations cease.\n  Use a negative number to indicate that call should continue indefinitely\n  (i.e. never fail).\n  Defaults to -1.\n\nExample:\n```javascript\ntrier.when({\n    predicate: function () {\n        return db.isConnected;\n    },\n    action: function () {\n        db.insert(user);\n    },\n    fail: function () {\n        log.error('No database connection, terminating.');\n        process.exit(1);\n    },\n    pass: function () {\n        next();\n    },\n    interval: 1000,\n    limit: 10\n});\n```\n\n#### trier.until (options)\n\nPerforms some action repeatedly\nuntil postrequisite conditions\nare met.\n\nAccepts a single options object,\nwhich supports the following properties:\n\n* `predicate`: Callback function used to test postcondition.\n  Should return `false` to retry `action` or `true` to stop it.\n  Defaults to nop.\n* `action`: The function you want to call. Defaults to nop.\n* `fail`: Callback function to be invoked if `limit` tries are reached.\n  Defaults to nop.\n* `context`: Context object used when applying `predicate`, `action` and `fail`.\n  Defaults to `{}`.\n* `args`: Arguments array used when applying `predicate`, `action` and `fail`.\n  Defaults to `[]`.\n* `interval`: Retry interval in milliseconds.\n  Use negative numbers to indicate that subsequent retries should wait for twice the preceding interval\n  (i.e. exponential waits).\n  Defaults to -1000.\n* `limit`: Maximum retry count, at which point the call fails and retry iterations cease.\n  Use a negative number to indicate that call should continue indefinitely\n  (i.e. never fail).\n  Defaults to -1.\n\nExample:\n```javascript\nvar sent = false\ntrier.until({\n    predicate: function () {\n        return sent;\n    },\n    action: function () {\n        smtp.send(email, function (error) {\n            if (!error) {\n                sent = true;\n            }\n        });\n    },\n    pass: function () {\n        next();\n    },\n    interval: -1000,\n    limit: -1\n});\n```\n\n## Development\n\n### Dependencies\n\nThe build environment relies on\nNode.js,\n[NPM],\n[JSHint],\n[Mocha],\n[Chai] and\n[UglifyJS].\nAssuming that you already have Node.js and NPM set up,\nyou just need to run `npm install`\nto install all of the dependencies as listed in `package.json`.\n\n### Unit tests\n\nThe unit tests are in `test/trier.js`.\nYou can run them with the command `npm test` or `jake test`.\nTo run the tests in a web browser,\nopen `test/trier.html`.\n\n[ci-image]: https://secure.travis-ci.org/philbooth/trier.js.png?branch=master\n[ci-status]: http://travis-ci.org/#!/philbooth/trier.js\n[license]: https://github.com/philbooth/trier.js/blob/master/COPYING\n[node]: http://nodejs.org/\n[browserify]: http://browserify.org/\n[require]: http://requirejs.org/\n[npm]: https://npmjs.org/\n[jshint]: https://github.com/jshint/node-jshint\n[mocha]: http://visionmedia.github.com/mocha\n[chai]: http://chaijs.com/\n[uglifyjs]: https://github.com/mishoo/UglifyJS\n\n","license":"MIT","scripts":{"lint":"./node_modules/.bin/jshint ./src/trier.js --config config/jshint.json","test":"./node_modules/.bin/mocha --ui tdd --reporter spec --colors ./test/trier.js","minify":"./node_modules/.bin/uglifyjs ./src/trier.js --compress --mangle --output ./lib/trier.min.js"},"_npmUser":{"name":"philbooth","email":"pmbooth@gmail.com"},"keywords":["repeat","retry","predicate","conditional","invocation","ender"],"deprecated":"Alas, trier is dead. Rest in peace, trier. But worry not! A phoenix rises from the flames; perhaps you should look at `tryer` instead!","repository":{"url":"https://github.com/philbooth/trier.js","type":"git"},"_npmVersion":"1.3.8","description":"Because everyone loves a trier! Conditional and repeated task invocation for node and browser.","maintainers":[{"name":"philbooth","email":"pmbooth@gmail.com"}],"contributors":[{"name":"Phil Booth","email":"pmbooth@gmail.com"}],"readmeFilename":"README.md","devDependencies":{"chai":"1.7.x","mocha":"1.13.x","jshint":"2.1.x","uglify-js":"2.4.x"},"_id":"trier@0.1.0","version":"0.1.0"}