# heropatterns-helper

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

Latest version **0.0.3** (published 2019-07-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install heropatterns-helper
pnpm add heropatterns-helper
yarn add heropatterns-helper
bun add heropatterns-helper
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2019-07-17 |
| First published | 2019-07-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 14.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | John Armstrong |
| Maintainers | jlarmstrongiv |

## Links

- npm: https://www.npmjs.com/package/heropatterns-helper
- Repository: https://github.com/jlarmstrongiv/heropatterns-helper
- Homepage: https://github.com/jlarmstrongiv/heropatterns-helper#readme
- Issues: https://github.com/jlarmstrongiv/heropatterns-helper/issues
- npm.io page: https://npm.io/package/heropatterns-helper

## Dependencies (2)

- [adm-zip](https://npm.io/package/adm-zip.md) ^0.4.13
- [import-lazy](https://npm.io/package/import-lazy.md) ^4.0.0

## Recent versions

- 0.0.3 (latest) — 2019-07-17
- 0.0.2 — 2019-07-07
- 0.0.1 — 2019-07-07
- 0.0.0 — 2019-07-07

## README

# Heropatterns Helper

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

## Getting Started

### Installation

Install with [NPM](https://www.npmjs.com/package/heropatterns-helper).

```Shell
npm install heropatterns-helper sharp
```

Install with Yarn.

```Shell
yarn add heropatterns-helper sharp
```

Please note that [Sharp.js](https://github.com/lovell/sharp) is a peer dependency for `toJpeg`, `toPng`, and `toZip`.

### Setup and Usage

#### Import the library

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

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

#### Helper functions

```js
// returns object { width, height, backgroundColor, foregroundColor, svg, }
getMetadata(cssString);
```

```js
// returns buffer with jpeg
toJpeg(heroPatternSvg);
```

```js
// returns buffer with png
toPng(heroPatternSvg);
```

```js
// returns buffer with svg
toSvg(heroPatternSvg);
```

```js
// 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)

---
_Source: https://npm.io/package/heropatterns-helper · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
