# flatcopy

> Micro-Library for flat object or array copies in context of immutable objects/arrays

Latest version **1.0.1** (published 2016-10-20) · MIT license · 0 weekly downloads

## Install

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

## Health

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

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

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.1 |
| Published | 2016-10-20 |
| First published | 2016-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Philipp Renoth |
| Maintainers | daaitch |
| Keywords | immutable, copy |

## Links

- npm: https://www.npmjs.com/package/flatcopy
- Repository: https://github.com/DaAitch/flatcopy
- Homepage: https://github.com/DaAitch/flatcopy#readme
- Issues: https://github.com/DaAitch/flatcopy/issues
- npm.io page: https://npm.io/package/flatcopy

## Dependencies (1)

- [lodash](https://npm.io/package/lodash.md) ^4.16.4

## Alternatives

- [@lexical/table](https://npm.io/package/@lexical/table.md) — 3.0M weekly downloads
- [mantine-datatable](https://npm.io/package/mantine-datatable.md) — 98.2K weekly downloads
- [react-native-collapsible-tab-view](https://npm.io/package/react-native-collapsible-tab-view.md) — 70.6K weekly downloads
- [@handsontable/vue3](https://npm.io/package/@handsontable/vue3.md) — 16.1K weekly downloads
- [vuewordcloud](https://npm.io/package/vuewordcloud.md) — 7.2K weekly downloads

## Recent versions

- 1.0.1 (latest) — 2016-10-20
- 1.0.0 — 2016-10-16

## README

# flatcopy
Micro-Library for flat object or array copies in context of immutable objects/arrays.
This is just a small wrapper library with some checks, designed for writing safe code
for object mutation.

## Immutable States
Many change detection strategies profit from immutable structures.
That recursively means, that if a piece of data needs to be changed,
the parent has to be copied before, to not mutate it and that applies up to the root node.

If `oldNode === newNode` then nothing changed. E.g. for view updates etc. this can be
a great performance boost.

```typescript
// example impl. of a state transition with immutable states

// flat copy or an empty object
const _state = flatcopy(state);

// 1. flat copy or an empty array
// 2. mutation of our `_state` copy
const _persons = _state.persons = flatarraycopy(_state.persons);

// 1. flat copy of an empty object
// 2. mutation of our `_persons` copy
const _person = _persons[personId] = flatcopy(_persons[personId]);
_person.name = personName;

// `_state` is the next state without mutation of any objects
// _state.persons                !== state.persons
// _state.persons[personId]      !== state.persons[personId]
// _state.persons[personId].name !== state.persons[personId].name
```

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