0.1.4 • Published 8 years ago

javascript-retina-detect v0.1.4

Weekly downloads
28
License
MIT
Repository
github
Last release
8 years ago

javascript-retina-detect

NPM Version Build Status Test Coverage

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

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:

npm install

This module is written in ES6 and uses Babel for ES5 transpilation. Widely consumable JavaScript can be produced by running:

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:

npm test

While actively developing, one can use (personally I don't use it)

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

npm pack

It will build, test and then create a .tgz archive which you can then install in your project folder

npm install [module name with version].tar.gz

License

MIT