MCPcopy Create free account
hub / github.com/json-editor/json-editor / optimizeNodes

Method optimizeNodes

docs/scripts/ajv-validator.js:912–932  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

910 return code;
911 }
912 optimizeNodes() {
913 super.optimizeNodes();
914 const cond = this.condition;
915 if (cond === true)
916 return this.nodes; // else is ignored here
917 let e = this.else;
918 if (e) {
919 const ns = e.optimizeNodes();
920 e = this.else = Array.isArray(ns) ? new Else(ns) : ns;
921 }
922 if (e) {
923 if (cond === false)
924 return e instanceof If ? e : e.nodes;
925 if (this.nodes.length)
926 return this;
927 return new If(not(cond), e instanceof If ? [e] : e.nodes);
928 }
929 if (cond === false || !this.nodes.length)
930 return undefined;
931 return this;
932 }
933 optimizeNames(names, constants) {
934 var _a;
935 this.else = (_a = this.else) === null || _a === void 0 ? void 0 : _a.optimizeNames(names, constants);

Callers 3

optimizeNodesMethod · 0.45
optimizeNodesMethod · 0.45
optimizeMethod · 0.45

Calls 1

notFunction · 0.85

Tested by

no test coverage detected