How to use is-svg - 8 common examples

To help you get started, we’ve selected a few is-svg 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 itgalaxy / webfont / src / __tests__ / index.js View on Github external
}).then((result) => {
        /* eslint-disable ava/max-asserts */
        t.deepEqual(['svg', 'ttf', 'eot', 'woff', 'woff2', 'css'], Object.keys(result));
        t.true(isSvg(result.svg));
        t.true(isTtf(result.ttf));
        t.true(isEot(result.eot));
        t.true(isWoff(result.woff));
        t.true(isWoff2(result.woff2));
        t.is(result.css.slice(0, 21), '/* custom template */');
        /* eslint-enable ava/max-asserts */

        return result;
    }).catch(logError);
});
github webhintio / hint / packages / utils / src / content-type.ts View on Github external
if (!rawContent) {
        return null;
    }

    const detectedFileType = fileType(rawContent);

    if (detectedFileType) {

        /*
         * If the file is XML, check if it's a specific
         * type of XML such as a SVG.
         */

        if (detectedFileType.mime === 'application/xml' &&
            isSvg(rawContent)) {
            // See: https://www.w3.org/TR/SVG/mimereg.html.
            return 'image/svg+xml';
        }

        // Use the media types from `mime-db`, not `file-type`.
        return getMediaTypeBasedOnFileExtension(detectedFileType.ext);
    }

    return null;
};
github ritz078 / transform / pages / svg-to-react-native.tsx View on Github external
async ({ value }) => {
      if (!isSvg(value)) throw new Error("This is not a valid svg code.");

      svgo = svgo || getWorker(SvgoWorker);
      svgr = svgr || getWorker(SvgrWorker);

      let _value = await svgo.send({
        value,
        settings: {
          ...(settings.optimizeSvg ? settings : {}),
          ...nativeRequiredSettings
        }
      });

      // set optimized value in state to be used by preview.
      setOptimizedValue(_value);

      _babelWorker = _babelWorker || getWorker(BabelWorker);
github ritz078 / transform / pages / index.tsx View on Github external
async ({ value }) => {
      if (!isSvg(value)) throw new Error("This is not a valid svg code.");

      svgr = svgr || getWorker(SvgrWorker);
      svgo = svgo || getWorker(SvgoWorker);

      let _value = value;

      if (settings.optimizeSvg) {
        _value = await svgo.send({
          value,
          settings
        });
      }

      setOptimizedValue(_value);

      _value = await svgr.send({
github ritz078 / transform / pages / html-to-jsx.tsx View on Github external
async ({ value }) => {
      setSvg(isSvg(value));

      const converter = new HtmlToJsx(settings);

      return converter.convert(value);
    },
    [settings]
github ritz078 / transform / pages / svg-to-react-native.js View on Github external
getTransformedValue = async (newValue: string) => {
    if (!isSvg(newValue)) {
      throw new Error("Please provide a valid SVG markup.");
    }

    return new Promise(resolve =>
      convertSvgString(newValue, code => resolve(code))
    );
  };
github ritz078 / transform / pages / html-to-jsx.js View on Github external
convertHtmlToJsx = html => {
    if (isSvg(html) && this.state.shouldOptimize) {
      return new Promise(resolve => {
        svgo.optimize(html, result => {
          resolve(converter.convert(result.data));
        });
      });
    }
    return converter.convert(html);
  };

is-svg

Check if a string is SVG

MIT
Latest version published 5 months ago

Package Health Score

78 / 100
Full package analysis

Popular is-svg functions