How to use the svgo/lib/svgo/svg2js function in svgo

To help you get started, we’ve selected a few svgo examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github joshblack / react-svg-converter / src / index.js View on Github external
svg.map(({ name, content }) => new Promise((resolve, reject) => {
        svg2js(content, (result) => resolve({
          name,
          content: addStyleJSXAttribute(result, component)
        }));
      })));
github mapbox / svg-to-geojson / src / web-workers / svgo.js View on Github external
self.addEventListener('message', e => {
  const { svg } = e.data;

  svg2js(svg, parsedSvg => {
    if (parsedSvg.error) {
      throw Error(parsed.error);
    }

    const svg = cloneParsedSvg(parsedSvg);

    let cleanSvg;
    plugins(svg, {input: 'string'}, optimisedPluginsData);

    cleanSvg = js2svg(svg, { indent: '  ' }).data;
    self.postMessage(cleanSvg);
  });
});
github jakearchibald / svgomg / src / js / svgo-worker / index.js View on Github external
load({ data }) {
    svg2js(data, p => parsedSvg = p);

    if (parsedSvg.error) throw Error(parsedSvg.error);

    return getDimensions(parsedSvg);
  },
  process({ settings }) {
github wadackel / svg-to-jsx-with-gui / src / svg2jsx / processors / svgoProcessor.js View on Github external
return value => new Promise((resolve, reject) => {
    svg2js(value, (svg) => {
      if (svg.error) {
        reject(new Error(normalizeErrorString(svg.error)));
        return;
      }

      plugins(svg, opts);

      const jsx = js2svg(svg, {
        indent: '  ',
        pretty: true,
      }).data;

      resolve(jsx);
    });
  });
};