| 23 | } |
| 24 | |
| 25 | export function eavsToComparables(eavs, entities, index = {}) { |
| 26 | let results = []; |
| 27 | for(let eav of eavs) { |
| 28 | let [e,a,v] = eav; |
| 29 | let cur = index[e]; |
| 30 | if(!index[e]) { |
| 31 | cur = index[e] = {list: [], links: [], e}; |
| 32 | results.push(cur); |
| 33 | } |
| 34 | if(entities[v]) { |
| 35 | cur.links.push([a, v]); |
| 36 | } else { |
| 37 | let avKey = `${a}, ${v}`; |
| 38 | cur.list.push(avKey); |
| 39 | } |
| 40 | } |
| 41 | return results; |
| 42 | } |
| 43 | |
| 44 | // Tests if the elements of `as` are in `bs` by comparing keys in a list. In |
| 45 | // the case of floating points, we want the comparison to be looser, to account |