safe-feature-detect

0.0.1 • Public • Published

🕵️ safe-feature-detect

A lightweight and extendable feature detection library heavily inspired by the great Feature.js. Like Feature.js, this library stays under 1kb minified & gzipped. In addition, safe-feature-detect caches detections and will not throw an error if for some reason it's called during server side rendering.

Installation

npm install safe-feature-detect

Usage

  const { features, addFeature } = require('safe-feature-detect');

  features.matchMedia()
  features.deviceMotion()
  features.deviceOrientation()
  features.historyAPI()
  features.serviceWorker()
  features.touch()
  features.async()
  features.defer()
  features.fetch()
  features.srcset()
  features.sizes()
  features.HTMLPictureElement()
  features.webworkers()
  features.intl()
  features.fileReader()
  features.flex()
  features.sticky()

  addFeature('localStorage', () => {
    try {
      window.localStorage.setItem('test', 'foo');
      window.localStorage.removeItem('test');
      return true;
    } catch () {
      return false;
    }
  });

Readme

Keywords

none

Package Sidebar

Install

npm i safe-feature-detect

Weekly Downloads

1

Version

0.0.1

License

MIT

Unpacked Size

7.44 kB

Total Files

7

Last publish

Collaborators

  • ryhinchey