# observejs

> Watch a Javascript object for changes and stream changes to another object

Latest version **0.0.2** (published 2013-06-17) · BSD license · 0 weekly downloads

## Install

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

## 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.2 |
| Published | 2013-06-17 |
| First published | 2013-06-16 |
| Weekly downloads | 0 |
| License | BSD |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Eugene Ware |
| Maintainers | eugeneware |
| Keywords | Object.observe, object, observe, watch, json, levelup, leveldb |

## Links

- npm: https://www.npmjs.com/package/observejs
- Repository: https://github.com/eugeneware/observejs
- npm.io page: https://npm.io/package/observejs

## Dependencies (2)

- [through](https://npm.io/package/through.md) ~2.3.4
- [changeset](https://npm.io/package/changeset.md) 0.0.5

## 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.0.2 (latest) — 2013-06-17
- 0.0.1 — 2013-06-16

## README

# observejs

Watch a Javascript object for changes and stream changes to another object
using node.js Streams.

# Installation

Install with npm:

```
$ npm install observejs
```

# Example

``` js
var observejs = require('observejs');

// the source object
var o = {
  name: 'Eugene',
  number: 42,
  tags: ['tag1', 'tag2', 'tag3'],
  cars: [
    {
      make: 'Toyota',
      model: 'Camry'
    },
    {
      make: 'Toyota',
      model: 'Corolla'
    }
  ]
};

// deep clone of o
var o2 = JSON.parse(JSON.stringify(o));

// Replicate any changes to o2
observejs.observe(o)
  .pipe(observejs.changes(o2));

// Make some changes to the source object
o.name = 'Susan';
o.number = 43;
o.number = undefined;
o.cars[0].make = 'Holden';
o.cars.push({
  make: 'BMW',
  model: 'M3'
});

// o and o2 should be equal
expect(o2).to.deep.equals(o);
```

## methods

``` js
var observejs = require('observerjs');
```

### observejs.observe(src)

Watch the object ```src``` for any changes. Returns a stream which can be used
with ```observerjs.changes(dest)``` to keep another object in sync.

### observejs.unobserve(src)

Stop watching the object ```src```.

### observejs.changes(dest)

Stream which takes the data from an ```observerjs.observer(src)``` and keeps
the target object ```dest``` in sync with the source.

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