# parse-ingredients

> Multi-language recipe ingredients parser

Latest version **0.2.8** (published 2021-11-03) · MIT license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install parse-ingredients
pnpm add parse-ingredients
yarn add parse-ingredients
bun add parse-ingredients
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.2.8 |
| Published | 2021-11-03 |
| First published | 2021-10-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 169 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 3 |
| Author | Jérémy Magrin |
| Maintainers | magrinj |
| Keywords | recipe, parser, ingredient, combine, units |

## Links

- npm: https://www.npmjs.com/package/parse-ingredients
- Repository: https://github.com/JMagrin/parse-ingredients
- Homepage: https://github.com/JMagrin/parse-ingredients.git#readme
- Issues: https://github.com/JMagrin/parse-ingredients.git/issues
- npm.io page: https://npm.io/package/parse-ingredients

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 0.2.8 (latest) — 2021-11-03
- 0.2.7 — 2021-11-03
- 0.2.6 — 2021-10-29
- 0.2.5 — 2021-10-29
- 0.2.4 — 2021-10-29
- 0.2.3 — 2021-10-28
- 0.2.2 — 2021-10-28
- 0.2.1 — 2021-10-28
- 0.2.0 — 2021-10-23
- 0.1.5 — 2021-10-22
- 0.1.4 — 2021-10-22
- 0.1.3 — 2021-10-22
- 0.1.2 — 2021-10-22
- 0.1.1 — 2021-10-22
- 0.1.0 — 2021-10-22

## README

# parse-ingredients

[![NPM version][npm-version-image]][npm-url]
[![NPM downloads][npm-downloads-image]][npm-downloads-url]
[![MIT License][license-image]][license-url]

[license-image]: https://img.shields.io/badge/license-MIT-blue.svg?style=flat
[license-url]: LICENSE

[npm-url]: https://npmjs.org/package/parse-ingredients
[npm-version-image]: https://img.shields.io/npm/v/parse-ingredients.svg?style=flat

[npm-downloads-image]: https://img.shields.io/npm/dm/parse-ingredients.svg?style=flat
[npm-downloads-url]: https://npmcharts.com/compare/parse-ingredients?minimal=true


Parser for recipes and lists of ingredients. Can parse a string into an object and also combine an array of these ingredient objects.

## About

This project was rewrite on top of code written by [mackenziefernandez](https://github.com/mackenziefernandez/recipe-parser). 

## To install

`yarn add parse-ingredients`

## To use

```typescript
import parse from 'parse-ingredients';

console.log(parse('1 teaspoon of basil'));
/*
{
  quantity: 1,
  unit: 'teaspoon',
  ingredient: 'basil',
  article: 'of',
  minQty: 1,
  maxQty: 1
};
*/
```

`import parse from 'parse-ingredients';`

### Language

This package currenly support french and english.
By default english is imported.
If you want to use another language do the following:

```typescript
import parse from 'parse-ingredients';

// import 'parse-ingredients/lib/locale/{LOCALE_NAME}'
import 'parse-ingredients/lib/locale/fr'

console.log(parse('1 c. à café de basilique'));
/*
{
  quantity: 1,
  unit: 'cuillère à café',
  ingredient: 'basilique',
  article: 'de',
  minQty: 1,
  maxQty: 1
};
*/
```

### Combine ingredient objects

```typescript
import {combine} from 'parse-ingredients';

console.log(combine([{
  quantity: 1,
  unit: 'teaspoon',
  ingredient: 'basil',
  article: 'of',
  minQty: 1,
  maxQty: 2,
},
{
  quantity: 2,
  unit: 'teaspoon',
  ingredient: 'basil',
  article: 'of',
  minQty: 2,
  maxQty: 2
}]));
/*
[{
  quantity: 3,
  unit: 'teaspoon',
  ingredient: 'basil',
  minQty: 3,
  maxQty: 4
}]
*/
```

### Prettify ingredient

```typescript
import {pretty} from 'parse-ingredients';

console.log(pretty({
  quantity: 1,
  unit: 'teaspoon',
  ingredient: 'basil',
  article: 'of',
  minQty: 1,
  maxQty: 1,
}));
/*
1 teaspoon of basil
*/
```

### Unicode Fractions
Will also correctly parse unicode fractions into the proper amount

### Development	
Clone the repo and `yarn` to install packages. If `yarn test` comes back good after your code changes, give yourself a pat on the back.

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