declare const faker ; export class PhoneList { objectArray = [ ] ; objectArray2 = [ ] ; objectArray3 = [ ] ; numberOfItems = 1000 ; isSelected = false ; isVisible = true ; selectedMarkup = 'div' ; value : string = '' ; $removeUntilCount = 0 ; $addCount = 0 ; $removeFromIndex = 0 ; $removeFromCount = 0 ; $addFromCount = 0 ; toggle ( ) { this . isVisible = ! this . isVisible ; } click ( ) { console . log ( 'click' ) ; } setIsSelected ( ) { this . isSelected = true ; } createItem ( index ? ) { let name = faker . name . findName ( ) ; return { firstLetter : name . charAt ( 0 ) , name : name , color : faker . internet . color ( ) , phone : faker . phone . phoneNumber ( ) , country : faker . address . country ( ) } ; } activate ( ) { } swap ( ) { [ this . objectArray3 , this . objectArray2 ] = [ this . objectArray2 , this . objectArray3 ] ; } addItems ( count ) { console . log ( `adding ${ count } items...` ) ; for ( let i = 0 ; i < count ; ++ i ) { this . objectArray3 . push ( this . createItem ( i ) ) ; } console . log ( `finsihed adding ${ count } items` ) ; this . numberOfItems = this . objectArray3 . length ; } addItem2 ( ) { let item = this . createItem ( ) ; this . objectArray3 . splice ( 1 , 0 , item ) ; } addItemFirst ( count = 10 ) { for ( let i = 0 ; i < count ; ++ i ) { this . objectArray3 . unshift ( this . createItem ( ) ) ; } } removeItems ( count ) { this . objectArray3 . splice ( 0 , count ) ; } unshift5 ( ) { this . objectArray3 . unshift ( this . createItem ( ) , this . createItem ( ) , this . createItem ( ) , this . createItem ( ) , this . createItem ( ) ) ; } addItemLast ( count = 10 ) { while ( count -- > 0 ) { this . objectArray3 . push ( this . createItem ( ) ) ; } } removeLast ( ) { this . objectArray3 . pop ( ) ; } search ( ) { let results = [ ] ; for ( let i = 0 ; i < this . objectArray3 . length ; i ++ ) { let item = this . objectArray3 [ i ] ; if ( item . name . toLowerCase ( ) . startsWith ( this . value . toLowerCase ( ) ) ) { results . push ( item ) ; } } this . objectArray3 . splice ( 0 , this . objectArray3 . length , ... results ) ; } removeAndAdd ( afterRemoveCount , addCount , startIndex = 0 ) { this . objectArray3 . splice ( startIndex , Math . max ( 0 , this . objectArray3 . length - afterRemoveCount ) , ... Array . from ( { length : addCount } , ( ) => this . createItem ( ) ) ) ; } removeFromIndexAndAdd ( startIndex , addCount , removeCount = this . objectArray3 . length ) { const addedItems = Array . from ( { length : addCount } , ( ) => this . createItem ( ) ) ; this . objectArray3 . splice ( startIndex , removeCount , ... addedItems ) ; } }