Skip to content

Commit

Permalink
Replace flatMap with reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
inokawa committed Oct 17, 2020
1 parent 24a92df commit 2c9a98a
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/remark-slate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ function createSlateNode(
case "strong":
case "delete": {
const { type, children } = node;
return children.flatMap((n) =>
createSlateNode(n, { ...decoration, [type]: true })
);
return children.reduce<SlateNode[]>((acc, n) => {
acc.push(...createSlateNode(n, { ...decoration, [type]: true }));
return acc;
}, []);
}
case "inlineCode": {
const { type, value } = node;
Expand Down

0 comments on commit 2c9a98a

Please sign in to comment.