Skip to content

Instantly share code, notes, and snippets.

@edgvi10
Created Dec 30, 2021
Embed
What would you like to do?
export const mask = function (m, str) {
if (str === undefined || str === null) return '';
var m,
l = (m = m.split("")).length,
s = str.split(""),
j = 0,
h = "";
for (var i = -1; ++i < l;)
if (m[i] != "#") {
if (m[i] == "\\" && (h += m[++i])) continue;
h += m[i];
i + 1 == l && (s[j - 1] += h, h = "");
}
else {
if (!s[j] && !(h = "")) break;
(s[j] = h + s[j++]) && (h = "");
}
return s.join("") + h;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment