1/* 2* throttle 3*/ 4function throttle( callback, delay ) { 5 var last; 6 var timer; 7 return function () { 8 var context = this; 9 var now = +new Date(); 10 var args = arguments; 11 if ( last && now < last + delay ) { 12 clearTimeout( timer ); 13 timer = setTimeout( function () { 14 last = now; 15 callback.apply( context, args ); 16 }, delay ); 17 } else { 18 last = now; 19 callback.apply( context, args ); 20 } 21 }; 22} 23 24 25/* 26* debounce 27*/ 28function debounce( callback, delay ) { 29 var timer; 30 return function () { 31 var args = arguments; 32 var context = this; 33 clearTimeout( timer ); 34 timer = setTimeout( function () { 35 callback.apply( context, args ); 36 }, delay ); 37 }; 38} 39 40 41/* 42* Detect if is front page 43* based on the 'home' added class on the body 44*/ 45function is_front_page() { 46 return document.getElementsByTagName( 'body' )[ 0 ].classList.contains( 'home' ); 47} 48 49 50/* 51* convertToSlug 52*/ 53function convertToSlug(content) { 54 return content 55 .toLowerCase() 56 .replace(/ /g,'-') 57 .replace(/[^\w-]+/g,''); 58}
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.