@daysnap/utils
Version:
14 lines (10 loc) • 472 B
JavaScript
;Object.defineProperty(exports, "__esModule", {value: true}); function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } }// src/filterString.ts
function filterString(val, sep = "*", start = 0, end) {
return val.split("").map((s, index) => {
if (index >= start && index < (_nullishCoalesce(end, () => ( val.length)))) {
return sep;
}
return s;
}).join("");
}
exports.filterString = filterString;