1.1.0 • Published 5 years ago

node-webp-detect v1.1.0

Weekly downloads
3
License
ISC
Repository
github
Last release
5 years ago

Node Webp Detect

This package will detect if the client browser supports webp images. It can work with the express request object or with the user agent string.

Install

npm install node-webp-detect

Usage

const webpDetect = require('node-webp-detect');

const result = webpDetect('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36');

console.log(result);

Output:

{
    "name": "chrome",
    "version": "70.0.3538",
    "versionNumber": 70.03538,
    "mobile": false,
    "os": "OS X 10.14.2",
    "webpSupport": true
}

Or wirh express

const webpDetect = require('node-webp-detect');
const app = require('express')();

app.use((req, res, next) => {
    req.browserDetails = webpDetect(req);
    next();
});

app.get('/path', (req, res) => {
    console.log(req.browserDetails);
})

Output:

{
    "name": "chrome",
    "version": "70.0.3538",
    "versionNumber": 70.03538,
    "mobile": false,
    "os": "OS X 10.14.2",
    "webpSupport": true
}
1.1.0

5 years ago

1.0.0

5 years ago

0.0.1

5 years ago