import { cstr , indent } from './strings' ; see https param module param whatToImport param importType example export function createImport ( module ) ; export function createImport ( module , importType , whatToImport ) ; export function createImport ( module , importType , namedImports ) ; export function createImport ( module , importType , whatToImport ) ; export function createImport ( module , importType ? , whatToImport ? ) { if ( ! whatToImport ) { return `import '${ module }';` ; } else if ( importType === 'composite' ) { const [ defaultImport , ... namedImports ] = whatToImport as string [ ] ; return `import ${ defaultImport }, { ${ namedImports . join ( ', ' ) } } from '${ module }';` ; } else if ( importType === 'named' ) { const namedImports = Array . isArray ( whatToImport ) ? whatToImport . join ( ', ' ) : whatToImport ; return `import { ${ namedImports } } from '${ module }';` ; } return `import ${ whatToImport } from '${ module }';` ; } param name param value param exported param type example export const declareConst = ( name , value , exported = false , type = '' ) => `${ cstr ( exported , 'export ' ) }const ${ name }${ cstr ( ! ! type , `: ${ type }` ) } = ${ value };` ; param name param exported example export const declareInterface = ( name , exported = false ) => `${ cstr ( exported , 'export ' ) }interface ${ name } {}` ; param name param params param body param exported export const declareFunction = ( name , params = '' , body = '' , exported = false ) => `${ cstr ( exported , 'export ' ) }function ${ name }(${ params }) {${ body ? `\n${ indent ( body ) }\n` : ' ' }}` ; param params param body export const createArrowFunction = ( params = '' , body = '' ) => `(${ params }) => {${ cstr ( ! ! body , '\n' + indent ( body ) + '\n' ) }}` ; param name export const createDefaultExport = ( name ) => `export default ${ name };` ; param type param content example export const createComment = ( type , content ) => ( { single : ( content ) => `// ${ content }` , multi : ( content ) => [ '/*' , ' * ' + content , ' */' ] . join ( '\n' ) , jsdoc : ( content ) => [ '/**' , ' * ' + content , ' */' ] . join ( '\n' ) , } ) [ type ] ( content ) ; param target param key param value example export const createAssignment = ( target , key , value ) => `${ target }.${ key } = ${ value };` ;