@polkadot/util#stringCamelCase TypeScript Examples

The following examples show how to use @polkadot/util#stringCamelCase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: MessageSignature.tsx    From crust-apps with Apache License 2.0 5 votes vote down vote up
function MessageSignature ({ className, message: { args, identifier, isConstructor, isMutating, returnType }, params = [], withTooltip = false }: Props): React.ReactElement<Props> {
  const { t } = useTranslation();

  return (
    <div className={className}>
      <span className='ui--MessageSignature-name'>{stringCamelCase(identifier)}</span>
      {' '}({args.map(({ name, type }, index): React.ReactNode => {
        return (
          <React.Fragment key={`${name}-args-${index}`}>
            {name}:
            {' '}
            <span className='ui--MessageSignature-type'>
              {params && params[index]
                ? <b>{truncate((params as string[])[index].toString())}</b>
                : encodeTypeDef(type)
              }
            </span>
            {index < (args.length) - 1 && ', '}
          </React.Fragment>
        );
      })})
      {(!isConstructor && returnType) && (
        <>
          :
          {' '}
          <span className='ui--MessageSignature-returnType'>
            {encodeTypeDef(returnType)}
          </span>
        </>
      )}
      {isMutating && (
        <>
          <Icon
            className='ui--MessageSignature-mutates'
            icon='database'
            tooltip={`mutates-${identifier}`}
          />
          {withTooltip && (
            <Tooltip
              text={t<string>('Mutates contract state')}
              trigger={`mutates-${identifier}`}
            />
          )}
        </>
      )}
    </div>
  );
}
Example #2
Source File: string.ts    From gear-js with GNU General Public License v3.0 5 votes vote down vote up
export function toCamelCase(array: string[] | Text[]): string {
  let result = stringCamelCase(array.join('_'));
  result = result.slice(0, 1).toUpperCase() + result.slice(1, result.length);
  return result;
}