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

weft

v1.3.1

Published

NodeJS API Wrapper for Google Web Fonts

Downloads

21

Readme

:santa: weft

NodeJS API Wrapper for Google Web Fonts

Installation

Using NPM
npm install weft --save

Using Yarn
yarn add weft

Usage

const weft = require('weft')

// Set API Key
weft.apiKey(/* Your API_KEY here */)

// See current API Key
console.log(weft.apiKey())

// Display Google Fonts Complete List
weft.list().then(result => {
  console.log(result)
})

/**
 * Display Google Fonts With Custom Fields
 * See fields and sortBy on API section below
 */
weft.list(fields, sortBy).then(result => {
  console.log(result)
})

// View Open Sans Info
weft.view('Open Sans').then(result => {
  console.log(result)
})

/**
 * Search fonts
 * See options on API section below
 */
weft.search('monts', options).then(result => {
  console.log(result)
})

// Get font URL
console.log(weft.embedUrl('Montserrat', options))

API

Table of Contents

weft.sortBy

Constant variables of sorting list.

| Key | Value | | --- | --- | | ALPHA | alpha | | DATE | date | | SYLE | style | | TRENDING | trending | | POPULAR | popularity |

Example

weft.list(options, weft.sortBy.TRENDING)

weft.categories

Constant variables of categories.

| Key | Value | | --- | --- | | ALL | Empty | | SERIF | serif | | SANS_SERIF | sans-serif | | DISPLAY | display, | HANDWRITING | handwriting | | MONOSPACE | monospace |

weft.apiKey (key: string = '')

Set or Get API Key. If you leave key empty, it will be used as getter.

weft.list (fields?: object = '', sortBy?: string = weft.sortBy.ALPHA)

Get Google Fonts list. The first argument fields is to see or hide result from Google Fonts API. The second argument is sorting function.

Default Fields

| Key | Description | Default Value | | --- | --- | --- | | category | Font category | false | | files | File list from Google Server | false | | family | Font Family Name | true | | lastModified | Last modified date | false | | subsets | Font Subsets | false | | variants | Font Variants | false | | version | Font Version | false |

Example

// Get font family and font variants
const yoFields = {
  category: false,
  files: false,
  family: true,
  lastModified: false,
  subsets: false,
  variants: true,
  version: false
}

weft.list(yoFields).then(result => {
  // Pssst, hey kids wanna see result?
})

weft.view (fontName: string)

View individual font information.

weft.search (query: string = '', options?: object = {})

Search font with criteria. query can be empty.

Default Options

 {
  fields: {
    // See default fields on weft.list section above
  },
  category: weft.categories.ALL,
  sortBy: weft.sortBy.TRENDING,
  subsets: {
    latin: false,
    latinExtended: false,
    sinhala: false,
    greek: false,
    hebrew: false,
    vietnamese: false,
    cyrillic: false,
    cyrillicExtended: false,
    devanagari: false,
    arabic: false,
    khmer: false,
    tamil: false,
    greekExtended: false,
    thai: false,
    bengali: false,
    gujarati: false,
    oriya: false,
    malayalam: false,
    gurmukhi: false,
    kannada: false,
    telugu: false,
    myanmar: false
  },
  variants: {
    thin: false,
    thinItalic: false,
    extraLight: false,
    extraLightItalic: false,
    light: false,
    lightItalic: false,
    regular: false,
    italic: false,
    medium: false,
    mediumItalic: false,
    semiBold: false,
    semiBoldItalic: false,
    bold: false,
    boldItalic: false,
    extraBold: false,
    extraBoldItalic: false,
    black: false,
    blackItalic: false
  }
})

weft.embedUrl (fontName: string = '', options?: object = {})

Get Google Fonts Embed URL

License

MIT © oknoorap