Skip to content

Commit

Permalink
Remove chain (it needs whole lodash to be imported)
Browse files Browse the repository at this point in the history
  • Loading branch information
Gnito committed May 18, 2018
1 parent 049f6a7 commit 676cf3e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions src/util/richText.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import React from 'react';
import chain from 'lodash/chain';
import flow from 'lodash/flow';
import flatMap from 'lodash/flatMap';
import map from 'lodash/map';
import { ExternalLink } from '../components';

/**
Expand Down Expand Up @@ -125,11 +127,12 @@ export const richText = (text, options) => {
const nonWhiteSpaceSequence = /([^\s]+)/gi;

return text.split(nonWhiteSpaceSequence).reduce((acc, nextChild, i) => {
const parts = chain([nextChild])
.flatMap(w => linkifyOrWrapLinkSplit(w, i, { linkify, linkClass: linkOrLongWordClass }))
.flatMap(w => zwspAroundSpecialCharsSplit(w, '/,'))
.map((w, j) => wrapLongWord(w, `${i}${j}`, { longWordMinLength, longWordClass }))
.value();
const parts = flow([
v =>
flatMap(v, w => linkifyOrWrapLinkSplit(w, i, { linkify, linkClass: linkOrLongWordClass })),
v => flatMap(v, w => zwspAroundSpecialCharsSplit(w, '/,')),
v => map(v, (w, j) => wrapLongWord(w, `${i}${j}`, { longWordMinLength, longWordClass })),
])([nextChild]);
return acc.concat(parts);
}, []);
};

0 comments on commit 676cf3e

Please sign in to comment.