aboutsummaryrefslogtreecommitdiffstats
path: root/packages
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-02-16 14:54:36 +0800
committerFabio Berger <me@fabioberger.com>2018-02-16 14:54:36 +0800
commit974fab72844d51314f726316d25161e1a8c14cc1 (patch)
treee697433e53441efd59a862476ec97129ed32cf0d /packages
parent8a52ffe7b7d4e2079b119f2c2b5cb885b17f1cd5 (diff)
downloaddexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.tar
dexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.tar.gz
dexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.tar.bz2
dexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.tar.lz
dexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.tar.xz
dexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.tar.zst
dexon-0x-contracts-974fab72844d51314f726316d25161e1a8c14cc1.zip
replace repeated conditionals with variable
Diffstat (limited to 'packages')
-rw-r--r--packages/website/ts/pages/documentation/method_signature.tsx35
1 files changed, 17 insertions, 18 deletions
diff --git a/packages/website/ts/pages/documentation/method_signature.tsx b/packages/website/ts/pages/documentation/method_signature.tsx
index a24d35924..f94524b48 100644
--- a/packages/website/ts/pages/documentation/method_signature.tsx
+++ b/packages/website/ts/pages/documentation/method_signature.tsx
@@ -24,27 +24,26 @@ export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSi
const sectionName = constants.TYPES_SECTION_NAME;
const parameters = renderParameters(props.method, props.docsInfo, sectionName, props.typeDefinitionByName);
const paramStringArray: any[] = [];
+ const hasMoreThenTwoParams = parameters.length > 2;
_.each(parameters, (param: React.ReactNode, i: number) => {
- const finalParam =
- parameters.length > 2 ? (
- <span className="pl2" key={`param-${i}`}>
- {param}
- </span>
- ) : (
- param
- );
+ const finalParam = hasMoreThenTwoParams ? (
+ <span className="pl2" key={`param-${i}`}>
+ {param}
+ </span>
+ ) : (
+ param
+ );
paramStringArray.push(finalParam);
- const comma =
- parameters.length > 2 ? (
- <span key={`param-comma-${i}`}>
- , <br />
- </span>
- ) : (
- ', '
- );
+ const comma = hasMoreThenTwoParams ? (
+ <span key={`param-comma-${i}`}>
+ , <br />
+ </span>
+ ) : (
+ ', '
+ );
paramStringArray.push(comma);
});
- if (parameters.length <= 2) {
+ if (!hasMoreThenTwoParams) {
paramStringArray.pop();
}
const methodName = props.shouldHideMethodName ? '' : props.method.name;
@@ -55,7 +54,7 @@ export const MethodSignature: React.SFC<MethodSignatureProps> = (props: MethodSi
<span style={{ fontSize: 15 }}>
{props.method.callPath}
{methodName}
- {typeParameterIfExists}({parameters.length > 2 && <br />}
+ {typeParameterIfExists}({hasMoreThenTwoParams && <br />}
{paramStringArray})
{props.method.returnType && (
<span>