# tryer [![Build status](https://gitlab.com/philbooth/tryer/badges/master/pipeline.svg)](https://gitlab.com/philbooth/tryer/pipelines) [![Package status](https://img.shields.io/npm/v/tryer.svg)](https://www.npmjs.com/package/tryer) [![Downloads](https://img.shields.io/npm/dm/tryer.svg)](https://www.npmjs.com/package/tryer) [![License](https://img.shields.io/npm/l/tryer.svg)](https://opensource.org/licenses/MIT) Because everyone loves a tryer! Conditional and repeated function invocation for node and browser. * [Say what?](#say-what) * [What size is it?](#what-size-is-it) * [How do I install it?](#how-do-i-install-it) * [How do I use it?](#how-do-i-use-it) * [Loading the library](#loading-the-library) * [Calling the exported function](#calling-the-exported-function) * [Examples](#examples) * [How do I set up the dev environment?](#how-do-i-set-up-the-dev-environment) * [What license is it released under?](#what-license-is-it-released-under) ## Say what? Sometimes, you want to defer calling a function until a certain pre-requisite condition is met. Other times, you want to call a function repeatedly until some post-requisite condition is satisfied. Occasionally, you might even want to do both for the same function. To save you writing explicit conditions and loops on each of those occasions, `tryer` implements a predicate-based approach that hides the cruft behind a simple, functional interface. Additionally, it allows you to easily specify retry intervals and limits, so that your code doesn't hog the CPU. It also supports exponential backoff of retry intervals, which can be useful when handling indefinite error states such as network failure. ## What size is it? 5.6 kb unminified with comments, 1.1 kb minified, 0.5 kb minified + gzipped. ## How do I install it? Via npm: ``` npm i tryer --save ``` Or if you just want the git repo: ``` git clone git@gitlab.com:philbooth/tryer.git ``` ## How do I use it? ### Loading the library If you are running in Node.js or another CommonJS-style environment, you can `require` tryer like so: ```javascript const tryer = require('tryer'); ``` It also the supports the AMD-style format preferred by Require.js. If you are including `tryer` with an HTML `