Move spawnSwitchErr to @0xproject/utils

This commit is contained in:
Fabio Berger
2018-06-06 16:26:04 +02:00
parent af1d5fce6e
commit cf8fdd3a70
15 changed files with 24 additions and 25 deletions

View File

@@ -3,7 +3,6 @@ import * as _ from 'lodash';
import * as React from 'react';
import { CustomType } from '../types';
import { utils } from '../utils/utils';
const STRING_ENUM_CODE_PREFIX = ' strEnum(';

View File

@@ -29,7 +29,6 @@ import {
TypescriptMethod,
} from '../types';
import { constants } from '../utils/constants';
import { utils } from '../utils/utils';
import { Badge } from './badge';
import { Comment } from './comment';

View File

@@ -1,4 +1,5 @@
import { colors, constants as sharedConstants, utils as sharedUtils } from '@0xproject/react-shared';
import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import * as React from 'react';
import { Link as ScrollLink } from 'react-scroll';
@@ -7,7 +8,6 @@ import * as ReactTooltip from 'react-tooltip';
import { DocsInfo } from '../docs_info';
import { Type as TypeDef, TypeDefinitionByName, TypeDocTypes } from '../types';
import { constants } from '../utils/constants';
import { utils } from '../utils/utils';
import { Signature } from './signature';
import { TypeDefinition } from './type_definition';
@@ -140,7 +140,7 @@ export function Type(props: TypeProps): any {
break;
default:
throw utils.spawnSwitchErr('type.typeDocType', type.typeDocType);
throw errorUtils.spawnSwitchErr('type.typeDocType', type.typeDocType);
}
// HACK: Normalize BigNumber to simply BigNumber. For some reason the type
// name is unpredictably one or the other.

View File

@@ -1,11 +1,11 @@
import { AnchorTitle, colors, HeaderSizes } from '@0xproject/react-shared';
import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import * as React from 'react';
import { DocsInfo } from '../docs_info';
import { CustomType, CustomTypeChild, EnumValue, KindString, TypeDocTypes } from '../types';
import { constants } from '../utils/constants';
import { utils } from '../utils/utils';
import { Comment } from './comment';
import { CustomEnum } from './custom_enum';
@@ -96,7 +96,7 @@ export class TypeDefinition extends React.Component<TypeDefinitionProps, TypeDef
break;
default:
throw utils.spawnSwitchErr('type.kindString', customType.kindString);
throw errorUtils.spawnSwitchErr('type.kindString', customType.kindString);
}
const typeDefinitionAnchorId = `${this.props.sectionName}-${customType.name}`;

View File

@@ -1,3 +1,4 @@
import { errorUtils } from '@0xproject/utils';
import * as _ from 'lodash';
import { DocsInfo } from '../docs_info';
@@ -19,7 +20,6 @@ import {
TypescriptFunction,
TypescriptMethod,
} from '../types';
import { utils } from '../utils/utils';
export const typeDocUtils = {
isType(entity: TypeDocNode): boolean {
@@ -197,7 +197,7 @@ export const typeDocUtils = {
break;
default:
throw utils.spawnSwitchErr('kindString', entity.kindString);
throw errorUtils.spawnSwitchErr('kindString', entity.kindString);
}
});
return docSection;

View File

@@ -1,5 +0,0 @@
export const utils = {
spawnSwitchErr(name: string, value: any): Error {
return new Error(`Unexpected switch value: ${value} encountered for ${name}`);
},
};