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

@mithray/font-cacher

v0.0.130

Published

For loading and downloading Fonts locally, only Google Fonts is supported for now but this may change. Fonts are retrieved from a font url, and returned. If already present on disk they will be loaded from disk and returned. If not present on disk they wi

Downloads

11

Readme

Font Cacher

For loading and downloading Fonts locally, only Google Fonts is supported for now but this may change. Fonts are retrieved from a font url, and returned. If already present on disk they will be loaded from disk and returned. If not present on disk they will be downloaded, saved to disk, and returned. Useful for integrating into SSGs or other site builders.

Usage

import { getFont } from '@mithray/font-cacher

const options = {cachePath: './fonts'}
const url = 'https://fonts.googleapis.com/css2?family=Playfair+Display'
const fontFiles = await getFont(options)(url)
console.log(fontFiles)
/*
Output is an array of files, which will be saved to disk
[
  {
    name: 'https!fonts.googleapis.com!css2!family=Playfair+Display',
    filename: 'https!fonts.googleapis.com!css2!family=Playfair+Display',
    url: 'https://fonts.googleapis.com/css2?family=Playfair+Display',
    mimetype: 'text/css',
    ext: 'css',
    data: <Buffer 2f 2a 20 63 79 72 69 6c 6c 69 63 20 2a 2f 0a 40 66 6f 6e 74 2d 66 61 63 65 20 7b 0a 20 20 66 6f 6e 74 2d 66 61 6d 69 6c 79 3a 20 27 50 6c 61 79 66 61 ... 1535 more bytes>,
    digest: 'qBv0a2kEUGwSh+7GjUAk6neS0kM9CK6tQxkFHvt1NPd09td0FnwUNOX/RrMjZK4W0+Rl3Wqw1hxkCH8LA5+QDw=='
  },
...
  {
    name: 'https!fonts.gstatic.com!s!playfairdisplay!v37!nuFvD-vYSZviVYUb_rj3ij__anPXJzDwcbmjWBN2PKdFvXDT.woff2',
    filename: 'https!fonts.gstatic.com!s!playfairdisplay!v37!nuFvD-vYSZviVYUb_rj3ij__anPXJzDwcbmjWBN2PKdFvXDT.woff2',
    url: 'https://fonts.gstatic.com/s/playfairdisplay/v37/nuFvD-vYSZviVYUb_rj3ij__anPXJzDwcbmjWBN2PKdFvXDTbtPK_l2qI0s.woff2',
    mimetype: 'font/woff2',
    ext: 'woff2',
    data: <Buffer 77 4f 46 32 00 01 00 00 00 00 2c 5c 00 0f 00 00 00 00 6d 98 00 00 2b fd 00 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 1a 81 ... 11306 more bytes>,
    digest: '9nkMIqw3pwNBKI7O0umHwYJJOBCsmZS+nsEPsBRKI4XKBvjKPQlORTYoweGPwrttT9Qzstkczc883FKOAB3s7g=='
  },
]
*/

By default, the files will be saved in './fonts'. If you want to change the directory, pass `{cachePath: './some_path_here'}` as first argument to getFont. If you want to disable saving to disk,because you want to integrate it into some other build step, you can pass `{cachePath: null}`.

Options

opts =
  { cachePath: './fonts' // Any Path
  , verbosity: 'silent' // 'silent', 'debug', 'info'  
  }