import { Injectable } from '@nestjs/common' ; type TemplateParameter = any [ ] ; @ Injectable ( ) export class UtilService { public template < T > ( templateData , param , delimiter = '\n' ) { let output = '' ; for ( let i = 0 ; i < param . length ; i += 1 ) { output += templateData [ i ] + param [ i ] ; } output += templateData [ param . length ] ; const lines = output . split ( /(?:\r\n|\n|\r)/ ) ; return lines . map ( ( text ) => text . replace ( /^\s+/gm , '' ) ) . join ( delimiter ) . trim ( ) ; } public pre ( templateData , ... param ) { return this . template ( templateData , param , '\n' ) ; } public line ( templateData , ... param ) { return this . template ( templateData , param , ' ' ) ; } public isKeyOfSchema < T > ( key , schema ) { return ( typeof key === 'string' ) && key in schema ; } public removeUndefined < T > ( argv ) { return Object . fromEntries ( Object . entries ( argv ) . filter ( ( [ , value ] ) => value !== undefined ) ) ; } }