Skip to content

Commit

Permalink
(code) Prefer findLast over generic reduce.
Browse files Browse the repository at this point in the history
  • Loading branch information
mcsf committed Jan 20, 2020
1 parent 49cd963 commit 7ae05ef
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions packages/rich-text/src/component/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import classnames from 'classnames';
import {
find,
findLast,
isNil,
pickBy,
startsWith,
Expand Down Expand Up @@ -463,13 +464,7 @@ class RichText extends Component {
inputRule( change, this.valueToFormat );
}

const transformed = formatTypes.reduce( ( accumlator, { __unstableInputRule } ) => {
if ( __unstableInputRule ) {
accumlator = __unstableInputRule( accumlator );
}

return accumlator;
}, change );
const transformed = findLast( formatTypes, ( { __unstableInputRule } ) => __unstableInputRule ) || change;

if ( transformed !== change ) {
this.onCreateUndoLevel();
Expand Down

0 comments on commit 7ae05ef

Please sign in to comment.