Tiny asynchronous state management based on static data stitching
npm install cagibiAddition-only asynchronous state based on static data stitching
``js
import { make } from 'cagibi';
// Create a stitchable copy of your object
const profile = make({ name: 'Joe', posts: [] });
// Use your object as a reference to stitch a sub-object
const post = make({ title: 'A new post' }, profile.posts);
// Stitch them all to get the final object
const stitched = stitch(profile, post);
// => { name: 'Joe', posts: [{ title: 'A new post' }] }
`
npm i cagibi / yarn add cagibi


Cagibi's name comes from the french word used to call a small storeroom. Pronounced /kä'jēbē/.
and stitch.
- Two more methods to use it with persisted state or through remote channels: write and read.
- Some utilities like protect(target, ...keys) to forbid changes on keys.
- And a Patches array-based class to help handling all patches to be stitched back into one object.
- No store.
- No complex API.
- Fully extendable.
- Intends to work with all native objects.$3
Merging nested data structure through async channels (API, parallel threads or job queues) without willing to maintain a key-value store with primary keys linking records.
$3
`js
import { make } from 'cagibi';const profile = make({ name: 'Joe', posts: [] });
// => { name: 'Joe', posts: [] }
`$3
`js
const post = make({ title: 'A new post' }, profile.posts);
`
$3
`js
import { stitch } from 'cagibi';const stitched = stitch(profile, post);
`Returns stitched state:
`json
{
"name": "Joe",
"posts": [{ "title": "A new post" }]
}
`
$3
`js
import { make, stitch, write, read } from 'cagibi';const stack = [];
const profile = make({ name: 'Joe', posts: [] });
const post = make({ title: 'A new post' }, profile.posts);
stack.push(write(profile));
stack.push(write(post));
// ...
// And only later on or in another environment
const profile = read(profileWritten);
const post = read(postWritten);
const stitched = stitch(profile, post);
`Returns stitched state:
`json
{
"name": "Joe",
"posts": [{ "title": "A new post" }]
}
`$3
`js
import { make, stitch, write, read, Patches } from 'cagibi';const patches = new Patches();
const profile = make({ name: 'Joe', posts: [] });
const post = make({ title: 'A new post' }, profile.posts);
patches.push(profile, post);
const savedPatches = patches.write();
// ...
// And only later on or in another environment
const importedPatches = new Patches();
importedPatches.read(savedPatches);
const stitched = importedPatches.stitch();
`Returns stitched state:
`json
{
"name": "Joe",
"posts": [{ "title": "A new post" }]
}
``