import { getEle } from '../helpers/util' ; export default class Posts { private posts : Element [ ] ; constructor ( selector ) { this . posts = getEle ( selector ) ; } partialHide ( startIndex ) { if ( this . posts ) { this . posts . forEach ( ( post , index ) => { if ( index > startIndex ) { post . classList . add ( 'is-hidden' ) ; } } ) ; } } show ( count ) { this . posts . forEach ( ( post , index ) => { if ( index < count ) { post . classList . remove ( 'is-hidden' ) ; } } ) ; } size ( ) { return this . posts . length ; } wrapper ( ) { const wrapper = this . posts [ 0 ] . parentElement ; if ( wrapper ) { return wrapper ; } else { throw new Error ( `cannot find post wrapper` ) ; } } }