# parse-attr-options

> Parses a string of semi-colon delimited options into a plain object.

Latest version **0.1.4** (published 2017-02-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install parse-attr-options
pnpm add parse-attr-options
yarn add parse-attr-options
bun add parse-attr-options
```

## 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.1.4 |
| Published | 2017-02-12 |
| First published | 2016-05-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | twalker |
| Maintainers | twalker |
| Keywords | data-attributes |

## Links

- npm: https://www.npmjs.com/package/parse-attr-options
- Repository: https://github.com/twalker/parse-attr-options
- Issues: https://github.com/twalker/parse-attr-options/issues
- npm.io page: https://npm.io/package/parse-attr-options

## Recent versions

- 0.1.4 (latest) — 2017-02-12
- 0.1.3 — 2016-05-16
- 0.1.1 — 2016-05-15
- 0.1.0 — 2016-05-15

## README

# parse-attr-options

Parses a string of semi-colon delimited options into a plain object. Stringify provides the reverse.

```javascript
import { parse, stringify } from 'parse-attr-options'

parse('align: center; width: 300; neat: true; yagni: [1,2,3]')
>> {align: 'center', width: 300, neat: true, yagni: [1,2,3]}

stringify({align: 'center', width: 300, neat: true, yagni: [1,2,3]})
>> 'align: center; width: 300; neat: true; yagni: [1,2,3]'
```

Useful for options in html `data-`attributes:

```html
<section data-options="stamp: 1422377357359; go: hawks">content</section>
<script>
  let el = document.querySelector('section')
  let opts = parse(el.getAttribute('data-options'))
  console.info(`section last updated on ${opts.stamp}`)
</script>
```

## Why?!

Serializing and deserializing JSON in dom `data-` attributes can become a knot of single/double quotes.   This module provides a small quote-less alternative for a shallow set of options.  

Supports `string`, `boolean`, and `number` values, and arrays composed of the same.  
Does not support Objects, quotes, or nesting.  

---------------------

Inspired by: https://github.com/dfcreative/parse-attr

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