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

use-icons

v0.9.5

Published

Provide svg to iconfont and png/jpg to sprity-image

Downloads

4

Readme

use-icons

Provide svg to iconfont and png/jpg to sprity-image

Installation

npm install use-icons

Use

var useIcons = require("use-icons");

/**
 * Generate the sprites - image
 */
var pics = []; 
var picOptions = {};
useIcons.pic2icons(pics, picOptions, function(err, files) {
});
var useIcons = require("use-icons");
/**
 * Generate svg icon fonts
 */
var svgs = [];
var svgOptions = {};
useIcons.svg2icons(svg, svgOptions, function(err, files) {
});

Documentation

API

  • svg2icons(data, options, callback)
    • data Array

      [
          {
              file: "./aa.svg", //The SVG file path
              unicode : "e001", //font unicode
              classname : "aa", //default unicode, output classname
          },
          {
              content: "<svg>...</svg>", // The content of the SVG file
              unicode : "e002", //font unicode
              classname : "bb", //default unicode, output classname
          },
          ...
      ]
    • options:Object

      svgicons2svgfont options

      {
          fileName : "", //Type: String default: iconfonts, font file name
          classPrefix : "",//Type: String default: "icon-", font class prefix
          fontBaseUri : "", //Type: String default: "", font url
          fontOptions : [], //Type: Array default : [{family : "iconfonts", classname : "iconfonts"}]
          resetViewBoxSize : false, //Type: Boolean Default: false, 
          prependUnicode : false, //Type: Boolean Default: false, The automation of module
          startUnicode : 0xE001, //Type: Number, Default - 0xE001, the number of the start unicode
          /*--- svgicons2svgfont options ---*/
          fontName : "", //required, Type: String Default value: 'iconfont',The font family name you want.
          fontId : "", //Type: String Default value: the options.fontName value,The font id you want.
          fontStyle : "", //Type: String Default value: '',The font style you want.
          fontWeight : "", //Type: String Default value: '',The font weight you want.
          fixedWidth : false, // Type: Boolean Default value: false,Creates a monospace font of the width of the largest input icon
          centerHorizontally : false, //Type: Boolean Default value: false,Calculate the bounds of a glyph and center it horizontally.
          normalize : false, //Type: Boolean Default value: false,Normalize icons by scaling them to the height of the highest icon.
          fontHeight : "", //Type: Number Default value: MAX(icons.height) The outputted font height (defaults to the height of the highest input icon).
          round : 10e12,//Type: Number Default value: 10e12 Setup SVG path rounding.
          descent : 0, //Type: Number Default value: 0,The font descent. It is usefull to fix the font baseline yourself.
          ascent : "", //Type: Number Default value: fontHeight - descent,The font ascent. Use this options only if you know what you're doing. A suitable value for this is computed for you.
          metadata : "", //Type: String Default value: undefined,The font metadata(https://www.w3.org/TR/SVG/metadata.html). You can set any character data in but it is the be suited place for a copyright mention.
          log : "",//Type: Function Default value: console.log,Allows you to provide your own logging function. Set to function(){} to impeach logging.
      }
    • callback(err, files):Function

      • err Mixed // error info

      • files Array//out files content

        [
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "svg",
                content : "..."
            },
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "eof",
                content : "..."
            },
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "ttf",
                content : "..."
            },
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "woff",
                content : "..."
            },
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "woff2",
                content : "..."
            },
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "css",
                content : "..."
            },
            {
                fileName : options.fileName,// same of Options.fileName
                fileType : "html",
                content : "..."
            }
        ]

Demo

icons-svg

  • pic2icons(data, options, callback)
    • data:Array

      [
          {
              file: "./aa.jpg", //The Image file path
              classname : "aa", //Default: filename, output classname
          },
          {
              file: "./bb.jpg", //The Image file path
              classname : "bb", //Default: filename, output classname
          },
          {
              content : "...", //The Image binary resources, use image content ,the classname is required
              classname: "cc", //Required, output classname
              ext: "png", //Default: png, file ext
          }
          ...
      ]
    • options:Object

      Spritesmith Options

      {
          padding : 5, //Default: 5, The Image space
          /*--- Spritesmith Options ---*/
          algorithm : "binary-tree",//Default: binary-tree,top-down,left-right,diagonal,alt-diagonal,binary-tree
          quality : 100, //Default: 100, The quality of the picture
          sort : false,//Default: false, Whether the sorting
          imageName : "sprites.png", //Default: sprites.png, output Sprites Image
          imageUrl : "",//Default: options.imageName, background-image:url image-url
          classMain : "sprites, //Default: sprites, main class
          classPrefix : "sprites-" //Default: "sprites-", class prefix
      }
    • callback(err, files):Function

      • err Mixed // error info

      • files Array//out files content

        [
            {
                fileName : options.imageName.replace(/\.([^\.]+)$/, ""),
                fileType : options.imageName.replace(/.*\.([^\.]+)$/, "$1"),
                content : "..."
            },
            {
                fileName : "sprites",
                fileType : "css",
                content : "..."
            },
            {
                fileName : "sprites",
                fileType : "html",
                content : "..."
            }
        ]

Demo

icons-svg

  • hex2int(intStr)
    • intStr Number
  • int2hex(hexStr)
    • hexStr String

License

MIT