A codemod which makes the array search operation more optimal and efficient, by converting the array into a set and executing the set's has method to find the desired element.
Example
Before
// Initialize an array with some elementsconst array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];// Element to checkconst elementToCheck = 5;// Check if the element exists in the arrayconst isElementInArray = array.includes(elementToCheck);
After
// Initialize an array with some elementsconst array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];// Element to checkconst elementToCheck = 5;// Convert the array into a setconst set = new Set(array);// Check if the element exists in the setconst isElementInSet = set.has(elementToCheck);
Build custom codemods
Use AI-powered codemod studio and automate undifferentiated tasks for yourself, colleagues or the community