npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@getstation/fetch-favicon

v0.0.4-rc.2

Published

Fetch a great looking favicon from a website

Downloads

72

Readme

fetch-favicon

Circle CI Dependency Status devDependency Status js-standard-style semantic-release npm version

Favicons can be difficult. They come in several different formats, no page seems to have them all, and it is hard to know which one to use when you want the best. fetch-favicon takes the complexity out by finding them all and choosing the best for you.

Installation

npm install @meltwater/fetch-favicon --save

Using fetch-favicon

getFavicon(url, [size])

// using an ES6 transpiler, like babel
import fetchFavicon from '@meltwater/fetch-favicon'

// not using an ES6 transpiler
var fetchFavicon = require('@meltwater/fetch-favicon').fetchFavicon

fetchFavicon('https://www.github.com')

/*
'https://github.com/apple-touch-icon.png'
*/

Arguments

  • url: the address of the web page to be searched for favicons

  • size: (optional) an integer that represents a prefered minimum width/height of the favicon. If none of the retrieved favicons meet this constraint or the size information is not available, fetch-favicon will still return a favicon.

  • returns: the address of a favicons. If no favicons are found it will return the address of the favicon.ico off of the root (i.e. https://www.github.com/favicon.ico)

getFavicons(url, [size])

// using an ES6 transpiler, like babel
import { fetchFavicons } from '@meltwater/fetch-favicon'

// not using an ES6 transpiler
var fetchFavicons = require('@meltwater/fetch-favicon').fetchFavicons

fetchFavicons('https://www.github.com')

/*
[
  {"href":"http://github.com/apple-touch-icon.png","name":"apple-touch-icon"},
  {"href":"http://github.com/apple-touch-icon-57x57.png","name":"apple-touch-icon","size":57,"active":true},
  {"href":"http://github.com/apple-touch-icon-60x60.png","name":"apple-touch-icon","size":60},
  {"href":"http://github.com/apple-touch-icon-72x72.png","name":"apple-touch-icon","size":72},
  {"href":"http://github.com/apple-touch-icon-76x76.png","name":"apple-touch-icon","size":76},
  {"href":"http://github.com/apple-touch-icon-114x114.png","name":"apple-touch-icon","size":114},
  {"href":"http://github.com/apple-touch-icon-120x120.png","name":"apple-touch-icon","size":120},
  {"href":"http://github.com/apple-touch-icon-144x144.png","name":"apple-touch-icon","size":144},
  {"href":"http://github.com/apple-touch-icon-152x152.png","name":"apple-touch-icon","size":152},
  {"href":"http://github.com/apple-touch-icon-180x180.png","name":"apple-touch-icon","size":180},
  {"href":"https://assets-cdn.github.com/images/modules/open_graph/github-logo.png","name":"og:image"},
  {"href":"https://assets-cdn.github.com/images/modules/open_graph/github-mark.png","name":"og:image"},
  {"href":"https://assets-cdn.github.com/images/modules/open_graph/github-octocat.png","name":"og:image"},
  {"href":"/windows-tile.png","name":"msapplication-TileImage"},
  {"href":"https://assets-cdn.github.com/favicon.ico","name":"icon"},
  {"href":"http://github.com/favicon.ico","name":"favicon.ico"}
]
*/

Arguments

  • url: the address of the web page to be searched for favicons

  • size: (optional) an integer that represents a prefered minimum width/height of the favicon.

  • returns: an array of all the favicons found on the web page.

    • href: (string) location of the favicon image
    • name: (string) type of favicon
    • size: (int) size of favicon (if available)
    • active: (bool) true for the favicon returned by getFavicon. undefined for all others.

Contributing

Code Conventions

Use standard. CI won't pass without it.

Tests

Add tests where appropriate. See the test readme for some suggestions.

Semantic Versioning

Format commit messages to conform to conventional-changelog. This drives the semantic versioning of the module.

Additional Information

License

MIT