0.0.3 • Published 5 years ago

heropatterns-helper v0.0.3

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

Heropatterns Helper

Node.js helper functions to convert heropatterns to JPEGs, PNGs, SVGs, and ZIPs

Getting Started

Installation

Install with NPM.

npm install heropatterns-helper sharp

Install with Yarn.

yarn add heropatterns-helper sharp

Please note that Sharp.js is a peer dependency for toJpeg, toPng, and toZip.

Setup and Usage

Import the library

const heropatterns = require('heropatterns-helper');

const {
  toJpeg,
  toPng,
  toSvg,
  toZip,
  getMetadata,
  FileType,
} = require('heropatterns-helper');

Helper functions

// returns object { width, height, backgroundColor, foregroundColor, svg, }
getMetadata(cssString);
// returns buffer with jpeg
toJpeg(heroPatternSvg);
// returns buffer with png
toPng(heroPatternSvg);
// returns buffer with svg
toSvg(heroPatternSvg);
// The FileType as imported above
export const FileType = {
  JPEG: 'JPEG',
  PNG: 'PNG',
  SVG: 'SVG',
  ZIP: 'ZIP',
};

// if you have already created file buffers
// the zip function can reuse them
const files = {
  [FileType.JPEG]: await toJpeg(heroPatternSvg),
};
// returns buffer with zip
toZip(heroPatternSvg, files, fileName, licenseText);

License

Heropatterns Helper Code: MIT (see license.md)

0.0.3

5 years ago

0.0.2

5 years ago

0.0.1

5 years ago

0.0.0

5 years ago