MCPcopy
hub / github.com/williamngan/pts / C

Function C

demo/edit/vs/editor/editor.main.js:121–121  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

119;return(e?n.startsWithIgnoreCase(i,t):0===i.indexOf(t))?t.length>0?[{start:0,end:t.length}]:[]:null}function s(e,t){var n=t.toLowerCase().indexOf(e.toLowerCase());return-1===n?null:[{start:n,end:n+e.length}]}function a(e,t){return l(e.toLowerCase(),t.toLowerCase(),0,0)}function l(e,t,n,i){if(n===e.length)return[];if(i===t.length)return null;if(e[n]===t[i]){var o=null;return(o=l(e,t,n+1,i+1))?f({start:i,end:i+1},o):null}return l(e,t,n,i+1)}function u(e){return 97<=e&&e<=122}function c(e){return 65<=e&&e<=90}function d(e){return 48<=e&&e<=57}function h(e){return 32===e||9===e||10===e||13===e}function p(e){return u(e)||c(e)||d(e)}function f(e,t){return 0===t.length?t=[e]:e.end===t[0].start?t[0].start=e.start:t.unshift(e),t}function g(e,t){for(var n=t;n<e.length;n++){var i=e.charCodeAt(n);if(c(i)||d(i)||n>0&&!p(e.charCodeAt(n-1)))return n}return e.length}function m(e,t,n,i){if(n===e.length)return[];if(i===t.length)return null;if(e[n]!==t[i].toLowerCase())return null;var o=null,r=i+1
120;for(o=m(e,t,n+1,i+1);!o&&(r=g(t,r))<t.length;)o=m(e,t,n+1,r),r++;return null===o?null:f({start:i,end:i+1},o)}function v(e,t){if(!t)return null;if(0===(t=t.trim()).length)return null;if(!function(e){for(var t=0,n=0,i=0,o=0,r=0;r<e.length;r++)c(i=e.charCodeAt(r))&&t++,u(i)&&n++,h(i)&&o++;return 0!==t&&0!==n||0!==o?t<=5:e.length<=30}(e))return null;if(t.length>60)return null;var n=function(e){for(var t=0,n=0,i=0,o=0,r=0,s=0;s<e.length;s++)c(r=e.charCodeAt(s))&&t++,u(r)&&n++,p(r)&&i++,d(r)&&o++;return{upperPercent:t/e.length,lowerPercent:n/e.length,alphaPercent:i/e.length,numericPercent:o/e.length}}(t);if(!function(e){var t=e.upperPercent,n=e.lowerPercent,i=e.alphaPercent,o=e.numericPercent;return n>.2&&t<.8&&i>.6&&o<.2}(n)){if(!function(e){var t=e.upperPercent;return 0===e.lowerPercent&&t>.6}(n))return null;t=t.toLowerCase()}for(var i=null,o=0;o<t.length&&null===(i=m(e.toLowerCase(),t,0,o));)o=g(t,o+1);return i}function _(e,t,n,i,o){if(n===e.length)return[];if(i===t.length)return null
121;if(e[n]!==t[i].toLowerCase())return null;var r=null,s=i+1;if(r=_(e,t,n+1,i+1,o),!o)for(;!r&&(s=y(t,s))<t.length;)r=_(e,t,n+1,s,o),s++;return null===r?null:f({start:i,end:i+1},r)}function y(e,t){for(var n=t;n<e.length;n++){if(h(e.charCodeAt(n))||n>0&&h(e.charCodeAt(n-1)))return n}return e.length}function C(){for(var e=[],t=[0],n=1;n<=100;n++)t.push(-n);for(n=0;n<=100;n++){var i=t.slice(0);i[0]=-n,e.push(i)}return e}function b(e,t,n,i,o){function r(e,t,n){for(void 0===n&&(n=" ");e.length<t;)e=n+e;return e}for(var s=" | |"+i.split("").map(function(e){return r(e,3)}).join("|")+"\n",a=0;a<=n;a++)s+=0===a?" |":t[a-1]+"|",s+=e[a].slice(0,o+1).map(function(e){return r(e.toString(),3)}).join("|")+"\n";return s}function S(e,t){if(t<0||t>=e.length)return!1;switch(e.charCodeAt(t)){case 95:case 45:case 46:case 32:case 47:case 92:case 39:case 34:case 58:return!0;default:return!1}}function w(e,t){if(t<0||t>=e.length)return!1;switch(e.charCodeAt(t)){case 32:case 9:return!0;default:return!1}}function E(e,t,n){
122var i=e.length>100?100:e.length,o=t.length>100?100:t.length,r=0;for(void 0===n&&(n=i);r<n&&w(e,r);)r+=1;if(r===i)return[-100,[]];if(!(i>o)){for(var s=e.toLowerCase(),a=t.toLowerCase(),l=r,u=0;l<i&&u<o;)s[l]===a[u]&&(l+=1),u+=1;if(l===i){for(l=r+1;l<=i;l++)for(u=1;u<=o;u++){var c=-1,d=a[u-1];s[l-1]===d&&(c=u===l-r?e[l-1]===t[u-1]?7:5:d!==t[u-1]?e[l-1]===t[u-1]?7:5:S(a,u-2)||w(a,u-2)?5:1),M[l][u]=c;var h=D[l-1][u-1]+(c>1?1:c),p=D[l-1][u]+-1,f=D[l][u-1]+-1;f>=p?f>h?(D[l][u]=f,k[l][u]=4):f===h?(D[l][u]=f,k[l][u]=6):(D[l][u]=h,k[l][u]=2):p>h?(D[l][u]=p,k[l][u]=1):p===h?(D[l][u]=p,k[l][u]=3):(D[l][u]=h,k[l][u]=2)}if(O&&(console.log(b(D,e,i,t,o)),console.log(b(k,e,i,t,o)),console.log(b(M,e,i,t,o))),P=0,A=-100,F=r,L(i,o,i===o?1:0,new W,!1),0!==P)return[A,R.toArray()]}}}function L(e,t,n,i,o){if(!(P>=10||n<-25)){for(var r=0;e>F&&t>0;){var s=M[e][t],a=k[e][t];if(4===a)t-=1,o?n-=5:i.isEmpty()||(n-=1),o=!1,r=0;else{if(!(2&a))return;if(4&a&&L(e,t-1,i.isEmpty()?n:n-1,i.slice(),o),n+=s,e-=1,t-=1,i.unshift(t),o=!0,1===s){
123if(r+=1,e===F)return}else n+=1+r*(s-1),r=0}}P+=1,(n-=t>=3?9:3*t)>A&&(A=n,R=i)}}function x(e,t,n,i){var o=E(e,t,i);if(o&&!n)return o;if(e.length>=3)for(var r=Math.min(7,e.length-1),s=1;s<r;s++){var a=function(e,t){if(t+1>=e.length)return;var n=e[t],i=e[t+1];if(n===i)return;return e.slice(0,t)+i+n+e.slice(t+2)}(e,s);if(a){var l=E(a,t,i);l&&(l[0]-=3,(!o||l[0]>o[0])&&(o=l))}}return o}Object.defineProperty(t,"__esModule",{value:!0}),t.or=o,t.matchesStrictPrefix=r.bind(void 0,!1),t.matchesPrefix=r.bind(void 0,!0),t.matchesContiguousSubString=s,t.matchesSubString=a,t.isUpper=c,t.matchesCamelCase=v,t.matchesWords=function(e,t,n){if(void 0===n&&(n=!1),!t||0===t.length)return null;for(var i=null,o=0;o<t.length&&null===(i=_(e.toLowerCase(),t,0,o,n));)o=y(t,o+1);return i},t.fuzzyContiguousFilter=o(t.matchesPrefix,v,s);var I=o(t.matchesPrefix,v,a),N=new i.LRUCache(1e4);t.matchesFuzzy=function(e,i,o){if(void 0===o&&(o=!1),"string"!=typeof e||"string"!=typeof i)return null;var r=N.get(e)
124;r||(r=new RegExp(n.convertSimple2RegExpPattern(e),"i"),N.set(e,r));var s=r.exec(i);return s?[{start:s.index,end:s.index+s[0].length}]:o?I(e,i):t.fuzzyContiguousFilter(e,i)},t.skipScore=function(e,t,n){e=e.toLowerCase(),t=t.toLowerCase();for(var i=[],o=0,r=0;r<e.length;++r){var s=t.indexOf(e.charAt(r),o);s>=0&&(i.push(s),o=s+1)}return[i.length,i]},t.createMatches=function(e){var t=[];if(!e)return t;for(var n,i=0,o=e;i<o.length;i++){var r=o[i];n&&n.end===r?n.end+=1:(n={start:r,end:r+1},t.push(n))}return t};var T,D=C(),M=C(),k=C(),O=!1;!function(e){e[e.Top=1]="Top",e[e.Diag=2]="Diag",e[e.Left=4]="Left"}(T||(T={})),t.fuzzyScore=E;var R,P=0,A=0,F=0,W=function(){function e(){}return e.prototype.isEmpty=function(){return!this._data&&(!this._parent||this._parent.isEmpty())},e.prototype.unshift=function(e){this._data?this._data.unshift(e):this._data=[e]},e.prototype.slice=function(){var t=new e;return t._parent=this,t._parentLen=this._data?this._data.length:0,t},e.prototype.toArray=function(){

Callers 6

cFunction · 0.70
hFunction · 0.70
editor.main.jsFile · 0.70
dFunction · 0.70
bFunction · 0.70
yFunction · 0.70

Calls 5

mapMethod · 0.80
yFunction · 0.70
_Function · 0.70
vFunction · 0.70
maxMethod · 0.45

Tested by

no test coverage detected