All files / src/commands/contract namespace.ts

75% Statements 6/8
81.81% Branches 9/11
50% Functions 2/4
71.42% Lines 5/7

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 255115x   1x     1x             2x         16x              
import * as ts from 'typescript'
 
import {capitalize} from '@wharfkit/contract'
 
// Generates a namespace name for a contract (eg. _EosioToken for eosio.token)
export function generateNamespaceName(contractName: string) {
    return contractName
        .split('.')
        .map((namePart) => capitalize(namePart))
        .join('')
}
 
export function generateNamespace(
    namespaceName: string,
    children,
    isExport = true
): ts.ModuleDeclaration {
    return ts.factory.createModuleDeclaration(
        isExport ? [ts.factory.createModifier(ts.SyntaxKind.ExportKeyword)] : [], // modifiers
        ts.factory.createIdentifier(namespaceName),
        ts.factory.createModuleBlock(children),
        ts.NodeFlags.Namespace
    )
}