toolish - v0.2.5
    Preparing search index...

    Function swapOrAddElementBy

    • Replaces the first array element matching the predicate with the given replacement, or else adds it to the end of the array. For your convenience the given replacement value is also passed to the predicate as a second parameter, so you can easily compare the two if needed.

      Type Parameters

      • T

      Parameters

      Returns undefined | T

      the original element if replaced, undefined if added