# to-dataset

> JS object to DOM dataset

Latest version **1.0.0** (published 2016-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install to-dataset
pnpm add to-dataset
yarn add to-dataset
bun add to-dataset
```

## 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 | 1.0.0 |
| Published | 2016-03-23 |
| First published | 2016-02-15 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Edo Balvers |
| Maintainers | ehtb |
| Keywords | dataset |

## Links

- npm: https://www.npmjs.com/package/to-dataset
- Repository: https://github.com/ehtb/to-dataset
- Homepage: https://github.com/ehtb/to-dataset#readme
- Issues: https://github.com/ehtb/to-dataset/issues
- npm.io page: https://npm.io/package/to-dataset

## Recent versions

- 1.0.0 (latest) — 2016-03-23
- 0.1.1 — 2016-02-17
- 0.1.0 — 2016-02-15

## README

# To Dataset

Object to DOM Dataset

## API

```js
  toDataset(hash, {data = {}, allowFalse = true} = {});
```

### hash
The object to convert to a dataset, every key will get the ```data``` prefix.

- Hash values can be of type String, Number, Boolean, Function and Object.
- Strings, Numbers and Booleans will be parsed as string values.
- Functions will be called and recursively added to the dataset.
- Objects will be recursively added to the dataset.

### data (optional)
The data object where the dataset will be merged into. Defaults to {}.

### allowFalse (optional)
Set falsy dataset attributes, otherwise ignore. Defaults to true.


## Example

```js

import toDataset from 'to-dataset';

const data = toDataset({
  component: 'link',
  'is-false': false,
  'is-deep': {
    deep: 1
  },
  'is-method': () => 'hello',
  'is-method-deep': () => ({
    a: 1,
    b: 2
  }),
  no: false
});

data === {
  'data-component': 'link',
  'data-is-false': 'false',
  'data-is-deep-deep': '1',
  'data-is-method': 'hello',
  'data-is-method-deep-a': '1',
  'data-is-method-deep-b': '2',
  'data-no': 'false'
};

```

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