# ng-http-estimate

> Automatic $http request time estimates

Latest version **0.6.0** (published 2015-06-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install ng-http-estimate
pnpm add ng-http-estimate
yarn add ng-http-estimate
bun add ng-http-estimate
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.6.0 |
| Published | 2015-06-02 |
| First published | 2015-04-27 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 10 |
| Author | Gleb Bahmutov |
| Maintainers | bahmutov |
| Keywords | angular, $http, http, request, time, estimate, estimation |

## Links

- npm: https://www.npmjs.com/package/ng-http-estimate
- Repository: https://github.com/bahmutov/ng-http-estimate
- Issues: https://github.com/bahmutov/ng-http-estimate/issues
- npm.io page: https://npm.io/package/ng-http-estimate

## Alternatives

- [@js-joda/timezone](https://npm.io/package/@js-joda/timezone.md) — 383.4K weekly downloads
- [chartjs-adapter-moment](https://npm.io/package/chartjs-adapter-moment.md) — 210.8K weekly downloads
- [strftime](https://npm.io/package/strftime.md) — 171.2K weekly downloads
- [vue-flatpickr-component](https://npm.io/package/vue-flatpickr-component.md) — 115.8K weekly downloads
- [timepicker](https://npm.io/package/timepicker.md) — 51.0K weekly downloads

## Recent versions

- 0.6.0 (latest) — 2015-06-02
- 0.5.3 — 2015-04-28
- 0.5.2 — 2015-04-28
- 0.5.0 — 2015-04-28
- 0.4.0 — 2015-04-28
- 0.3.0 — 2015-04-28
- 0.2.0 — 2015-04-28
- 0.1.0 — 2015-04-27

## README

# ng-http-estimate

> Automatic $http request time estimates

[Demo][demo], [basic example][basic], [custom estimator][estimator],
[reporting accuracy][accuracy], [low-level][low-level]

[demo]: http://glebbahmutov.com/ng-http-estimate/
[basic]: http://glebbahmutov.com/ng-http-estimate/examples/basic
[estimator]: http://glebbahmutov.com/ng-http-estimate/examples/custom-estimator
[accuracy]: http://glebbahmutov.com/ng-http-estimate/examples/accuracy
[low-level]: http://glebbahmutov.com/ng-http-estimate/examples/low-level

    npm|bower install ng-http-estimate

Include 'dist/ng-http-estimate.js' script in your page and add dependency on 'http-estimate'

    angular.module('app', ['http-estimate']);

Place the loading element into the body, you can also style it

    <body>
        <http-estimate></http-estimate>
        ...
    </body>

The element will appear automatically on HTML requests and will show estimated remaining
time (if previously computed) or "loading ..." message. Optionally, include 'dist/ng-http-estimate.css'
file to get the default centered style.

![screenshot](screenshot.png)

## Features

* Measurements are saved in the local storage.
* The $http requests are automatically intercepted. If you want to disable intercept and
control the start / stop events, use config provider

```js
.config(function (httpEstimateProvider) {
  httpEstimateProvider.set({
    interceptHttp: false
  });
})
```

* You can pass your own estimator function via config provider. The function can
use built-in estimator and should return the wait time in milliseconds. For example:

```js
.config(function (httpEstimateProvider) {
  httpEstimateProvider.set({
    estimator: function (cacheEstimator, url) {
      console.log('need to estimate how long get request to', url, 'would take');
      var estimate = cacheEstimator(url);
      console.log('built-in cache estimator says', estimate);
      console.log('will trust it');
      return estimate;
    }
  });
})
```

* You can pass 'accuracy' function via config provider to receive result after a request
completes. Useful to collect analytics how accurate the measurements were

```js
.config(function (httpEstimateProvider) {
  httpEstimateProvider.set({
    estimator: function (cacheEstimator, url) {
      ...
    },
    accuracy: function (url, estimate, took) {
      console.log('estimated request to', url, 'to take', estimate, 'took', took, 'ms');
    }
  });
})
```

* Low level interface. You can inject 'httpEstimateLowLevel' into your application and call
the low-level methods `start(name)` and `stop(name)`. Great for custom duration estimation with
http intercepts disabled.

```js
.controller('demoController', function ($scope, httpEstimateLowLevel) {
  $scope.startLoad = function startLoad() {
    httpEstimateLowLevel.start('/foo/bar');
  };
  $scope.stopLoad = function stopLoad() {
    httpEstimateLowLevel.stop('/foo/bar');
  };
});
```

* Verbose console log output for debugging.

```js
.config(function (httpEstimateProvider) {
  httpEstimateProvider.set({
    verbose: true
  });
})
```

* Works fine with other $http interceptors, like [angular-loading-bar][angular-loading-bar],
for example see the [accuracy example][accuracy].

[angular-loading-bar]: http://chieffancypants.github.io/angular-loading-bar/

## Small print

Author: Gleb Bahmutov &copy; 2015

* [@bahmutov](https://twitter.com/bahmutov)
* [glebbahmutov.com](http://glebbahmutov.com)
* [blog](http://glebbahmutov.com/blog)

License: MIT - do anything with the code, but don't blame me if it does not work.

Spread the word: tweet, star on github, etc.

Support: if you find any problems with this module, email / tweet /
[open issue](https://github.com/bahmutov/ng-http-esimate/issues) on Github

---
_Source: https://npm.io/package/ng-http-estimate · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
