# melt-data

> Javascript library inspired by the R reshape package

Latest version **0.2.1** (published 2013-09-19) · Apache-2.0 license · 0 weekly downloads

## Install

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

## 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.2.1 |
| Published | 2013-09-19 |
| First published | 2013-09-19 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Jacob Rideout |
| Maintainers | jrideout |
| Keywords | json, object, reshape, melt, cast |

## Links

- npm: https://www.npmjs.com/package/melt-data
- Repository: https://github.com/jrideout/melt.js
- Homepage: http://git.io/melt
- Issues: https://github.com/jrideout/melt.js/issues
- npm.io page: https://npm.io/package/melt-data

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.2.1 (latest) — 2013-09-19
- 0.2.0 — 2013-09-19

## README

[![Build Status](https://travis-ci.org/jrideout/melt.js.png?branch=master)](https://travis-ci.org/jrideout/melt.js)

Melt.js
=======

Javascript library inspired by the [R reshape](https://github.com/hadley/reshape) package by Hadley Wickham.

Melt provides two functions `melt` and `cast`. How do they work? 

First, they presume you have your data in the form of a list of objects. That looks like this:

```js
var data = [
  {key1: 1, key2: 2},
  {key1: 2, key2: 3},
  {key1: 3, key2: 5},
];
```

But if you need the keys to be represented as a value, then melt can come to the rescue. Let's take a look at some examples:

Examples
------------

Melt: [jsfiddle](http://jsfiddle.net/mf4Jd/)

Cast: [jsfiddle](http://jsfiddle.net/b5apx/)

API
----

**melt(data, keep, varName, valName, noAddId)**

  * `data` _list of objects_ - data to melt
  * `keep` _array of strings_ - names of object keys to keep
  * `varName` _string_ - name of the key to use in the molten objects for the former keys (those not in keep)
  * `varName` _string_ - name of the key to use in the molten objects for the former values

**cast(data, keep, fun, funArgs ...)**

  * `data` _list of objects_ - data to cast
  * `keep` _array of strings_ - names of object keys to keep (the "GROUP BY" keys)
  * `fun` _function_ - a function used to aggregate values accross grouped objects
  * `funArgs` _mixed_ - arguments to passed to `fun`
  
**cast.sum(name, cols)** - convience function to summarize data with cast

  * `name` _string_ name of resulting object key with sum results
  * `cols` _string or array_ - names of keys to totaled in the sum. Key values should respond to `+`.

**cast.sum(name)** - convience function to sum data with cast

  * `name` _string_ - special case of `cast.sum(name, cols)` name is treated as both `name` and `cols`.

**cast.count(name)** - convience function to count data with cast

  * `name` _string_ - name of resulting object key with which to count objects with common `keep` values

License
-------
Apache 2

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