import { Pipe , PipeTransform , EventEmitter } from '@angular/core' ; import { GtInformation , GtEvent } from '..' ; @ Pipe ( { name : 'gtChunk' } ) export class GtChunkPipe implements PipeTransform { transform ( array , gtInfo , chunkSize , page , refreshPageArray , refreshData , gtEvent , data ) { if ( ! Array . isArray ( array ) ) { return array ; } data . exportData = array ; const PAGES = [ ] ; const ENTRIES = array . length ; for ( let i = 0 ; i < ENTRIES ; i += chunkSize ) { PAGES . push ( array . slice ( i , i + chunkSize ) ) ; } gtInfo . visibleRecords = ! PAGES [ page - 1 ] ? [ ] : [ ... PAGES [ page - 1 ] ] ; gtInfo . pageTotal = PAGES . length ; setTimeout ( ( ) => gtEvent . emit ( { name : 'gt-info' , value : gtInfo } ) , 0 ) ; return PAGES [ page - 1 ] ; } }