Registry
E

e18e/@e18e/array.prototype.find

No description available

e18e37 executions

  • Legacy
  • e18e
  • module-replacement
Connect a repo
npx codemod @e18e/array.prototype.find

Array.prototype.find Codemod

Introduction

This codemod replaces instances of using a custom implementation to find elements in an array with the built-in Array.prototype.find method. By utilizing native JavaScript features, it reduces unnecessary dependencies and improves the performance and readability of the codebase.

Before

javascript
const findElement = (array, predicate) => {
  for (let i = 0; i < array.length; i++) {
    if (predicate(array[i])) {
      return array[i];
    }
  }
  return undefined;
};

const result = findElement(myArray, element => element.id === 1);

After

javascript
const result = myArray.find(element => element.id === 1);

Ready to evolve your codebase?

Build tailored, compiler-aware skills to assess, plan, and automate complex codebase changes.