# javascript-retina-detect

[![NPM Version][npm-badge]][npm]
[![Build Status][travis-badge]][travis]
[![Test Coverage][coveralls-badge]][coveralls]

Detects device screen pixel ratio programmatically (through javascript). Using this tool one can decide whether to fetch retina images or save bandwidth (and power) and fetch normal resolution images.

## Installation

```
npm install javascript-retina-detect --save
```

## Usage

```js
import { device_pixel_ratio } from 'javascript-retina-detect'

device_pixel_ratio()
// `1` for normal screens
// `2` for retina@2x
// `3` for retina@3x
// …
```

## Contributing

After cloning this repo, ensure dependencies are installed by running:

```sh
npm install
```

This module is written in ES6 and uses [Babel](http://babeljs.io/) for ES5
transpilation. Widely consumable JavaScript can be produced by running:

```sh
npm run build
```

Once `npm run build` has run, you may `import` or `require()` directly from
node.

After developing, the full test suite can be evaluated by running:

```sh
npm test
```

While actively developing, one can use (personally I don't use it)

```sh
npm run watch
```

in a terminal. This will watch the file system and run tests automatically 
whenever you save a js file.

When you're ready to test your new functionality on a real project, you can run

```sh
npm pack
```

It will `build`, `test` and then create a `.tgz` archive which you can then install in your project folder

```sh
npm install [module name with version].tar.gz
```

## License

[MIT](LICENSE)
[npm]: https://www.npmjs.org/package/javascript-retina-detect
[npm-badge]: https://img.shields.io/npm/v/javascript-retina-detect.svg?style=flat-square
[travis]: https://travis-ci.org/halt-hammerzeit/javascript-retina-detect
[travis-badge]: https://img.shields.io/travis/halt-hammerzeit/javascript-retina-detect/master.svg?style=flat-square
[coveralls]: https://coveralls.io/r/halt-hammerzeit/javascript-retina-detect?branch=master
[coveralls-badge]: https://img.shields.io/coveralls/halt-hammerzeit/javascript-retina-detect/master.svg?style=flat-square
