flex-svg
Create SVG files of flexible width and height
Last updated 3 years ago by shinnn .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ cnpm install flex-svg 
SYNC missed versions from official npm registry.

flex-svg

npm version Build Status Coverage Status

A Node.js module to create SVG files of flexible width and height

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg" width="50px" height="50px">
  <rect width="50px" height="50px"/>
</svg>

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<svg xmlns="http://www.w3.org/2000/svg">
  <rect width="50px" height="50px"/>
</svg>

If width and height attributes of outermost svg elements are not specified, they are regarded as 100% according to SVG 1.1 Specification.

Used by

Installation

Use npm.

npm install flex-svg

API

const flexSvg = require('flex-svg');

flexSvg(SVGdata [, options], callback)

SVGdata: string Buffer (SVG)
options: Object (directly passed to the xml2js.Parser options and the xml2js.Builder options)
callback: Function

callback(error, result)

error: Error if it fails to parse SVG, otherwise null
result: String of SVG without width and height attributes

const fs = require('fs');
const flexSvg = require('flex-svg');

fs.readFile('path/to/file.svg', (readErr, data) => {
  if (readErr) {
    throw readErr;
  }

  flexSvg(data, (parseErr, result) => {
    if (parseErr) {
      throw parseErr;
    }

    console.log(result);
  });
});

flexSvg.FlexSvg([options])

Return: Function

Create a function to which options are binded. This is more efficient way in the case when the program repeatedly runs flexSvg function with the same options.

License

Copyright (c) 2014 - 2017 Shinnosuke Watanabe

Licensed under the MIT License

Current Tags

  • 3.0.0-2                                ...           latest (3 years ago)
  • 3.0.0-4                                ...           next (2 years ago)

19 Versions

  • 3.0.0-4                                ...           2 years ago
  • 3.0.0-3                                ...           2 years ago
  • 3.0.0-2                                ...           3 years ago
  • 3.0.0-1                                ...           3 years ago
  • 3.0.0-0                                ...           3 years ago
  • 2.1.1                                ...           5 years ago
  • 2.1.0                                ...           5 years ago
  • 2.0.1                                ...           5 years ago
  • 2.0.0                                ...           5 years ago
  • 1.0.1                                ...           6 years ago
  • 1.0.0                                ...           6 years ago
  • 0.2.0                                ...           6 years ago
  • 0.1.1                                ...           6 years ago
  • 0.1.0                                ...           6 years ago
  • 0.0.4                                ...           6 years ago
  • 0.0.3                                ...           6 years ago
  • 0.0.2                                ...           6 years ago
  • 0.0.1                                ...           6 years ago
  • 0.0.0                                ...           6 years ago
Maintainers (1)
Downloads
Today 0
This Week 0
This Month 0
Last Day 0
Last Week 0
Last Month 0
Dependencies (1)
Dev Dependencies (5)

Copyright 2014 - 2016 © taobao.org |