• Stars
    star
    132
  • Rank 274,205 (Top 6 %)
  • Language
    TypeScript
  • License
    MIT License
  • Created over 7 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

๐ŸŒ simplify detecting your browser.

NPM

npm version npm Join the chat at https://gitter.im/KennethanCeyer/PIGNOSE GitHub stars License: MIT

Build Status Coverage Status codecov

CodeFactor Maintainability Test Coverage

๐Ÿ“ฆ Installation

npm

$ npm install browser-detect

yarn

$ yarn add browser-detect

๐Ÿ“ƒ Example

Web

<script src="node_modules/browser-detect/dist/browser-detect.umd.js"></script>
const result = browserDetect();
console.log(result);

output

{
    name: 'chrome',
    version: '58.0.3029',
    versionNumber: 58.03029,
    mobile: false,
    os: 'Windows NT 10.0'
}

Web with module

import browser from 'browser-detect';

const result = browser();
console.log(result);

output

{
    name: 'chrome',
    version: '58.0.3029',
    versionNumber: 58.03029,
    mobile: false,
    os: 'Windows NT 10.0'
}

NodeJS

Just simple :trollface:

const browser = require('browser-detect');
const result = browser();

console.log(result);

output

{
    name: 'node',
    version: '9.9.0',
    versionNumber: 9.9,
    mobile: false,
    os: 'win32'
}

NodeJS with Express

const router = express.Router();
const browser = require('browser-detect');

router.get('/', req => {
    const result = browser(req.headers['user-agent']);
    console.log(result);
});

return router;

output

{
    name: 'ie',
    version: '9.0',
    versionNumber: 9,
    mobile: false,
    os: 'Windows NT 10.0'
}

Or set a middleware and send to res.locals.

// browserDetectMiddleware.js
const browser = require('browser-detect');

const MiddleWare = () => req => {
    res.locals.browser = browser(req.headers['user-agent']);
    next();
};

module.exports = MiddleWare;
// app.js

const express = require('express');
const browserDetectMiddleware = require('./browserDetectMiddleware');

const app = express();
app.use(browserDetectMiddleware())

View will can access browser variable.

<!-- view.ejs -->

<%=JSON.stringify(browser)%>

output

"{ name: 'firefox', version: '53.0.0', versionNumber: 53, mobile: false, os: 'Windows NT 10.0' }"

๐Ÿ“ƒ Demo

Web

  • open examples/client.html by your browser.

NodeJS

  • open command or terminal
  • move directory to browser-detect path that you download
  • type following code
$ node ./examples/server.js

โšก Type

name type description example
name string a browser name ie, chrome, firefox
version string browser or node version 59.2.22
versionNumber number browser or node number casted to number 59.222
mobile boolean if browser is in mobile environment, it will be true true
os string os type name Windows NT 10.0

๐Ÿšฉ Roadmap

  • detect browser both compatible client and server
  • support AMD and CommonJS module feature
  • support typings
  • support guideline and documentations for contributors
  • support browser compatity to IE7
  • support to detect mobile and OS
  • support CI (TravisCI)
  • support unit tests
  • support e2e tests
  • suport cdn

๐Ÿ”Ž Compatibility

  • IE 7+
  • Chrome (Windows, MacOS)
  • Edge
  • Firefox
  • Safari (Windows, MacOS)
  • Opera
  • Android
  • Chromium Browsers (Will be named chrome)

:octocat: Contribution

environment

  1. clone project from Github
$ git clone [email protected]:KennethanCeyer/browser-detect.git
  1. install npm packages
$ cd browser-detect
$ npm install
  1. build sources
$ npm run build

test

$ npm run test

๐Ÿ’› Contributors

๐Ÿ”Ž License

FOSSA Status

More Repositories

1

tutorial-git

๐Ÿ“˜ ์–ด๋–ป๊ฒŒ ๊นƒ์„ ์‚ฌ์šฉํ•˜๋Š”์ง€ ๋น ๋ฅด๊ฒŒ ์•Œ์•„๋ด…์‹œ๋‹ค. (Quick learn How to use Git.)
314
star
2

pg-calendar

๐Ÿ“† beautiful and eidetic date picker
JavaScript
128
star
3

formulize

