
Product
Announcing Socket Fix 2.0
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
ot-json1-immutable
Advanced tools
This module add supports for Immutable.js structures to ot-json1
.
yarn add ot-json1-immutable ot-json1 immutable
Just import json from ot-json1-immutable
and use it exactly like specified by ot-json1
documentation. Use applyImmutable
to actually apply operations to any immutable structure.
import json1 from 'ot-json1-immutable';
import { Map } from 'immutable';
const op = json1.moveOp(['a'], ['b']);
let doc = new Map({ a: 1 });
doc = json1.type.applyImmutable(doc, op);
// doc => new Map({ b: 1 })
applyImmutable
function also take a reviver, used by Immutable's fromJS
:
function reviver(key, value) => {
if (!isKeyed(value)) {
return value.toList();
}
switch (value.get('object')) {
case 'block':
return Block.create(value.toJS());
default:
return value.toMap();
}
}
const op = json1.insertOp(['a'], { object: 'block' });
let doc = new Map({});
doc = json1.type.applyImmutable(doc, op, reviver);
// doc.get('a') => new Block()
FAQs
Add Immutable.js support to ot-json1
The npm package ot-json1-immutable receives a total of 0 weekly downloads. As such, ot-json1-immutable popularity was classified as not popular.
We found that ot-json1-immutable demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Product
Socket Fix 2.0 brings targeted CVE remediation, smarter upgrade planning, and broader ecosystem support to help developers get to zero alerts.
Security News
Socket CEO Feross Aboukhadijeh joins Risky Business Weekly to unpack recent npm phishing attacks, their limited impact, and the risks if attackers get smarter.
Product
Socket’s new Tier 1 Reachability filters out up to 80% of irrelevant CVEs, so security teams can focus on the vulnerabilities that matter.