Untitled
3 years ago in Plain Text
var TEST = function () {
function _isMatch(str, si, ei) {
while (si < ei) {
if (str[si] !== str[ei]) { return false; }
si++;
ei--;
}
return true;
}
return {
doTest: function (str) {
if (!str) { return ''; }
let len = str.length;
const idx = { s: NaN, e: NaN };
while (len > 0) {
idx.s = 0;
idx.e = len - 1;
while (str[idx.e]) {
if (_isMatch(str, idx.s, idx.e)) {
return str.substring(idx.s, idx.e+1);
}
idx.s++;
idx.e++;
}
len--;
}
return str[0];
}
};
}();