๐ŸŒ˜ formula ui generator
TypeScript
93
star
4

awesome-llm

Awesome series for Large Language Model(LLM)s
63
star
5

metric-parser

๐Ÿ“œ AST-based advanced mathematical parser written by Typescript.
TypeScript
32
star
6

awesome-llmops

Awesome series for LLMOps
32
star
7

hypermodel

๐Ÿ‘พ related model builder library
JavaScript
27
star
8

awesome-data-pipeline

Awesome list for datapipeline
23
star
9

learn-golang-kr

๐Ÿ“– golang korean translation project(golang ํ•œ๊ตญ์–ด ๋ฒˆ์—ญ ํ”„๋กœ์ ํŠธ)
17
star
10

up

Experimental: Thread-friendly interpreter programming language
Go
14
star
11

parallax-slider

๐ŸŒ awesome parallax slider
JavaScript
14
star
12

pg-gallery

๐ŸŽจ PIGNOSE Gallery is so simple and fast gallery style component.
JavaScript
12
star
13

awesome-numpy

Awesome list of NumPy
11
star
14

llm-diy-kit

Python
8
star
15

pg-tab

โœจ web accessibility be supported a responsible tab plugin.
HTML
5
star
16

pg-popup

๐ŸŒŒ PIGNOSE Popup is simple flat design modal plugin.
HTML
4
star
17

awesome-cafe

Awesome list of cafe for developers
4
star
18

gowap

๐Ÿ”’ ssh key manager written in go
Go
4
star
19

gdg-devfest-seoul-frontend-frameworks

๐Ÿ“ฆ GDG DevFest Seoul 2017 ํ”„๋ก ํŠธ์—”๋“œ ๋ชจ๋˜ ํ”„๋ ˆ์ž„์›Œํฌ ๋‚ฑ๋‚ฑํžˆ ํŒŒํ—ค์น˜๊ธฐ ์„ธ์…˜์˜ 3๊ฐ€์ง€ ํ”„๋ ˆ์ž„์›Œํฌ ๋ณ„ ์ฝ”๋“œ๋น„๊ต๋ฅผ ์œ„ํ•œ ๋ฆฌํฌ์ง€ํ† ๋ฆฌ์ž…๋‹ˆ๋‹ค.
JavaScript
4
star
20

fastcampus-mlops

Python
4
star
21

pycon-kr-2018

๐Ÿ“ฆ gracefully testing and refactoring
Python
3
star
22

resume

๐Ÿ“‹ a personal resume
3
star
23

vscode-io-extension

๐ŸŽ‰ io language syntax highlighting as vscode extension
3
star
24

pycon-kr-2017

๐Ÿ“ฆ reactive programming with RxPy (PyCon Korea 2017).
Python
3
star
25

ast

๐Ÿ”‰ Advanced sound tool written in Golang
Go
3
star
26

awesome-audio-speech

Awesome list of Audio, Speech, and DSP(Digital signal processing)
3
star
27

battle-net-chatting

๐Ÿ’ฌ Warcraft III Battle Net v1.0 Chatting Program for Windows.
C#
2
star
28

hiss

๐Ÿ python database migration tool based on git's design
Python
2
star
29

sparrow

๐Ÿฆ Golang env based configure management module which is supported yaml, toml, json
Go
2
star
30

danger-go

๐Ÿ’Ž A Dangerfile for golang developer (golint)
Ruby
2
star
31

hashids-io

๐Ÿ‘ป the implementation of hashids for io lang.
Io
2
star
32

bire

๐Ÿ‘ท Initial environment automated management tool by cli-interface
1
star
33

git-bot

Commandable git cli based on GPT-3
1
star
34

sally

๐ŸŒŒ automated install dataset for object detection as yolo, vision
Python
1
star
35

OKR

๐Ÿ˜Ž Personal OKR for improving self
1
star
36

dup

๐Ÿ“ A duplicated issue and PR checking tool
Vue
1
star
37

angular-benchmark

๐Ÿ“ˆ the performance between angular 1x, 2x and reactjs.
JavaScript
1
star
38

items

๐Ÿ”ง Rust cli tool which selectable prompt based on user interaction.
Rust
1
star
39

fastcampus-mlops-testing

Python
1
star