Created
December 30, 2021 16:21
-
-
Save edgvi10/0fc238ad30090559b9bbf2295f9f3c36 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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