# with-flatten

> flatten constructor objects to top level camelcased with reverse access

Latest version **1.0.0** (published 2022-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install with-flatten
pnpm add with-flatten
yarn add with-flatten
bun add with-flatten
```

## Health

**Score 30/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2022-03-16 |
| First published | 2022-03-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 26.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | stagas |
| Maintainers | stagas |

## Links

- npm: https://www.npmjs.com/package/with-flatten
- Repository: https://git@github.com/stagas/with-flatten
- Homepage: https://github.com/stagas/with-flatten#readme
- Issues: https://github.com/stagas/with-flatten/issues
- npm.io page: https://npm.io/package/with-flatten

## Dependencies (1)

- [define-accessors](https://npm.io/package/define-accessors.md) ^1.1.1

## Recent versions

- 1.0.0 (latest) — 2022-03-16

## README

<h1 align="center">with-flatten</h1>

<p align="center">
flatten constructor objects to top level camelcased with reverse access
</p>

<p align="center">
   <a href="#install">        🔧 <strong>Install</strong></a>
 · <a href="#example">        🧩 <strong>Example</strong></a>
 · <a href="#api">            📜 <strong>API docs</strong></a>
 · <a href="https://github.com/stagas/with-flatten/releases"> 🔥 <strong>Releases</strong></a>
 · <a href="#contribute">     💪🏼 <strong>Contribute</strong></a>
 · <a href="https://github.com/stagas/with-flatten/issues">   🖐️ <strong>Help</strong></a>
</p>

***

## Install

```sh
$ npm i with-flatten
```

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

*   [withFlatten](#withflatten)
    *   [Parameters](#parameters)

### withFlatten

[src/index.ts:67-107](https://github.com/stagas/with-flatten/blob/c8dfb35272d3a077ecf5e203e49226c10766e995/src/index.ts#L67-L107 "Source code on GitHub")

Mixins `ctor` with `parent` and camelCase flattens
and observes its properties mapping them back to the actual values.
Best used in conjuction with <https://github.com/stagas/with-properties>

```ts
const Foo = withFlatten(
  SomeParent,
  class {
    deep = {
      foo: 2,
    }
  }
)
const foo = new Foo()
foo.deepFoo = 4
expect(foo.deep.foo).toBe(4)
```

#### Parameters

*   `parent` **P**&#x20;
*   `ctor` **[Constructor](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object/constructor)\<T>**&#x20;

## Contribute

[Fork](https://github.com/stagas/with-flatten/fork) or
[edit](https://github.dev/stagas/with-flatten) and submit a PR.

All contributions are welcome!

## License

MIT © 2022
[stagas](https://github.com/stagas)

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