MCPcopy Index your code
hub / github.com/dataease/SQLBot / applyOperation

Function applyOperation

frontend/public/swagger-ui-bundle.js:38560–38658  ·  view source on GitHub ↗
(s, o, i, a, u, _)

Source from the content-addressed store, hash-verified

38558 var i = { op: '_get', path: o }
38559 return (applyOperation(s, i), i.value)
38560 }
38561 function applyOperation(s, o, i, a, u, _) {
38562 if (
38563 (void 0 === i && (i = !1),
38564 void 0 === a && (a = !0),
38565 void 0 === u && (u = !0),
38566 void 0 === _ && (_ = 0),
38567 i && ('function' == typeof i ? i(o, 0, s, o.path) : validator(o, 0)),
38568 '' === o.path)
38569 ) {
38570 var w = { newDocument: s }
38571 if ('add' === o.op) return ((w.newDocument = o.value), w)
38572 if ('replace' === o.op) return ((w.newDocument = o.value), (w.removed = s), w)
38573 if ('move' === o.op || 'copy' === o.op)
38574 return (
38575 (w.newDocument = getValueByPointer(s, o.from)),
38576 'move' === o.op && (w.removed = s),
38577 w
38578 )
38579 if ('test' === o.op) {
38580 if (((w.test = _areEquals(s, o.value)), !1 === w.test))
38581 throw new Do('Test operation failed', 'TEST_OPERATION_FAILED', _, o, s)
38582 return ((w.newDocument = s), w)
38583 }
38584 if ('remove' === o.op) return ((w.removed = s), (w.newDocument = null), w)
38585 if ('_get' === o.op) return ((o.value = s), w)
38586 if (i)
38587 throw new Do(
38588 'Operation `op` property is not one of operations defined in RFC-6902',
38589 'OPERATION_OP_INVALID',
38590 _,
38591 o,
38592 s
38593 )
38594 return w
38595 }
38596 a || (s = _deepClone(s))
38597 var x = (o.path || '').split('/'),
38598 C = s,
38599 j = 1,
38600 L = x.length,
38601 B = void 0,
38602 $ = void 0,
38603 U = void 0
38604 for (U = 'function' == typeof i ? i : validator; ; ) {
38605 if (
38606 (($ = x[j]) && -1 != $.indexOf('~') && ($ = unescapePathComponent($)),
38607 u && ('__proto__' == $ || ('prototype' == $ && j > 0 && 'constructor' == x[j - 1])))
38608 )
38609 throw new TypeError(
38610 'JSON-Patch: modifying `__proto__` or `constructor/prototype` prop is banned for security reasons, if this was on purpose, please set `banPrototypeModifications` flag false and pass it to this function. More info in fast-json-patch README'
38611 )
38612 if (
38613 (i &&
38614 void 0 === B &&
38615 (void 0 === C[$] ? (B = x.slice(0, j).join('/')) : j == L - 1 && (B = o.path),
38616 void 0 !== B && U(o, 0, s, B)),
38617 j++,

Callers 4

getValueByPointerFunction · 0.85
applyPatchFunction · 0.85
applyReducerFunction · 0.85

Calls 9

getValueByPointerFunction · 0.85
_areEqualsFunction · 0.85
_deepCloneFunction · 0.85
unescapePathComponentFunction · 0.85
helpers_isIntegerFunction · 0.85
iFunction · 0.70
validatorFunction · 0.70
UFunction · 0.70
isArrayMethod · 0.45

Tested by

no test coverage detected