New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

svgstore

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

svgstore

Combines mulitple svg files into one.

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28K
decreased by-16.81%
Maintainers
1
Weekly downloads
 
Created
Source

svgstore

NPM version Downloads Build Status Coverage Status Chat Tip

Combines multiple svg files into one using <symbol> elements which you may <use> in your markup. Heavily inspired by grunt-svgstore and gulp-svgstore, this is a standalone module that may be used in any asset pipeline.

Install

$ npm install --save svgstore

Usage

var svgstore = require('svgstore');
var fs = require('fs');

var sprites = svgstore()
    .add('unicorn', fs.readFileSync('./unicorn.svg', 'utf8'))
    .add('rainbow', fs.readFileSync('./rainbow.svg', 'utf8'));

fs.writeFileSync('./sprites.svg', sprites.toString());

The resulting file may be consumed in markup as external content.

<body>
    <svg role="img"><use xlink:href="./sprites.svg#unicorn"/></svg>
    <svg role="img"><use xlink:href="./sprites.svg#rainbow"/></svg>
</body>

See the examples directory for more detail.

API

svgstore(): SvgStore

Creates a container svg sprites document.

.element

The current cheerio instance.

.add(id, svg): SvgStore

  • id String Unique id for this svg file.
  • svg String Raw source of the svg file.

Appends a file to the sprite with the given id.

.toString([options]): String

  • options {Object}
    • inline {Boolean} (default: false) Don't output <?xml ?> and DOCTYPE.

Outputs sprite as a string of XML.

Contribute

Standards for this project, including tests, code coverage, and semantics are enforced with a build tool. Pull requests must include passing tests with 100% code coverage and no linting errors.

Test

$ npm test

© Shannon Moeller me@shannonmoeller.com (shannonmoeller.com)

Licensed under MIT

Keywords

FAQs

Package last updated on 09 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc