Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
.onPatch((patch) => {
// update the data with the provided patch// update the data with the provided patch
console.log('--------------- on patch ---------------');
// console.log('patch: %o', patch);
console.log('patch:');
applyPatch(this.result, patch);
console.log('result patched:');
console.log('--------------- end on patch ---------------');
}, this)
.onError((error: StreamDataError) => {
if (!div) {
throw Error('${el} does not exist');
}
div.classList.add('vega-embed');
if (actions) {
div.classList.add('has-actions');
}
div.innerHTML = ''; // clear container
const patch = opts.patch;
if (patch) {
if (patch instanceof Function) {
vgSpec = patch(vgSpec);
} else {
vgSpec = applyPatch(vgSpec, patch, true, false).newDocument;
}
}
// Set locale. Note that this is a global setting.
if (opts.formatLocale) {
vega.formatLocale(opts.formatLocale);
}
if (opts.timeFormatLocale) {
vega.timeFormatLocale(opts.timeFormatLocale);
}
// Do not apply the config to Vega when we have already applied it to Vega-Lite.
// This call may throw an Error if parsing fails.
const runtime = vega.parse(vgSpec, mode === 'vega-lite' ? {} : config);
router.resourcejs[req.route.path]['get'](childReq, childRes, function(err) {
if (err) {
return res.status(400).send(err);
}
const submission = _.get(childRes, 'resource.item', false);
// No submission exists.
if (!submission) {
return res.sendStatus(404);
}
const patch = req.body;
try {
req.body = jsonPatch.applyPatch(submission, patch, true).newDocument;
return next();
}
catch (err) {
res.status(400).send(err);
}
});
};
.then(function (ret) {
delete ret._id;
// apply patch
jsonpatch.applyPatch( ret, data.patch );
// sanitise
ret = JSON.parse(DOMPurify.sanitize(JSON.stringify(ret))); // sanitize works on strings, not objects
// mark previous as backup
db.get('mri').update({ source: json.source }, { $set: { backup: true }}, { multi: true })
.then(function () {
// insert new
db.get('mri').insert(ret);
});
});
} else {
_patchTarget (path, patches) {
let link = `${path}`;
let result = null;
try {
result = monitor.applyPatch(this.state, patches.map((op) => {
op.path = `${link}${op.path}`;
return op;
})).newDocument;
} catch (E) {
console.log('Could not patch target:', E, path, patches);
}
this.commit();
return result;
}
async _applyChanges (ops) {
try {
monitor.applyPatch(this['@data'], ops);
await this.commit();
} catch (E) {
this.error('Error applying changes:', E);
}
return this;
}
_apply (delta) {
let datastore = this;
let document = monitor.applyPatch(datastore['@data'], delta);
datastore._sign();
document.commit();
this.log('[DATASTORE]', '_apply', 'document:', document);
this.log('[DATASTORE]', '_apply', 'datastore:', datastore);
return datastore['@data'];
}
configFile = path.resolve(configFile);
let baseDir = getBaseDir(configFile);
let config = loadYaml(configFile);
config.baseDir = baseDir;
config.configFile = configFile;
if (!validator.config(config)) {
throw new ValidateError('config', validator.config.errors);
}
if (patch) {
let patchFile = getPatchFile(configFile, patch);
let patchOps = loadYaml(path.resolve(baseDir, patchFile));
if (!validator.patch(patchOps)) {
throw new ValidateError('patch', validator.patch.errors);
}
applyPatch(config, patchOps, false, true);
}
return config;
};
findComponent(form.components, change.key, null, function(component, path) {
found = true;
try {
set(form.components, path, applyPatch(component, change.patches).newDocument);
}
catch (err) {
failed.push(change);
}
});
break;