feature-detector
v0.1.5
Published
A tool for detecting environment features.
Downloads
2
Maintainers
Readme
Feature Detector
An extensible tool for detecting environment features such as WebGL or Web Workers.
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.