function padNumber ( num , length , pad ) { let result = String ( num ) ; while ( result . length < length ) { result = String ( pad ) + result ; } return result ; } /**
 * Options for  sourceArray function
  export interface SourceArrayOptions { /**
     * Minimum number of digits
     */ digits ? : number ; /**
     * Start and end frame numbers
     */ frame ? : number [ ] ; /**
     * Start and end lane numbers
     */ lane ? : number [ ] ; /**
     * Variable to be replaced by a frame number e.g. '{frame}'
     */ framePlacer ? : string ; /**
     * Variable to be replaced by a lane number e.g. '{lane}'
     */ lanePlacer ? : string ; } remarks param template param opts public export function sourceArray ( template , opts ) { const digits = opts . digits || 2 ; const lPlacer = opts . lanePlacer || '{lane}' ; const fPlacer = opts . framePlacer || '{frame}' ; let fStart = 0 ; let fEnd = 0 ; if ( opts . frame ) { fStart = opts . frame [ 0 ] ; fEnd = opts . frame [ 1 ] ; } let lStart = 0 ; let lEnd = 0 ; if ( opts . lane ) { lStart = opts . lane [ 0 ] ; lEnd = opts . lane [ 1 ] ; } const result = [ ] ; for ( let lane = lStart ; lane <= lEnd ; lane += 1 ) { for ( let frame = fStart ; frame <= fEnd ; frame += 1 ) { result . push ( template . replace ( lPlacer , padNumber ( lane , digits , '0' ) ) . replace ( fPlacer , padNumber ( frame , digits , '0' ) ) ) ; } } return result ; }