feature-detector

0.1.5 • Public • Published

Feature Detector

Build status npm version Dependencies

An extensible tool for detecting environment features such as WebGL or Web Workers.

API Reference

Installation

npm install feature-detector

Usage

Basics
import { Detector, FeatureId } from "feature-detector";
 
const detector = new Detector();
const feature = detector.get(FeatureId.WEBGL);
 
console.log(feature.supported);
console.log(detector.getMessage(feature));
Custom Features
import { Feature } from "feature-detector";
 
export class MyFeature extends Feature {
 
    constructor() {
 
        super();
 
        this.name = "My Feature";
 
        // Check if your feature is supported in this environment.
        // Note that this.root serves as a reference to the global scope.
        this.supported = true || false;
 
    }
 
}
import { Detector } from "feature-detector";
import { MyFeature } from "./MyFeature.js";
 
const detector = new Detector();
const MY_ID = "my-feature";
 
detector.set(MY_ID, new MyFeature());

Contributing

Maintain the existing coding style. Add unit tests for any new or changed functionality. Lint and test your code.

Package Sidebar

Install

npm i feature-detector

Weekly Downloads

1

Version

0.1.5

License

Zlib

Last publish

Collaborators

  • vanruesc