@technobuddha/library
Version:
A large library of useful functions
28 lines (27 loc) • 866 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.splice = void 0;
var constants_1 = require("../constants");
/**
* Insert a substring into a string
*
* @param input The string
* @param start The position which to insert the substring
* @param deleteCount The number of characters to delete
* @param items The substring(s) to insert
* @returns The modified strings
*/
function splice(input, start, deleteCount) {
var items = [];
for (var _i = 3; _i < arguments.length; _i++) {
items[_i - 3] = arguments[_i];
}
if (start < 0) {
start = input.length + start + 1;
if (start < 0)
start = 0;
}
return input.slice(0, start) + items.join(constants_1.empty) + input.slice(start + (deleteCount < 0 ? 0 : deleteCount));
}
exports.splice = splice;
exports.default = splice;