# data-module

> Wrap a plain JS object into an ES6 module.

Latest version **0.0.4** (published 2014-12-17) · MIT license · 0 weekly downloads

## Install

```sh
npm install data-module
pnpm add data-module
yarn add data-module
bun add data-module
```

## 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.4 |
| Published | 2014-12-17 |
| First published | 2014-12-10 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Maintainers | tomekwi |

## Links

- npm: https://www.npmjs.com/package/data-module
- Repository: https://github.com/tomekwi/data-module
- Issues: https://github.com/tomekwi/data-module/issues
- npm.io page: https://npm.io/package/data-module

## Dependencies (4)

- [extend](https://npm.io/package/extend.md) ~2.0.0
- [trimmer](https://npm.io/package/trimmer.md) ~1.0.0
- [format-json](https://npm.io/package/format-json.md) ~1.0.3
- [indent-string](https://npm.io/package/indent-string.md) ~1.2.0

## Recent versions

- 0.0.4 (latest) — 2014-12-17
- 0.0.3 — 2014-12-10
- 0.0.2 — 2014-12-10
- 0.0.1 — 2014-12-10

## README

data-module
===========

**Wrap a plain JS object into an ES6 module.**




Installation
------------

```
npm install data-module
```




Usage
-----

```js
var dataModule = require('data-module');

dataModule(
    { object: 'with'
    , some: ['important', 'data']
    }).toString();

// Outputs String: >
//     export default {"object":"with","some":["important","data"]};
//
```




API
---

### dataModule(data, [options])

#### data
> Type: `any`

The data to be wrapped in a module.


#### options.formatting(data)
> Default: JSON.stringify  
> Type: `Function`  
> Should accept arguments: `data` (type: `any`)  
> Should return type: `String`

The formatting function. When passed the original `data`, it should return its representation in valid JavaScript code.

We ship the function `dataModule.formatting.diffy([options])(data)`, which you can use here. The default value for `options` is `{indentString: '  '}`. We use [format-json][]'s diffy formatter to generate the output.




License
-------

[MIT][] © [Tomek Wiszniewski][].




<!-- Links -->
[MIT]: ./License.md
[Tomek Wiszniewski]: https://github.com/tomekwi
[format-json]: https://www.npmjs.com/package/format-json

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