UNPKG

lenye_base

Version:

基础方法

11 lines (9 loc) 374 B
/** * 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); }; export default mask;