Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jacobbubu/merged-model
https://github.com/jacobbubu/merged-model
Last synced: 14 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/jacobbubu/merged-model
- Owner: jacobbubu
- License: mit
- Created: 2020-05-06T15:26:25.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T05:11:10.000Z (about 2 years ago)
- Last Synced: 2024-11-22T21:13:51.966Z (2 months ago)
- Language: TypeScript
- Homepage:
- Size: 1.36 MB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 14
-
Metadata Files:
- Readme: README.md
- Contributing: .github/CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
# @jacobbubu/merged-model
[![Build Status](https://github.com/jacobbubu/merged-model/workflows/Build%20and%20Release/badge.svg)](https://github.com/jacobbubu/merged-model/actions?query=workflow%3A%22Build+and+Release%22)
[![Coverage Status](https://coveralls.io/repos/github/jacobbubu/merged-model/badge.svg)](https://coveralls.io/github/jacobbubu/merged-model)
[![npm](https://img.shields.io/npm/v/@jacobbubu/merged-model.svg)](https://www.npmjs.com/package/@jacobbubu/merged-model/)> A subclass of scuttlebutt-pull/model that supports merged values with same key.
## Usage
``` ts
const a = new MergedModel('A')
const b = new MergedModel('B')const s1 = a.createStream({ name: 'a->b' })
const s2 = b.createStream({ name: 'b->a' })a.set('num', 1)
b.set('num', 2)
a.set('foo', { foo: 'one' })
b.set('foo', { bar: 'two' })s2.on('synced', () => {
expect(b.toJSON()).toEqual({ num: 2, foo: { foo: 'one', bar: 'two' } })
done()
})link(s1, s2)
```