https://github.com/vanruesc/feature-detector
A tool for detecting environment features.
https://github.com/vanruesc/feature-detector
browser capabilities environment feature-detection nodejs
Last synced: 8 months ago
JSON representation
A tool for detecting environment features.
- Host: GitHub
- URL: https://github.com/vanruesc/feature-detector
- Owner: vanruesc
- License: zlib
- Archived: true
- Created: 2017-05-20T16:27:19.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2018-08-30T21:44:39.000Z (almost 8 years ago)
- Last Synced: 2025-01-06T09:46:14.593Z (over 1 year ago)
- Topics: browser, capabilities, environment, feature-detection, nodejs
- Language: JavaScript
- Homepage:
- Size: 1.68 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# Feature Detector
[](https://travis-ci.org/vanruesc/feature-detector)
[](http://badge.fury.io/js/feature-detector)
[](https://david-dm.org/vanruesc/feature-detector)
An extensible tool for detecting environment features such as
[WebGL](https://developer.mozilla.org/en-US/docs/Web/API/WebGL_API) or
[Web Workers](https://developer.mozilla.org/en-US/docs/Web/API/Web_Workers_API).
*[API Reference](http://vanruesc.github.io/feature-detector/docs)*
## Installation
```sh
npm install feature-detector
```
## Usage
##### Basics
```javascript
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
```javascript
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;
}
}
```
```javascript
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.