Git Product home page Git Product logo

Comments (5)

jasonkarns avatar jasonkarns commented on July 26, 2024

Agreed. We use _detect within a wrapper so that we can run our tests in node. But we'd also like to use bowser full-force in node.

Would a PR be accepted that changes the api to accept a UA string and only defaults to using the navigator?

from bowser.

lancedikson avatar lancedikson commented on July 26, 2024

Sorry, guys, but I haven't got what you want to do with the API. Could you give me more details?

from bowser.

jasonkarns avatar jasonkarns commented on July 26, 2024

Personally, I would love to see something like how substack's cookie-cutter handles it's document.cookie.

https://github.com/substack/cookie-cutter/blob/master/index.js#L1-L4

The module exports a function that, if given a string uses the string as document.cookie. If given an object, it treats the object as document (and thus expects it to have a cookie property; defaulting cookie to "" if it doesn't). If it's given a falsey value (undefined being the only falsey value we really care about), it defaults to checking the global document. If global document doesn't exist, it falls back to {cookie:""} as the document.

For bowser, I would expect to see:

browser = require('bowser');

// defaults to document.navigator
browser()

// uses provided document.navigator object
browser({navigator: { userAgent: "foo"} })

// uses provided string as the ua string
browser("Mozilla/5.0 (Linux; Android 5.1.1; Nexus 9 Build/LMY48T) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/47.0.2526.83 Safari/537.36")

from bowser.

lancedikson avatar lancedikson commented on July 26, 2024

Interesting point. I think this is a good issue for the next major release 👍 It would be nice if you want to help with it by PR. If you do, please, checkout develop branch and send the PR.

from bowser.

lancedikson avatar lancedikson commented on July 26, 2024

API of the new version will be much better. The release is very soon. You can track activity in the branch named v2.

from bowser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.