Utility Methods
has(value)– Check if value exists.get(index)– Get value by index.indexOf(value)– Find index of value.clone()– Create a new instance with same array and options.diff(prevArray)– Compare current array with a previous array (added/removed).merge(values)– Merge multiple strings with duplicate/limit handling.getPage(pageNum, pageSize)– Paginate array.
Example Usage
1const manager = new StringArrayManager(["apple", "banana"], { caseInsensitive: true });3// Add strings4manager.add("Cherry");5manager.addBulk(["Date", "Fig"]);7// Remove strings8manager.remove("banana");10// Replace strings11manager.replace("apple", "Apricot");13// Undo / Redo14manager.undo();15manager.redo();17// Search18manager.search(/a/i);20// Pagination21manager.getPage(1, 2);23// Stats24manager.stats();26// Event listening27manager.on("add", ({ value }) => console.log("Added:", value));29// Logging30manager.enableLogging(true);31console.log(manager.getLog());
StringArrayManager is ideal for managing dynamic lists of strings with full control, safe operations, history tracking, and extensibility.