UNPKG

bbo

Version:

bbo is a utility library of zero dependencies for javascript.

13 lines (10 loc) 389 B
'use strict'; /** * Replaces all but the last num of characters with the specified mask character. */ var mask = function (cc) { var num = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 4; var mask = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : '*'; return `${cc}`.slice(-num).padStart(`${cc}`.length, mask); }; module.exports = mask;