# @zalelion/immutable-object

> ## Install

Latest version **0.0.6** (published 2019-10-11) · ISC license · 0 weekly downloads

## Install

```sh
npm install @zalelion/immutable-object
pnpm add @zalelion/immutable-object
yarn add @zalelion/immutable-object
bun add @zalelion/immutable-object
```

## 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.6 |
| Published | 2019-10-11 |
| First published | 2019-09-30 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 5 |
| Unpacked size | 46.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | leozale |

## Links

- npm: https://www.npmjs.com/package/@zalelion/immutable-object
- Repository: https://github.com/zalelion/immutable-object
- Homepage: https://github.com/zalelion/immutable-object#readme
- Issues: https://github.com/zalelion/immutable-object/issues
- npm.io page: https://npm.io/package/@zalelion/immutable-object

## Dependencies (5)

- [lodash](https://npm.io/package/lodash.md) ^4.17.15
- [@cqrsfk/ob](https://npm.io/package/@cqrsfk/ob.md) ^0.0.16
- [immutability-helper](https://npm.io/package/immutability-helper.md) ^3.0.1
- [@cqrsfk/ob-middle-sync](https://npm.io/package/@cqrsfk/ob-middle-sync.md) ^0.0.2
- [@cqrsfk/ob-middle-change](https://npm.io/package/@cqrsfk/ob-middle-change.md) ^0.0.3

## Recent versions

- 0.0.6 (latest) — 2019-10-11
- 0.0.5 — 2019-10-03
- 0.0.4 — 2019-10-03
- 0.0.3 — 2019-10-02
- 0.0.2 — 2019-10-02
- 0.0.1 — 2019-09-30

## README

# immutable-object

## Install

    yarn add @zalelion/immutable-object

## Example

```ts
import { sync } from "../src/index";

const obj = {
    name: "hello",
    change(name) {
        this.name = name;
    },
    set: new Set,
    map: new Map,
    sub: { arr: ["1", "2", "333", "44444", "555555"] }
}

const [proxy, unlisten] = sync<typeof obj>(obj, newobj => console.log(newobj));
proxy.map.set("a", "2");

```

Output:
```
{ ...
  map: Map { 'a' => '2' }
}
```

And:

```ts
proxy.change("lion");
```

Output:
```
{ name: 'lion',
  ...
}
```

## API

```ts
import { sync } from "../src/index";

const [obj_proxy , unsubscribe] = sync(obj, cb);
```

+ `obj` is a object.
+ `cb(newImmutableObj)` when obj changed , then callback return a immutable object.
+ `obj_proxy` is a *Proxy* , call it to  `cb(newImmutableObj)`
+ `unsubscribe` is a function, stop subscribe obj change event.

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