Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

funcollate

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

funcollate

A diff & patch tool for immutable state tree

  • 0.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Funcollate

version-widget build-widget bundle-size-widget

A diff & patch tool for immutable state tree.

// local.js
import { diff } from "funcollate";

const prev = {
  name: "counter",
  count: 0
};
const next = {
  name: "counter",
  count: 1
};

const d = diff(prev, next);
send(JSON.stringify(d));

// remote.js
import { patch } from "funcollate";

const prev = {
  name: "counter",
  count: 0
};

const d = JSON.parse(receive());
const next = patch(prev, d);

assert(next.name === "counter");
assert(next.count === 1);
assert(prev.count === 0);

API

diff(prev: T, next: T): Difference

  • @param prev: previous state tree
  • @param next: next state tree
  • @return: an opaque value that represents difference and can be json serialized

Returns difference between prev and next.

patch(prev: T, diff: Difference): T

  • @param prev: previous state tree
  • @param diff: difference generated by diff
  • @return: next state tree

Generates next state tree from prev and diff. Mutates nothing of prev.

Similar

Keywords

FAQs

Package last updated on 21 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc