# opts-parser

> A very simple options string parser similiar to CSS.

Latest version **4.0.0** (published 2016-02-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install opts-parser
pnpm add opts-parser
yarn add opts-parser
bun add opts-parser
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 4.0.0 |
| Published | 2016-02-07 |
| First published | 2016-02-07 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=4 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alex Gorbatchev |
| Maintainers | alexgorbatchev |
| Keywords | options, parser |

## Links

- npm: https://www.npmjs.com/package/opts-parser
- Repository: https://github.com/syntaxhighlighter/opts-parser
- Issues: https://github.com/syntaxhighlighter/opts-parser/issues
- npm.io page: https://npm.io/package/opts-parser

## Dependencies (1)

- [syntaxhighlighter-regex](https://npm.io/package/syntaxhighlighter-regex.md) ^4.0.0

## 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

- 4.0.0 (latest) — 2016-02-07

## README

# opts-parser

[![GratiPay](https://img.shields.io/gratipay/user/alexgorbatchev.svg)](https://gratipay.com/alexgorbatchev/)
[![Build Status](https://travis-ci.org/syntaxhighlighter/opts-parser.svg)](https://travis-ci.org/syntaxhighlighter/opts-parser)
[![Coverage](https://img.shields.io/codecov/c/github/syntaxhighlighter/opts-parser.svg)](https://codecov.io/github/syntaxhighlighter/opts-parser)
![Downloads](https://img.shields.io/npm/dm/opts-parser.svg)
![Version](https://img.shields.io/npm/v/opts-parser.svg)

Parses key/value pairs into hash object. The source format looks like HTML's `style` attribute, see below for more details.

This was an old school way of passing random canfiguration values through `class` attribute into SyntaxHighlighter. Why not use `data-*` attributes? Well, back in 2002 those didn't exist... Yes, this could be modernized a bit, at the same time there are hundreds of thousands active usages now. 

## Important

This module depends on a verion of [XRegExp](https://github.com/slevithan/xregexp) that is bundled in [syntaxhighlighter-regex](https://github.com/syntaxhighlighter/syntaxhighlighter-regex). At the time of writing, the bundled version `3.1.0-dev` is unreleased.

## Installation

```
npm install opts-parser
```

## Usage Example

```
var opts = require('opts-parser');
opts.parse("hello: value; foo-bar: [12, "monkeys"]; value: 'value'");

{
  "hello": "value",
  "foo-bar": [12, "monkeys"],
  "fooBar": [12, "monkeys"],
  "value": "value
}
```

Understands the following formats:

- `name: true|false;`
- `name: word;`
- `name: [word, word];`
- `name: "string";`
- `name: 'string';`

## Testing

    npm test

## License

MIT

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