diff options
author | Fabio Berger <me@fabioberger.com> | 2018-03-23 00:10:01 +0800 |
---|---|---|
committer | Fabio Berger <me@fabioberger.com> | 2018-03-23 00:10:01 +0800 |
commit | 81f6487865faad641108a566f3f717311ee43a0b (patch) | |
tree | b2f8385600b43589f608c32b699c5f215b4276d5 /packages/react-docs | |
parent | 21b797c3f98e66b0a13b96975df723946ff30999 (diff) | |
download | dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.tar dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.tar.gz dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.tar.bz2 dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.tar.lz dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.tar.xz dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.tar.zst dexon-sol-tools-81f6487865faad641108a566f3f717311ee43a0b.zip |
Use _.filter instead of _.reduce
Diffstat (limited to 'packages/react-docs')
-rw-r--r-- | packages/react-docs/src/utils/typedoc_utils.ts | 12 |
1 files changed, 4 insertions, 8 deletions
diff --git a/packages/react-docs/src/utils/typedoc_utils.ts b/packages/react-docs/src/utils/typedoc_utils.ts index fff27a834..21f2dcabb 100644 --- a/packages/react-docs/src/utils/typedoc_utils.ts +++ b/packages/react-docs/src/utils/typedoc_utils.ts @@ -85,14 +85,10 @@ export const typeDocUtils = { let entities; let packageComment = ''; // HACK: We assume 1 exported class per file - const numClassChildren = _.reduce( - packageDefinitionWithMergedChildren.children, - (sum: number, child: TypeDocNode) => { - const nextSum = child.kindString === KindString.Class ? sum + 1 : sum; - return nextSum; - }, - ); - if (numClassChildren > 1) { + const classChildren = _.filter(packageDefinitionWithMergedChildren.children, (child: TypeDocNode) => { + return child.kindString === KindString.Class; + }); + if (classChildren.length > 1) { throw new Error('`react-docs` only supports projects with 1 exported class per file'); } const isClassExport = packageDefinitionWithMergedChildren.children[0].kindString === KindString.Class; |