MCPcopy Index your code
hub / github.com/witheve/Eve / recordToEAVs

Function recordToEAVs

src/client.ts:418–449  ·  view source on GitHub ↗
(record)

Source from the content-addressed store, hash-verified

416//---------------------------------------------------------
417
418function recordToEAVs(record) {
419 if(!record) return;
420 let eavs:EAV[] = [];
421 if(record.id && record.id.constructor === Array) throw new Error("Unable to apply multiple ids to the same record: " + JSON.stringify(record));
422 if(!record.id) record.id = uuid();
423 record.id = "" + record.id + "";
424 let e = record.id;
425
426 for(let a in record) {
427 if(record[a] === undefined) continue;
428 if(a === "id") continue;
429 if(record[a].constructor === Array) {
430 for(let v of record[a]) {
431 if(typeof v === "object") {
432 eavs.push.apply(eavs, recordToEAVs(v));
433 eavs.push([e, a, v.id]);
434 } else if(v !== undefined) {
435 eavs.push([e, a, v]);
436 }
437 }
438 } else {
439 let v = record[a];
440 if(typeof v === "object") {
441 eavs.push.apply(eavs, recordToEAVs(v));
442 eavs.push([e, a, v.id]);
443 } else if(v !== undefined) {
444 eavs.push([e, a, v]);
445 }
446 }
447 }
448 return eavs;
449}
450
451//---------------------------------------------------------
452// Initialize an IDE

Callers 1

sendEventMethod · 0.85

Calls 2

uuidFunction · 0.90
applyMethod · 0.45

Tested by

no test coverage detected