UNPKG

@joergmittaglawo/dmvconfig

Version:

DMV Configuration scripts for Lawo V__matrix Distributed Multiviewers.

1 lines 961 B
Object.defineProperty(exports,"__esModule",{value:!0}),exports.rate_alternatives=void 0,exports.rate_alternatives=function(t,e,n){var r,l;const o=null===(r=null==n?void 0:n.sort)||void 0===r||r,a=null!==(l=null==n?void 0:n.cutoff)&&void 0!==l?l:.5,i={};for(let e=0;e<t.length;++e)i.hasOwnProperty(t[e])?i[t[e]].push(e):i[t[e]]=[e];const f=e=>{const n=(Math.max(t.length,e.length)>>1)-1,r=new Array(t.length).fill(!1),l=new Array(e.length).fill(!1);let o=0;for(let a=0;a<Math.min(e.length,t.length+n);++a)if(i.hasOwnProperty(e[a]))for(const t of i[e[a]])if(!r[t]&&Math.abs(t-a)<=n){r[t]=!0,l[a]=!0,o+=1;break}if(0===o)return 0;let a=0,f=0;for(let n=0;n<e.length;++n)if(l[n]){for(;!r[a];)a+=1;t[a]!==e[n]&&(f+=1),a+=1}const h=(o/t.length+o/e.length+(o-.5*f)/o)/3;let s=0;for(let t=0;t<4&&t<r.length&&t<l.length&&r[t]==l[t];++t)s+=1;return h+.1*s*(1-h)};let h=e.map(t=>({...t,rating:f(t.key)})).filter(t=>t.rating>=a);return o&&h.sort((t,e)=>e.rating-t.rating),h};