q247-models-core
Version:
Models for effort/calories in q247 plugin
2 lines (1 loc) • 1.02 kB
JavaScript
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self)["q247-models-core"]={})}(this,function(e){"use strict";e.fmwFactor=(e,t=377,i=610,s=100)=>{if(e<t)return e;return i-(i-t)/(1+(e-t)/s)},e.parseGitDiff=e=>{const t={},i=e.split("\n");let s=null,n=[],o=[],f=[],l=!1;for(let e=0;e<i.length;e++){const r=i[e];if(r.startsWith("diff --git")){l=!1,n=[],o=[],f=[];const e=r.match(/^diff --git a\/(.+?) b\/(.+)$/);e&&(s=e[1],t[s]={original:"",resulting:"",changed:[]});continue}if(r.startsWith("@@"))l=!0;else if(l&&s)if(r.startsWith("-")){const e=r.slice(1);n.push(e),f.push({type:"removed",line:e})}else if(r.startsWith("+")){const e=r.slice(1);o.push(e),f.push({type:"added",line:e})}else if(r.startsWith(" ")){const e=r.slice(1);n.push(e),o.push(e)}}return s&&(t[s].original=n.join("\n"),t[s].resulting=o.join("\n"),t[s].changed=f),t},Object.defineProperty(e,"__esModule",{value:!0})});