function searchIcon(icons) {
    function findMatchedIcon(call) {
	return function(data) {
	    return data.filter(res => call(res.name))
	}
    }
    
    function renderIcons(content) {
	return function() {
	    setHtml(content)(container)
	}
    }

    function renderIconCount(icons) {
	return function() {
	    setHtml(icons.length)(count)
	}
    }

    function mountScroller() {
	let scroller = new IScroll('.js-icons-scroller', {
	    scrollbars: true,
	    mouseWheel: true,
	    interactiveScrollbars: true,
	    shrinkScrollbars: 'scale',
	    fadeScrollbars: true,
	    disablePointer: true,
	    disableTouch: true,
	    disableMouse: false
	})
	return function() {
	    scroller.refresh()
	}
    }

    function keyUpHandle(evt) {
	let value = evt.target.value.trim()
	let isMatched = isRegexMatched(new RegExp(`${value}`))
	let findIcon = isBlank(value) ? id : findMatchedIcon(isMatched)

	PL(icons)
	    .then(findIcon)
	    .then(res => Promise.all([
		composeTpl(tplRender)(res),
		renderIconCount(res)
	    ]))
	    .then(([str, fn]) => {
		next(fn)
		next(renderIcons(str))
		next(scroller)
	    })
	    
    }

    const container = $('#icons')
    const search    = $('#search')
    const count     = $('#count')
    const tplRender = renderTpl(iconTpl)
    const scroller  = mountScroller()

    PL(search)
	.then(on('keyup', keyUpHandle))
	.then(trigger('keyup'))

    return icons
}
/**
 * Search matched icons.
 *
 * Trigger on init and search bar typed.
 */
Search matched icons.
Trigger on init and search bar typed.
Search matched icons . Trigger on init and search bar typed .
function searchIcon(icons) {
    function findMatchedIcon(call) {
	return function(data) {
	    return data.filter(res => call(res.name))
	}
    }
    function renderIcons(content) {
	return function() {
	    setHtml(content)(container)
	}
    }
    function renderIconCount(icons) {
	return function() {
	    setHtml(icons.length)(count)
	}
    }
    function mountScroller() {
	let scroller = new IScroll('.js-icons-scroller', {
	    scrollbars: true,
	    mouseWheel: true,
	    interactiveScrollbars: true,
	    shrinkScrollbars: 'scale',
	    fadeScrollbars: true,
	    disablePointer: true,
	    disableTouch: true,
	    disableMouse: false
	})
	return function() {
	    scroller.refresh()
	}
    }
    function keyUpHandle(evt) {
	let value = evt.target.value.trim()
	let isMatched = isRegexMatched(new RegExp(`${value}`))
	let findIcon = isBlank(value) ? id : findMatchedIcon(isMatched)
	PL(icons)
	    .then(findIcon)
	    .then(res => Promise.all([
		composeTpl(tplRender)(res),
		renderIconCount(res)
	    ]))
	    .then(([str, fn]) => {
		next(fn)
		next(renderIcons(str))
		next(scroller)
	    })
    }
    const container = $('#icons')
    const search    = $('#search')
    const count     = $('#count')
    const tplRender = renderTpl(iconTpl)
    const scroller  = mountScroller()
    PL(search)
	.then(on('keyup', keyUpHandle))
	.then(trigger('keyup'))
    return icons
}
function searchIcon ( icons ) { function findMatchedIcon ( call ) { return function ( data ) { return data . filter ( res => call ( res . name ) ) } } function renderIcons ( content ) { return function ( ) { setHtml ( content ) ( container ) } } function renderIconCount ( icons ) { return function ( ) { setHtml ( icons . length ) ( count ) } } function mountScroller ( ) { let scroller = new IScroll ( '.js-icons-scroller' , { scrollbars : true , mouseWheel : true , interactiveScrollbars : true , shrinkScrollbars : 'scale' , fadeScrollbars : true , disablePointer : true , disableTouch : true , disableMouse : false } ) return function ( ) { scroller . refresh ( ) } } function keyUpHandle ( evt ) { let value = evt . target . value . trim ( ) let isMatched = isRegexMatched ( new RegExp ( ` ${ value } ` ) ) let findIcon = isBlank ( value ) ? id : findMatchedIcon ( isMatched ) PL ( icons ) . then ( findIcon ) . then ( res => Promise . all ( [ composeTpl ( tplRender ) ( res ) , renderIconCount ( res ) ] ) ) . then ( ( [ str , fn ] ) => { next ( fn ) next ( renderIcons ( str ) ) next ( scroller ) } ) } const container = $ ( '#icons' ) const search = $ ( '#search' ) const count = $ ( '#count' ) const tplRender = renderTpl ( iconTpl ) const scroller = mountScroller ( ) PL ( search ) . then ( on ( 'keyup' , keyUpHandle ) ) . then ( trigger ( 'keyup' ) ) return icons }
Search matched icons.
Search matched icons .