dtektor
A module to detect client side browser capabilities, heavily inspired in modernizr but with tests written as commonJS modules.
Important:
This is intended to be use with browserify, since it uses browserify transforms:
- shimixify
- require-globify
- babelify
Install
npm i --save dtektor
Usage
// hard way to use itvar dtektor = touch: fullscreen: // this is a custom test implemented in your app // dash separated keys will be transformed to // camelCase ones on the returned object 'another-test': ; // the keys that contain dashes// are converted to camelCase onesdtektoranotherTest // also the html element will have the classes:// - touch, if touch is supported or no-touch if not supported// - fullscreen, if fullscreen is supported or no-fullscreen if not supported// - another-test, if the custom test exports a boolean === true or// no-another-test if the exported value is false
Load all the tests included in this module
// for now only tests for fullscreen, hover-enabled and touch// ideally all the tests in the modernizr repo could be moved to commonjs// modules and can be imported here but this should be only done for dev purposes// TODO: Add more modernizr tests to the p/ folder (f stands for features)var dtektor = ;
Customize the tests
// In a real life app you should only load the tests you use// this can be achieved by doing://var dtektor = // this uses the transform require-globify // this will load only touch and fullscreen // other tests can be added as well when they // become available ; // or you can load your own testsvar dtektor = // this will expand your tests