# densen

> Reduce the size of your serialized data with densen by turning objects literal into arrays of values.

Latest version **2.0.0** (published 2021-01-22) · MIT license · 0 weekly downloads

## Install

```sh
npm install densen
pnpm add densen
yarn add densen
bun add densen
```

## 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 | 2.0.0 |
| Published | 2021-01-22 |
| First published | 2021-01-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 9.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | CreatifCreateur |
| Maintainers | creatif-createur |
| Keywords | compress, compressor, js, javascript, min, minification, minifier, optimize, optimizer, array, object, parse, parser |

## Links

- npm: https://www.npmjs.com/package/densen
- npm.io page: https://npm.io/package/densen

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

- 2.0.0 (latest) — 2021-01-22

## README

# densen

Reduce the size of your serialized data with `densen` by turning objects literal into arrays of values.

## Examples

### With Object

```js
const densen = require('densen');

const unflattened = {
	qualities: ['perseverant', 'open-minded', 'funny'],
	name: 'Alexander',
	hobbies: [
		{
			activity_name: 'soccer',
			hours_per_week: 4,
		},
		{
			activity_name: 'piano',
			hours_per_week: 3,
		},
		{
			activity_name: 'painting',
			hours_per_week: 2,
		},
	],
	age: 32,
	profession: {
		title: 'engineer',
		salary: 70000,
	},
};

const flattened = [
	'Alexander',
	32,
	['engineer', 70000],
	[
		['soccer', 4],
		['piano', 3],
		['painting', 2],
	],
	['perseverant', 'open-minded', 'funny'],
];

const shape = {
	name: '',
	age: 0,
	profession: {
		title: '',
		salary: 0,
	},
	hobbies: [
		{
			activity_name: '',
			hours_per_week: 0,
		},
	],
	qualities: [''],
};

const compressor = densen(shape);

compressor.unflatten(flattened); // returns unflattened
compressor.flatten(unflattened); // returns flattened
```

### With Array

```js
const densen = require('densen');

const unflattened = [
	{
		age: 44,
		name: 'Alice',
	},
	{
		name: 'Bob',
		age: 32,
	},
];

const flattened = [
	['Alice', 44],
	['Bob', 32],
];

const shape = [
	{
		name: '',
		age: 0,
	},
];

const compressor = densen(shape);

compressor.unflatten(flattened); // returns unflattened
compressor.flatten(unflattened); // returns flattened
```

## Functions

`unflatten` = values => keys / values

`flatten` = keys / values => values

## Details

0 dependencies
ECMAScript 2015

## License

MIT License

Copyright (c) 2021 CreatifCreateur

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