").addclass(o.options.dotsclass),e=0;e<=o.getdotcount();e+=1)t.append(i("").append(o.options.custompaging.call(this,o,e)));o.$dots=t.appendto(o.options.appenddots),o.$dots.find("li").first().addclass("slick-active")}},e.prototype.buildout=function(){var e=this;e.$slides=e.$slider.children(e.options.slide+":not(.slick-cloned)").addclass("slick-slide"),e.slidecount=e.$slides.length,e.$slides.each(function(e,t){i(t).attr("data-slick-index",e).data("originalstyling",i(t).attr("style")||"")}),e.$slider.addclass("slick-slider"),e.$slidetrack=0===e.slidecount?i('').appendto(e.$slider):e.$slides.wrapall('').parent(),e.$list=e.$slidetrack.wrap('').parent(),e.$slidetrack.css("opacity",0),!0!==e.options.centermode&&!0!==e.options.swipetoslide||(e.options.slidestoscroll=1),i("img[data-lazy]",e.$slider).not("[src]").addclass("slick-loading"),e.setupinfinite(),e.buildarrows(),e.builddots(),e.updatedots(),e.setslideclasses("number"==typeof e.currentslide?e.currentslide:0),!0===e.options.draggable&&e.$list.addclass("draggable")},e.prototype.buildrows=function(){var i,e,t,o,s,n,r,l=this;if(o=document.createdocumentfragment(),n=l.$slider.children(),l.options.rows>1){for(r=l.options.slidesperrow*l.options.rows,s=math.ceil(n.length/r),i=0;ir.breakpoints[o]&&(s=r.breakpoints[o]));null!==s?null!==r.activebreakpoint?(s!==r.activebreakpoint||t)&&(r.activebreakpoint=s,"unslick"===r.breakpointsettings[s]?r.unslick(s):(r.options=i.extend({},r.originalsettings,r.breakpointsettings[s]),!0===e&&(r.currentslide=r.options.initialslide),r.refresh(e)),l=s):(r.activebreakpoint=s,"unslick"===r.breakpointsettings[s]?r.unslick(s):(r.options=i.extend({},r.originalsettings,r.breakpointsettings[s]),!0===e&&(r.currentslide=r.options.initialslide),r.refresh(e)),l=s):null!==r.activebreakpoint&&(r.activebreakpoint=null,r.options=r.originalsettings,!0===e&&(r.currentslide=r.options.initialslide),r.refresh(e),l=s),e||!1===l||r.$slider.trigger("breakpoint",[r,l])}},e.prototype.changeslide=function(e,t){var o,s,n,r=this,l=i(e.currenttarget);switch(l.is("a")&&e.preventdefault(),l.is("li")||(l=l.closest("li")),n=r.slidecount%r.options.slidestoscroll!=0,o=n?0:(r.slidecount-r.currentslide)%r.options.slidestoscroll,e.data.message){case"previous":s=0===o?r.options.slidestoscroll:r.options.slidestoshow-o,r.slidecount>r.options.slidestoshow&&r.slidehandler(r.currentslide-s,!1,t);break;case"next":s=0===o?r.options.slidestoscroll:o,r.slidecount>r.options.slidestoshow&&r.slidehandler(r.currentslide+s,!1,t);break;case"index":var d=0===e.data.index?0:e.data.index||l.index()*r.options.slidestoscroll;r.slidehandler(r.checknavigable(d),!1,t),l.children().trigger("focus");break;default:return}},e.prototype.checknavigable=function(i){var e,t;if(e=this.getnavigableindexes(),t=0,i>e[e.length-1])i=e[e.length-1];else for(var o in e){if(ie.options.slidestoshow&&(e.$prevarrow&&e.$prevarrow.off("click.slick",e.changeslide),e.$nextarrow&&e.$nextarrow.off("click.slick",e.changeslide),!0===e.options.accessibility&&(e.$prevarrow&&e.$prevarrow.off("keydown.slick",e.keyhandler),e.$nextarrow&&e.$nextarrow.off("keydown.slick",e.keyhandler))),e.$list.off("touchstart.slick mousedown.slick",e.swipehandler),e.$list.off("touchmove.slick mousemove.slick",e.swipehandler),e.$list.off("touchend.slick mouseup.slick",e.swipehandler),e.$list.off("touchcancel.slick mouseleave.slick",e.swipehandler),e.$list.off("click.slick",e.clickhandler),i(document).off(e.visibilitychange,e.visibility),e.cleanupslideevents(),!0===e.options.accessibility&&e.$list.off("keydown.slick",e.keyhandler),!0===e.options.focusonselect&&i(e.$slidetrack).children().off("click.slick",e.selecthandler),i(window).off("orientationchange.slick.slick-"+e.instanceuid,e.orientationchange),i(window).off("resize.slick.slick-"+e.instanceuid,e.resize),i("[draggable!=true]",e.$slidetrack).off("dragstart",e.preventdefault),i(window).off("load.slick.slick-"+e.instanceuid,e.setposition)},e.prototype.cleanupslideevents=function(){var e=this;e.$list.off("mouseenter.slick",i.proxy(e.interrupt,e,!0)),e.$list.off("mouseleave.slick",i.proxy(e.interrupt,e,!1))},e.prototype.cleanuprows=function(){var i,e=this;e.options.rows>1&&((i=e.$slides.children().children()).removeattr("style"),e.$slider.empty().append(i))},e.prototype.clickhandler=function(i){!1===this.shouldclick&&(i.stopimmediatepropagation(),i.stoppropagation(),i.preventdefault())},e.prototype.destroy=function(e){var t=this;t.autoplayclear(),t.touchobject={},t.cleanupevents(),i(".slick-cloned",t.$slider).detach(),t.$dots&&t.$dots.remove(),t.$prevarrow&&t.$prevarrow.length&&(t.$prevarrow.removeclass("slick-disabled slick-arrow slick-hidden").removeattr("aria-hidden aria-disabled tabindex").css("display",""),t.htmlexpr.test(t.options.prevarrow)&&t.$prevarrow.remove()),t.$nextarrow&&t.$nextarrow.length&&(t.$nextarrow.removeclass("slick-disabled slick-arrow slick-hidden").removeattr("aria-hidden aria-disabled tabindex").css("display",""),t.htmlexpr.test(t.options.nextarrow)&&t.$nextarrow.remove()),t.$slides&&(t.$slides.removeclass("slick-slide slick-active slick-center slick-visible slick-current").removeattr("aria-hidden").removeattr("data-slick-index").each(function(){i(this).attr("style",i(this).data("originalstyling"))}),t.$slidetrack.children(this.options.slide).detach(),t.$slidetrack.detach(),t.$list.detach(),t.$slider.append(t.$slides)),t.cleanuprows(),t.$slider.removeclass("slick-slider"),t.$slider.removeclass("slick-initialized"),t.$slider.removeclass("slick-dotted"),t.unslicked=!0,e||t.$slider.trigger("destroy",[t])},e.prototype.disabletransition=function(i){var e=this,t={};t[e.transitiontype]="",!1===e.options.fade?e.$slidetrack.css(t):e.$slides.eq(i).css(t)},e.prototype.fadeslide=function(i,e){var t=this;!1===t.csstransitions?(t.$slides.eq(i).css({zindex:t.options.zindex}),t.$slides.eq(i).animate({opacity:1},t.options.speed,t.options.easing,e)):(t.applytransition(i),t.$slides.eq(i).css({opacity:1,zindex:t.options.zindex}),e&&settimeout(function(){t.disabletransition(i),e.call()},t.options.speed))},e.prototype.fadeslideout=function(i){var e=this;!1===e.csstransitions?e.$slides.eq(i).animate({opacity:0,zindex:e.options.zindex-2},e.options.speed,e.options.easing):(e.applytransition(i),e.$slides.eq(i).css({opacity:0,zindex:e.options.zindex-2}))},e.prototype.filterslides=e.prototype.slickfilter=function(i){var e=this;null!==i&&(e.$slidescache=e.$slides,e.unload(),e.$slidetrack.children(this.options.slide).detach(),e.$slidescache.filter(i).appendto(e.$slidetrack),e.reinit())},e.prototype.focushandler=function(){var e=this;e.$slider.off("focus.slick blur.slick").on("focus.slick blur.slick","*",function(t){t.stopimmediatepropagation();var o=i(this);settimeout(function(){e.options.pauseonfocus&&(e.focussed=o.is(":focus"),e.autoplay())},0)})},e.prototype.getcurrent=e.prototype.slickcurrentslide=function(){return this.currentslide},e.prototype.getdotcount=function(){var i=this,e=0,t=0,o=0;if(!0===i.options.infinite)if(i.slidecount<=i.options.slidestoshow)++o;else for(;en.options.slidestoshow&&(n.slideoffset=n.slidewidth*n.options.slidestoshow*-1,s=-1,!0===n.options.vertical&&!0===n.options.centermode&&(2===n.options.slidestoshow?s=-1.5:1===n.options.slidestoshow&&(s=-2)),r=t*n.options.slidestoshow*s),n.slidecount%n.options.slidestoscroll!=0&&i+n.options.slidestoscroll>n.slidecount&&n.slidecount>n.options.slidestoshow&&(i>n.slidecount?(n.slideoffset=(n.options.slidestoshow-(i-n.slidecount))*n.slidewidth*-1,r=(n.options.slidestoshow-(i-n.slidecount))*t*-1):(n.slideoffset=n.slidecount%n.options.slidestoscroll*n.slidewidth*-1,r=n.slidecount%n.options.slidestoscroll*t*-1))):i+n.options.slidestoshow>n.slidecount&&(n.slideoffset=(i+n.options.slidestoshow-n.slidecount)*n.slidewidth,r=(i+n.options.slidestoshow-n.slidecount)*t),n.slidecount<=n.options.slidestoshow&&(n.slideoffset=0,r=0),!0===n.options.centermode&&n.slidecount<=n.options.slidestoshow?n.slideoffset=n.slidewidth*math.floor(n.options.slidestoshow)/2-n.slidewidth*n.slidecount/2:!0===n.options.centermode&&!0===n.options.infinite?n.slideoffset+=n.slidewidth*math.floor(n.options.slidestoshow/2)-n.slidewidth:!0===n.options.centermode&&(n.slideoffset=0,n.slideoffset+=n.slidewidth*math.floor(n.options.slidestoshow/2)),e=!1===n.options.vertical?i*n.slidewidth*-1+n.slideoffset:i*t*-1+r,!0===n.options.variablewidth&&(o=n.slidecount<=n.options.slidestoshow||!1===n.options.infinite?n.$slidetrack.children(".slick-slide").eq(i):n.$slidetrack.children(".slick-slide").eq(i+n.options.slidestoshow),e=!0===n.options.rtl?o[0]?-1*(n.$slidetrack.width()-o[0].offsetleft-o.width()):0:o[0]?-1*o[0].offsetleft:0,!0===n.options.centermode&&(o=n.slidecount<=n.options.slidestoshow||!1===n.options.infinite?n.$slidetrack.children(".slick-slide").eq(i):n.$slidetrack.children(".slick-slide").eq(i+n.options.slidestoshow+1),e=!0===n.options.rtl?o[0]?-1*(n.$slidetrack.width()-o[0].offsetleft-o.width()):0:o[0]?-1*o[0].offsetleft:0,e+=(n.$list.width()-o.outerwidth())/2)),e},e.prototype.getoption=e.prototype.slickgetoption=function(i){return this.options[i]},e.prototype.getnavigableindexes=function(){var i,e=this,t=0,o=0,s=[];for(!1===e.options.infinite?i=e.slidecount:(t=-1*e.options.slidestoscroll,o=-1*e.options.slidestoscroll,i=2*e.slidecount);t-1*o.swipeleft)return e=n,!1}),math.abs(i(e).attr("data-slick-index")-o.currentslide)||1):o.options.slidestoscroll},e.prototype.goto=e.prototype.slickgoto=function(i,e){this.changeslide({data:{message:"index",index:parseint(i)}},e)},e.prototype.init=function(e){var t=this;i(t.$slider).hasclass("slick-initialized")||(i(t.$slider).addclass("slick-initialized"),t.buildrows(),t.buildout(),t.setprops(),t.startload(),t.loadslider(),t.initializeevents(),t.updatearrows(),t.updatedots(),t.checkresponsive(!0),t.focushandler()),e&&t.$slider.trigger("init",[t]),!0===t.options.accessibility&&t.initada(),t.options.autoplay&&(t.paused=!1,t.autoplay())},e.prototype.initada=function(){var e=this,t=math.ceil(e.slidecount/e.options.slidestoshow),o=e.getnavigableindexes().filter(function(i){return i>=0&&ii.options.slidestoshow&&(i.$prevarrow.off("click.slick").on("click.slick",{message:"previous"},i.changeslide),i.$nextarrow.off("click.slick").on("click.slick",{message:"next"},i.changeslide),!0===i.options.accessibility&&(i.$prevarrow.on("keydown.slick",i.keyhandler),i.$nextarrow.on("keydown.slick",i.keyhandler)))},e.prototype.initdotevents=function(){var e=this;!0===e.options.dots&&(i("li",e.$dots).on("click.slick",{message:"index"},e.changeslide),!0===e.options.accessibility&&e.$dots.on("keydown.slick",e.keyhandler)),!0===e.options.dots&&!0===e.options.pauseondotshover&&i("li",e.$dots).on("mouseenter.slick",i.proxy(e.interrupt,e,!0)).on("mouseleave.slick",i.proxy(e.interrupt,e,!1))},e.prototype.initslideevents=function(){var e=this;e.options.pauseonhover&&(e.$list.on("mouseenter.slick",i.proxy(e.interrupt,e,!0)),e.$list.on("mouseleave.slick",i.proxy(e.interrupt,e,!1)))},e.prototype.initializeevents=function(){var e=this;e.initarrowevents(),e.initdotevents(),e.initslideevents(),e.$list.on("touchstart.slick mousedown.slick",{action:"start"},e.swipehandler),e.$list.on("touchmove.slick mousemove.slick",{action:"move"},e.swipehandler),e.$list.on("touchend.slick mouseup.slick",{action:"end"},e.swipehandler),e.$list.on("touchcancel.slick mouseleave.slick",{action:"end"},e.swipehandler),e.$list.on("click.slick",e.clickhandler),i(document).on(e.visibilitychange,i.proxy(e.visibility,e)),!0===e.options.accessibility&&e.$list.on("keydown.slick",e.keyhandler),!0===e.options.focusonselect&&i(e.$slidetrack).children().on("click.slick",e.selecthandler),i(window).on("orientationchange.slick.slick-"+e.instanceuid,i.proxy(e.orientationchange,e)),i(window).on("resize.slick.slick-"+e.instanceuid,i.proxy(e.resize,e)),i("[draggable!=true]",e.$slidetrack).on("dragstart",e.preventdefault),i(window).on("load.slick.slick-"+e.instanceuid,e.setposition),i(e.setposition)},e.prototype.initui=function(){var i=this;!0===i.options.arrows&&i.slidecount>i.options.slidestoshow&&(i.$prevarrow.show(),i.$nextarrow.show()),!0===i.options.dots&&i.slidecount>i.options.slidestoshow&&i.$dots.show()},e.prototype.keyhandler=function(i){var e=this;i.target.tagname.match("textarea|input|select")||(37===i.keycode&&!0===e.options.accessibility?e.changeslide({data:{message:!0===e.options.rtl?"next":"previous"}}):39===i.keycode&&!0===e.options.accessibility&&e.changeslide({data:{message:!0===e.options.rtl?"previous":"next"}}))},e.prototype.lazyload=function(){function e(e){i("img[data-lazy]",e).each(function(){var e=i(this),t=i(this).attr("data-lazy"),o=i(this).attr("data-srcset"),s=i(this).attr("data-sizes")||n.$slider.attr("data-sizes"),r=document.createelement("img");r.onload=function(){e.animate({opacity:0},100,function(){o&&(e.attr("srcset",o),s&&e.attr("sizes",s)),e.attr("src",t).animate({opacity:1},200,function(){e.removeattr("data-lazy data-srcset data-sizes").removeclass("slick-loading")}),n.$slider.trigger("lazyloaded",[n,e,t])})},r.onerror=function(){e.removeattr("data-lazy").removeclass("slick-loading").addclass("slick-lazyload-error"),n.$slider.trigger("lazyloaderror",[n,e,t])},r.src=t})}var t,o,s,n=this;if(!0===n.options.centermode?!0===n.options.infinite?s=(o=n.currentslide+(n.options.slidestoshow/2+1))+n.options.slidestoshow+2:(o=math.max(0,n.currentslide-(n.options.slidestoshow/2+1)),s=n.options.slidestoshow/2+1+2+n.currentslide):(o=n.options.infinite?n.options.slidestoshow+n.currentslide:n.currentslide,s=math.ceil(o+n.options.slidestoshow),!0===n.options.fade&&(o>0&&o--,s<=n.slidecount&&s++)),t=n.$slider.find(".slick-slide").slice(o,s),"anticipated"===n.options.lazyload)for(var r=o-1,l=s,d=n.$slider.find(".slick-slide"),a=0;a=n.slidecount-n.options.slidestoshow?e(n.$slider.find(".slick-cloned").slice(0,n.options.slidestoshow)):0===n.currentslide&&e(n.$slider.find(".slick-cloned").slice(-1*n.options.slidestoshow))},e.prototype.loadslider=function(){var i=this;i.setposition(),i.$slidetrack.css({opacity:1}),i.$slider.removeclass("slick-loading"),i.initui(),"progressive"===i.options.lazyload&&i.progressivelazyload()},e.prototype.next=e.prototype.slicknext=function(){this.changeslide({data:{message:"next"}})},e.prototype.orientationchange=function(){var i=this;i.checkresponsive(),i.setposition()},e.prototype.pause=e.prototype.slickpause=function(){var i=this;i.autoplayclear(),i.paused=!0},e.prototype.play=e.prototype.slickplay=function(){var i=this;i.autoplay(),i.options.autoplay=!0,i.paused=!1,i.focussed=!1,i.interrupted=!1},e.prototype.postslide=function(e){var t=this;t.unslicked||(t.$slider.trigger("afterchange",[t,e]),t.animating=!1,t.slidecount>t.options.slidestoshow&&t.setposition(),t.swipeleft=null,t.options.autoplay&&t.autoplay(),!0===t.options.accessibility&&(t.initada(),t.options.focusonchange&&i(t.$slides.get(t.currentslide)).attr("tabindex",0).focus()))},e.prototype.prev=e.prototype.slickprev=function(){this.changeslide({data:{message:"previous"}})},e.prototype.preventdefault=function(i){i.preventdefault()},e.prototype.progressivelazyload=function(e){e=e||1;var t,o,s,n,r,l=this,d=i("img[data-lazy]",l.$slider);d.length?(t=d.first(),o=t.attr("data-lazy"),s=t.attr("data-srcset"),n=t.attr("data-sizes")||l.$slider.attr("data-sizes"),(r=document.createelement("img")).onload=function(){s&&(t.attr("srcset",s),n&&t.attr("sizes",n)),t.attr("src",o).removeattr("data-lazy data-srcset data-sizes").removeclass("slick-loading"),!0===l.options.adaptiveheight&&l.setposition(),l.$slider.trigger("lazyloaded",[l,t,o]),l.progressivelazyload()},r.onerror=function(){e<3?settimeout(function(){l.progressivelazyload(e+1)},500):(t.removeattr("data-lazy").removeclass("slick-loading").addclass("slick-lazyload-error"),l.$slider.trigger("lazyloaderror",[l,t,o]),l.progressivelazyload())},r.src=o):l.$slider.trigger("allimagesloaded",[l])},e.prototype.refresh=function(e){var t,o,s=this;o=s.slidecount-s.options.slidestoshow,!s.options.infinite&&s.currentslide>o&&(s.currentslide=o),s.slidecount<=s.options.slidestoshow&&(s.currentslide=0),t=s.currentslide,s.destroy(!0),i.extend(s,s.initials,{currentslide:t}),s.init(),e||s.changeslide({data:{message:"index",index:t}},!1)},e.prototype.registerbreakpoints=function(){var e,t,o,s=this,n=s.options.responsive||null;if("array"===i.type(n)&&n.length){s.respondto=s.options.respondto||"window";for(e in n)if(o=s.breakpoints.length-1,n.hasownproperty(e)){for(t=n[e].breakpoint;o>=0;)s.breakpoints[o]&&s.breakpoints[o]===t&&s.breakpoints.splice(o,1),o--;s.breakpoints.push(t),s.breakpointsettings[t]=n[e].settings}s.breakpoints.sort(function(i,e){return s.options.mobilefirst?i-e:e-i})}},e.prototype.reinit=function(){var e=this;e.$slides=e.$slidetrack.children(e.options.slide).addclass("slick-slide"),e.slidecount=e.$slides.length,e.currentslide>=e.slidecount&&0!==e.currentslide&&(e.currentslide=e.currentslide-e.options.slidestoscroll),e.slidecount<=e.options.slidestoshow&&(e.currentslide=0),e.registerbreakpoints(),e.setprops(),e.setupinfinite(),e.buildarrows(),e.updatearrows(),e.initarrowevents(),e.builddots(),e.updatedots(),e.initdotevents(),e.cleanupslideevents(),e.initslideevents(),e.checkresponsive(!1,!0),!0===e.options.focusonselect&&i(e.$slidetrack).children().on("click.slick",e.selecthandler),e.setslideclasses("number"==typeof e.currentslide?e.currentslide:0),e.setposition(),e.focushandler(),e.paused=!e.options.autoplay,e.autoplay(),e.$slider.trigger("reinit",[e])},e.prototype.resize=function(){var e=this;i(window).width()!==e.windowwidth&&(cleartimeout(e.windowdelay),e.windowdelay=window.settimeout(function(){e.windowwidth=i(window).width(),e.checkresponsive(),e.unslicked||e.setposition()},50))},e.prototype.removeslide=e.prototype.slickremove=function(i,e,t){var o=this;if(i="boolean"==typeof i?!0===(e=i)?0:o.slidecount-1:!0===e?--i:i,o.slidecount<1||i<0||i>o.slidecount-1)return!1;o.unload(),!0===t?o.$slidetrack.children().remove():o.$slidetrack.children(this.options.slide).eq(i).remove(),o.$slides=o.$slidetrack.children(this.options.slide),o.$slidetrack.children(this.options.slide).detach(),o.$slidetrack.append(o.$slides),o.$slidescache=o.$slides,o.reinit()},e.prototype.setcss=function(i){var e,t,o=this,s={};!0===o.options.rtl&&(i=-i),e="left"==o.positionprop?math.ceil(i)+"px":"0px",t="top"==o.positionprop?math.ceil(i)+"px":"0px",s[o.positionprop]=i,!1===o.transformsenabled?o.$slidetrack.css(s):(s={},!1===o.csstransitions?(s[o.animtype]="translate("+e+", "+t+")",o.$slidetrack.css(s)):(s[o.animtype]="translate3d("+e+", "+t+", 0px)",o.$slidetrack.css(s)))},e.prototype.setdimensions=function(){var i=this;!1===i.options.vertical?!0===i.options.centermode&&i.$list.css({padding:"0px "+i.options.centerpadding}):(i.$list.height(i.$slides.first().outerheight(!0)*i.options.slidestoshow),!0===i.options.centermode&&i.$list.css({padding:i.options.centerpadding+" 0px"})),i.listwidth=i.$list.width(),i.listheight=i.$list.height(),!1===i.options.vertical&&!1===i.options.variablewidth?(i.slidewidth=math.ceil(i.listwidth/i.options.slidestoshow),i.$slidetrack.width(math.ceil(i.slidewidth*i.$slidetrack.children(".slick-slide").length))):!0===i.options.variablewidth?i.$slidetrack.width(5e3*i.slidecount):(i.slidewidth=math.ceil(i.listwidth),i.$slidetrack.height(math.ceil(i.$slides.first().outerheight(!0)*i.$slidetrack.children(".slick-slide").length)));var e=i.$slides.first().outerwidth(!0)-i.$slides.first().width();!1===i.options.variablewidth&&i.$slidetrack.children(".slick-slide").width(i.slidewidth-e)},e.prototype.setfade=function(){var e,t=this;t.$slides.each(function(o,s){e=t.slidewidth*o*-1,!0===t.options.rtl?i(s).css({position:"relative",right:e,top:0,zindex:t.options.zindex-2,opacity:0}):i(s).css({position:"relative",left:e,top:0,zindex:t.options.zindex-2,opacity:0})}),t.$slides.eq(t.currentslide).css({zindex:t.options.zindex-1,opacity:1})},e.prototype.setheight=function(){var i=this;if(1===i.options.slidestoshow&&!0===i.options.adaptiveheight&&!1===i.options.vertical){var e=i.$slides.eq(i.currentslide).outerheight(!0);i.$list.css("height",e)}},e.prototype.setoption=e.prototype.slicksetoption=function(){var e,t,o,s,n,r=this,l=!1;if("object"===i.type(arguments[0])?(o=arguments[0],l=arguments[1],n="multiple"):"string"===i.type(arguments[0])&&(o=arguments[0],s=arguments[1],l=arguments[2],"responsive"===arguments[0]&&"array"===i.type(arguments[1])?n="responsive":void 0!==arguments[1]&&(n="single")),"single"===n)r.options[o]=s;else if("multiple"===n)i.each(o,function(i,e){r.options[i]=e});else if("responsive"===n)for(t in s)if("array"!==i.type(r.options.responsive))r.options.responsive=[s[t]];else{for(e=r.options.responsive.length-1;e>=0;)r.options.responsive[e].breakpoint===s[t].breakpoint&&r.options.responsive.splice(e,1),e--;r.options.responsive.push(s[t])}l&&(r.unload(),r.reinit())},e.prototype.setposition=function(){var i=this;i.setdimensions(),i.setheight(),!1===i.options.fade?i.setcss(i.getleft(i.currentslide)):i.setfade(),i.$slider.trigger("setposition",[i])},e.prototype.setprops=function(){var i=this,e=document.body.style;i.positionprop=!0===i.options.vertical?"top":"left","top"===i.positionprop?i.$slider.addclass("slick-vertical"):i.$slider.removeclass("slick-vertical"),void 0===e.webkittransition&&void 0===e.moztransition&&void 0===e.mstransition||!0===i.options.usecss&&(i.csstransitions=!0),i.options.fade&&("number"==typeof i.options.zindex?i.options.zindex<3&&(i.options.zindex=3):i.options.zindex=i.defaults.zindex),void 0!==e.otransform&&(i.animtype="otransform",i.transformtype="-o-transform",i.transitiontype="otransition",void 0===e.perspectiveproperty&&void 0===e.webkitperspective&&(i.animtype=!1)),void 0!==e.moztransform&&(i.animtype="moztransform",i.transformtype="-moz-transform",i.transitiontype="moztransition",void 0===e.perspectiveproperty&&void 0===e.mozperspective&&(i.animtype=!1)),void 0!==e.webkittransform&&(i.animtype="webkittransform",i.transformtype="-webkit-transform",i.transitiontype="webkittransition",void 0===e.perspectiveproperty&&void 0===e.webkitperspective&&(i.animtype=!1)),void 0!==e.mstransform&&(i.animtype="mstransform",i.transformtype="-ms-transform",i.transitiontype="mstransition",void 0===e.mstransform&&(i.animtype=!1)),void 0!==e.transform&&!1!==i.animtype&&(i.animtype="transform",i.transformtype="transform",i.transitiontype="transition"),i.transformsenabled=i.options.usetransform&&null!==i.animtype&&!1!==i.animtype},e.prototype.setslideclasses=function(i){var e,t,o,s,n=this;if(t=n.$slider.find(".slick-slide").removeclass("slick-active slick-center slick-current").attr("aria-hidden","true"),n.$slides.eq(i).addclass("slick-current"),!0===n.options.centermode){var r=n.options.slidestoshow%2==0?1:0;e=math.floor(n.options.slidestoshow/2),!0===n.options.infinite&&(i>=e&&i<=n.slidecount-1-e?n.$slides.slice(i-e+r,i+e+1).addclass("slick-active").attr("aria-hidden","false"):(o=n.options.slidestoshow+i,t.slice(o-e+1+r,o+e+2).addclass("slick-active").attr("aria-hidden","false")),0===i?t.eq(t.length-1-n.options.slidestoshow).addclass("slick-center"):i===n.slidecount-1&&t.eq(n.options.slidestoshow).addclass("slick-center")),n.$slides.eq(i).addclass("slick-center")}else i>=0&&i<=n.slidecount-n.options.slidestoshow?n.$slides.slice(i,i+n.options.slidestoshow).addclass("slick-active").attr("aria-hidden","false"):t.length<=n.options.slidestoshow?t.addclass("slick-active").attr("aria-hidden","false"):(s=n.slidecount%n.options.slidestoshow,o=!0===n.options.infinite?n.options.slidestoshow+i:i,n.options.slidestoshow==n.options.slidestoscroll&&n.slidecount-is.options.slidestoshow)){for(o=!0===s.options.centermode?s.options.slidestoshow+1:s.options.slidestoshow,e=s.slidecount;e>s.slidecount-o;e-=1)t=e-1,i(s.$slides[t]).clone(!0).attr("id","").attr("data-slick-index",t-s.slidecount).prependto(s.$slidetrack).addclass("slick-cloned");for(e=0;ea.getdotcount()*a.options.slidestoscroll))!1===a.options.fade&&(o=a.currentslide,!0!==t?a.animateslide(r,function(){a.postslide(o)}):a.postslide(o));else if(!1===a.options.infinite&&!0===a.options.centermode&&(i<0||i>a.slidecount-a.options.slidestoscroll))!1===a.options.fade&&(o=a.currentslide,!0!==t?a.animateslide(r,function(){a.postslide(o)}):a.postslide(o));else{if(a.options.autoplay&&clearinterval(a.autoplaytimer),s=o<0?a.slidecount%a.options.slidestoscroll!=0?a.slidecount-a.slidecount%a.options.slidestoscroll:a.slidecount+o:o>=a.slidecount?a.slidecount%a.options.slidestoscroll!=0?0:o-a.slidecount:o,a.animating=!0,a.$slider.trigger("beforechange",[a,a.currentslide,s]),n=a.currentslide,a.currentslide=s,a.setslideclasses(a.currentslide),a.options.asnavfor&&(l=(l=a.getnavtarget()).slick("getslick")).slidecount<=l.options.slidestoshow&&l.setslideclasses(a.currentslide),a.updatedots(),a.updatearrows(),!0===a.options.fade)return!0!==t?(a.fadeslideout(n),a.fadeslide(s,function(){a.postslide(s)})):a.postslide(s),void a.animateheight();!0!==t?a.animateslide(d,function(){a.postslide(s)}):a.postslide(s)}},e.prototype.startload=function(){var i=this;!0===i.options.arrows&&i.slidecount>i.options.slidestoshow&&(i.$prevarrow.hide(),i.$nextarrow.hide()),!0===i.options.dots&&i.slidecount>i.options.slidestoshow&&i.$dots.hide(),i.$slider.addclass("slick-loading")},e.prototype.swipedirection=function(){var i,e,t,o,s=this;return i=s.touchobject.startx-s.touchobject.curx,e=s.touchobject.starty-s.touchobject.cury,t=math.atan2(e,i),(o=math.round(180*t/math.pi))<0&&(o=360-math.abs(o)),o<=45&&o>=0?!1===s.options.rtl?"left":"right":o<=360&&o>=315?!1===s.options.rtl?"left":"right":o>=135&&o<=225?!1===s.options.rtl?"right":"left":!0===s.options.verticalswiping?o>=35&&o<=135?"down":"up":"vertical"},e.prototype.swipeend=function(i){var e,t,o=this;if(o.dragging=!1,o.swiping=!1,o.scrolling)return o.scrolling=!1,!1;if(o.interrupted=!1,o.shouldclick=!(o.touchobject.swipelength>10),void 0===o.touchobject.curx)return!1;if(!0===o.touchobject.edgehit&&o.$slider.trigger("edge",[o,o.swipedirection()]),o.touchobject.swipelength>=o.touchobject.minswipe){switch(t=o.swipedirection()){case"left":case"down":e=o.options.swipetoslide?o.checknavigable(o.currentslide+o.getslidecount()):o.currentslide+o.getslidecount(),o.currentdirection=0;break;case"right":case"up":e=o.options.swipetoslide?o.checknavigable(o.currentslide-o.getslidecount()):o.currentslide-o.getslidecount(),o.currentdirection=1}"vertical"!=t&&(o.slidehandler(e),o.touchobject={},o.$slider.trigger("swipe",[o,t]))}else o.touchobject.startx!==o.touchobject.curx&&(o.slidehandler(o.currentslide),o.touchobject={})},e.prototype.swipehandler=function(i){var e=this;if(!(!1===e.options.swipe||"ontouchend"in document&&!1===e.options.swipe||!1===e.options.draggable&&-1!==i.type.indexof("mouse")))switch(e.touchobject.fingercount=i.originalevent&&void 0!==i.originalevent.touches?i.originalevent.touches.length:1,e.touchobject.minswipe=e.listwidth/e.options.touchthreshold,!0===e.options.verticalswiping&&(e.touchobject.minswipe=e.listheight/e.options.touchthreshold),i.data.action){case"start":e.swipestart(i);break;case"move":e.swipemove(i);break;case"end":e.swipeend(i)}},e.prototype.swipemove=function(i){var e,t,o,s,n,r,l=this;return n=void 0!==i.originalevent?i.originalevent.touches:null,!(!l.dragging||l.scrolling||n&&1!==n.length)&&(e=l.getleft(l.currentslide),l.touchobject.curx=void 0!==n?n[0].pagex:i.clientx,l.touchobject.cury=void 0!==n?n[0].pagey:i.clienty,l.touchobject.swipelength=math.round(math.sqrt(math.pow(l.touchobject.curx-l.touchobject.startx,2))),r=math.round(math.sqrt(math.pow(l.touchobject.cury-l.touchobject.starty,2))),!l.options.verticalswiping&&!l.swiping&&r>4?(l.scrolling=!0,!1):(!0===l.options.verticalswiping&&(l.touchobject.swipelength=r),t=l.swipedirection(),void 0!==i.originalevent&&l.touchobject.swipelength>4&&(l.swiping=!0,i.preventdefault()),s=(!1===l.options.rtl?1:-1)*(l.touchobject.curx>l.touchobject.startx?1:-1),!0===l.options.verticalswiping&&(s=l.touchobject.cury>l.touchobject.starty?1:-1),o=l.touchobject.swipelength,l.touchobject.edgehit=!1,!1===l.options.infinite&&(0===l.currentslide&&"right"===t||l.currentslide>=l.getdotcount()&&"left"===t)&&(o=l.touchobject.swipelength*l.options.edgefriction,l.touchobject.edgehit=!0),!1===l.options.vertical?l.swipeleft=e+o*s:l.swipeleft=e+o*(l.$list.height()/l.listwidth)*s,!0===l.options.verticalswiping&&(l.swipeleft=e+o*s),!0!==l.options.fade&&!1!==l.options.touchmove&&(!0===l.animating?(l.swipeleft=null,!1):void l.setcss(l.swipeleft))))},e.prototype.swipestart=function(i){var e,t=this;if(t.interrupted=!0,1!==t.touchobject.fingercount||t.slidecount<=t.options.slidestoshow)return t.touchobject={},!1;void 0!==i.originalevent&&void 0!==i.originalevent.touches&&(e=i.originalevent.touches[0]),t.touchobject.startx=t.touchobject.curx=void 0!==e?e.pagex:i.clientx,t.touchobject.starty=t.touchobject.cury=void 0!==e?e.pagey:i.clienty,t.dragging=!0},e.prototype.unfilterslides=e.prototype.slickunfilter=function(){var i=this;null!==i.$slidescache&&(i.unload(),i.$slidetrack.children(this.options.slide).detach(),i.$slidescache.appendto(i.$slidetrack),i.reinit())},e.prototype.unload=function(){var e=this;i(".slick-cloned",e.$slider).remove(),e.$dots&&e.$dots.remove(),e.$prevarrow&&e.htmlexpr.test(e.options.prevarrow)&&e.$prevarrow.remove(),e.$nextarrow&&e.htmlexpr.test(e.options.nextarrow)&&e.$nextarrow.remove(),e.$slides.removeclass("slick-slide slick-active slick-visible slick-current").attr("aria-hidden","true").css("width","")},e.prototype.unslick=function(i){var e=this;e.$slider.trigger("unslick",[e,i]),e.destroy()},e.prototype.updatearrows=function(){var i=this;math.floor(i.options.slidestoshow/2),!0===i.options.arrows&&i.slidecount>i.options.slidestoshow&&!i.options.infinite&&(i.$prevarrow.removeclass("slick-disabled").attr("aria-disabled","false"),i.$nextarrow.removeclass("slick-disabled").attr("aria-disabled","false"),0===i.currentslide?(i.$prevarrow.addclass("slick-disabled").attr("aria-disabled","true"),i.$nextarrow.removeclass("slick-disabled").attr("aria-disabled","false")):i.currentslide>=i.slidecount-i.options.slidestoshow&&!1===i.options.centermode?(i.$nextarrow.addclass("slick-disabled").attr("aria-disabled","true"),i.$prevarrow.removeclass("slick-disabled").attr("aria-disabled","false")):i.currentslide>=i.slidecount-1&&!0===i.options.centermode&&(i.$nextarrow.addclass("slick-disabled").attr("aria-disabled","true"),i.$prevarrow.removeclass("slick-disabled").attr("aria-disabled","false")))},e.prototype.updatedots=function(){var i=this;null!==i.$dots&&(i.$dots.find("li").removeclass("slick-active").end(),i.$dots.find("li").eq(math.floor(i.currentslide/i.options.slidestoscroll)).addclass("slick-active"))},e.prototype.visibility=function(){var i=this;i.options.autoplay&&(document[i.hidden]?i.interrupted=!0:i.interrupted=!1)},i.fn.slick=function(){var i,t,o=this,s=arguments[0],n=array.prototype.slice.call(arguments,1),r=o.length;for(i=0;i
* copyright js foundation and other contributors
* released under mit license
* based on underscore.js 1.8.3
* copyright jeremy ashkenas, documentcloud and investigative reporters & editors
*/
;(function() {
/** used as a safe reference for `undefined` in pre-es5 environments. */
var undefined;
/** used as the semantic version number. */
var version = '4.17.5';
/** used as the size to enable large array optimizations. */
var large_array_size = 200;
/** error message constants. */
var core_error_text = 'unsupported core-js use. try https://npms.io/search?q=ponyfill.',
func_error_text = 'expected a function';
/** used to stand-in for `undefined` hash values. */
var hash_undefined = '__lodash_hash_undefined__';
/** used as the maximum memoize cache size. */
var max_memoize_size = 500;
/** used as the internal argument placeholder. */
var placeholder = '__lodash_placeholder__';
/** used to compose bitmasks for cloning. */
var clone_deep_flag = 1,
clone_flat_flag = 2,
clone_symbols_flag = 4;
/** used to compose bitmasks for value comparisons. */
var compare_partial_flag = 1,
compare_unordered_flag = 2;
/** used to compose bitmasks for function metadata. */
var wrap_bind_flag = 1,
wrap_bind_key_flag = 2,
wrap_curry_bound_flag = 4,
wrap_curry_flag = 8,
wrap_curry_right_flag = 16,
wrap_partial_flag = 32,
wrap_partial_right_flag = 64,
wrap_ary_flag = 128,
wrap_rearg_flag = 256,
wrap_flip_flag = 512;
/** used as default options for `_.truncate`. */
var default_trunc_length = 30,
default_trunc_omission = '...';
/** used to detect hot functions by number of calls within a span of milliseconds. */
var hot_count = 800,
hot_span = 16;
/** used to indicate the type of lazy iteratees. */
var lazy_filter_flag = 1,
lazy_map_flag = 2,
lazy_while_flag = 3;
/** used as references for various `number` constants. */
var infinity = 1 / 0,
max_safe_integer = 9007199254740991,
max_integer = 1.7976931348623157e+308,
nan = 0 / 0;
/** used as references for the maximum length and index of an array. */
var max_array_length = 4294967295,
max_array_index = max_array_length - 1,
half_max_array_length = max_array_length >>> 1;
/** used to associate wrap methods with their bit flags. */
var wrapflags = [
['ary', wrap_ary_flag],
['bind', wrap_bind_flag],
['bindkey', wrap_bind_key_flag],
['curry', wrap_curry_flag],
['curryright', wrap_curry_right_flag],
['flip', wrap_flip_flag],
['partial', wrap_partial_flag],
['partialright', wrap_partial_right_flag],
['rearg', wrap_rearg_flag]
];
/** `object#tostring` result references. */
var argstag = '[object arguments]',
arraytag = '[object array]',
asynctag = '[object asyncfunction]',
booltag = '[object boolean]',
datetag = '[object date]',
domexctag = '[object domexception]',
errortag = '[object error]',
functag = '[object function]',
gentag = '[object generatorfunction]',
maptag = '[object map]',
numbertag = '[object number]',
nulltag = '[object null]',
objecttag = '[object object]',
promisetag = '[object promise]',
proxytag = '[object proxy]',
regexptag = '[object regexp]',
settag = '[object set]',
stringtag = '[object string]',
symboltag = '[object symbol]',
undefinedtag = '[object undefined]',
weakmaptag = '[object weakmap]',
weaksettag = '[object weakset]';
var arraybuffertag = '[object arraybuffer]',
dataviewtag = '[object dataview]',
float32tag = '[object float32array]',
float64tag = '[object float64array]',
int8tag = '[object int8array]',
int16tag = '[object int16array]',
int32tag = '[object int32array]',
uint8tag = '[object uint8array]',
uint8clampedtag = '[object uint8clampedarray]',
uint16tag = '[object uint16array]',
uint32tag = '[object uint32array]';
/** used to match empty string literals in compiled template source. */
var reemptystringleading = /\b__p \+= '';/g,
reemptystringmiddle = /\b(__p \+=) '' \+/g,
reemptystringtrailing = /(__e\(.*?\)|\b__t\)) \+\n'';/g;
/** used to match html entities and html characters. */
var reescapedhtml = /&(?:amp|lt|gt|quot|#39);/g,
reunescapedhtml = /[&<>"']/g,
rehasescapedhtml = regexp(reescapedhtml.source),
rehasunescapedhtml = regexp(reunescapedhtml.source);
/** used to match template delimiters. */
var reescape = /<%-([\s\s]+?)%>/g,
reevaluate = /<%([\s\s]+?)%>/g,
reinterpolate = /<%=([\s\s]+?)%>/g;
/** used to match property names within property paths. */
var reisdeepprop = /\.|\[(?:[^[\]]*|(["'])(?:(?!\1)[^\\]|\\.)*?\1)\]/,
reisplainprop = /^\w*$/,
repropname = /[^.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|$))/g;
/**
* used to match `regexp`
* [syntax characters](http://ecma-international.org/ecma-262/7.0/#sec-patterns).
*/
var reregexpchar = /[\\^$.*+?()[\]{}|]/g,
rehasregexpchar = regexp(reregexpchar.source);
/** used to match leading and trailing whitespace. */
var retrim = /^\s+|\s+$/g,
retrimstart = /^\s+/,
retrimend = /\s+$/;
/** used to match wrap detail comments. */
var rewrapcomment = /\{(?:\n\/\* \[wrapped with .+\] \*\/)?\n?/,
rewrapdetails = /\{\n\/\* \[wrapped with (.+)\] \*/,
resplitdetails = /,? & /;
/** used to match words composed of alphanumeric characters. */
var reasciiword = /[^\x00-\x2f\x3a-\x40\x5b-\x60\x7b-\x7f]+/g;
/** used to match backslashes in property paths. */
var reescapechar = /\\(\\)?/g;
/**
* used to match
* [es template delimiters](http://ecma-international.org/ecma-262/7.0/#sec-template-literal-lexical-components).
*/
var reestemplate = /\$\{([^\\}]*(?:\\.[^\\}]*)*)\}/g;
/** used to match `regexp` flags from their coerced string values. */
var reflags = /\w*$/;
/** used to detect bad signed hexadecimal string values. */
var reisbadhex = /^[-+]0x[0-9a-f]+$/i;
/** used to detect binary string values. */
var reisbinary = /^0b[01]+$/i;
/** used to detect host constructors (safari). */
var reishostctor = /^\[object .+?constructor\]$/;
/** used to detect octal string values. */
var reisoctal = /^0o[0-7]+$/i;
/** used to detect unsigned integer values. */
var reisuint = /^(?:0|[1-9]\d*)$/;
/** used to match latin unicode letters (excluding mathematical operators). */
var relatin = /[\xc0-\xd6\xd8-\xf6\xf8-\xff\u0100-\u017f]/g;
/** used to ensure capturing order of template delimiters. */
var renomatch = /($^)/;
/** used to match unescaped characters in compiled string literals. */
var reunescapedstring = /['\n\r\u2028\u2029\\]/g;
/** used to compose unicode character classes. */
var rsastralrange = '\\ud800-\\udfff',
rscombomarksrange = '\\u0300-\\u036f',
recombohalfmarksrange = '\\ufe20-\\ufe2f',
rscombosymbolsrange = '\\u20d0-\\u20ff',
rscomborange = rscombomarksrange + recombohalfmarksrange + rscombosymbolsrange,
rsdingbatrange = '\\u2700-\\u27bf',
rslowerrange = 'a-z\\xdf-\\xf6\\xf8-\\xff',
rsmathoprange = '\\xac\\xb1\\xd7\\xf7',
rsnoncharrange = '\\x00-\\x2f\\x3a-\\x40\\x5b-\\x60\\x7b-\\xbf',
rspunctuationrange = '\\u2000-\\u206f',
rsspacerange = ' \\t\\x0b\\f\\xa0\\ufeff\\n\\r\\u2028\\u2029\\u1680\\u180e\\u2000\\u2001\\u2002\\u2003\\u2004\\u2005\\u2006\\u2007\\u2008\\u2009\\u200a\\u202f\\u205f\\u3000',
rsupperrange = 'a-z\\xc0-\\xd6\\xd8-\\xde',
rsvarrange = '\\ufe0e\\ufe0f',
rsbreakrange = rsmathoprange + rsnoncharrange + rspunctuationrange + rsspacerange;
/** used to compose unicode capture groups. */
var rsapos = "['\u2019]",
rsastral = '[' + rsastralrange + ']',
rsbreak = '[' + rsbreakrange + ']',
rscombo = '[' + rscomborange + ']',
rsdigits = '\\d+',
rsdingbat = '[' + rsdingbatrange + ']',
rslower = '[' + rslowerrange + ']',
rsmisc = '[^' + rsastralrange + rsbreakrange + rsdigits + rsdingbatrange + rslowerrange + rsupperrange + ']',
rsfitz = '\\ud83c[\\udffb-\\udfff]',
rsmodifier = '(?:' + rscombo + '|' + rsfitz + ')',
rsnonastral = '[^' + rsastralrange + ']',
rsregional = '(?:\\ud83c[\\udde6-\\uddff]){2}',
rssurrpair = '[\\ud800-\\udbff][\\udc00-\\udfff]',
rsupper = '[' + rsupperrange + ']',
rszwj = '\\u200d';
/** used to compose unicode regexes. */
var rsmisclower = '(?:' + rslower + '|' + rsmisc + ')',
rsmiscupper = '(?:' + rsupper + '|' + rsmisc + ')',
rsoptcontrlower = '(?:' + rsapos + '(?:d|ll|m|re|s|t|ve))?',
rsoptcontrupper = '(?:' + rsapos + '(?:d|ll|m|re|s|t|ve))?',
reoptmod = rsmodifier + '?',
rsoptvar = '[' + rsvarrange + ']?',
rsoptjoin = '(?:' + rszwj + '(?:' + [rsnonastral, rsregional, rssurrpair].join('|') + ')' + rsoptvar + reoptmod + ')*',
rsordlower = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[a-z_])',
rsordupper = '\\d*(?:1st|2nd|3rd|(?![123])\\dth)(?=\\b|[a-z_])',
rsseq = rsoptvar + reoptmod + rsoptjoin,
rsemoji = '(?:' + [rsdingbat, rsregional, rssurrpair].join('|') + ')' + rsseq,
rssymbol = '(?:' + [rsnonastral + rscombo + '?', rscombo, rsregional, rssurrpair, rsastral].join('|') + ')';
/** used to match apostrophes. */
var reapos = regexp(rsapos, 'g');
/**
* used to match [combining diacritical marks](https://en.wikipedia.org/wiki/combining_diacritical_marks) and
* [combining diacritical marks for symbols](https://en.wikipedia.org/wiki/combining_diacritical_marks_for_symbols).
*/
var recombomark = regexp(rscombo, 'g');
/** used to match [string symbols](https://mathiasbynens.be/notes/javascript-unicode). */
var reunicode = regexp(rsfitz + '(?=' + rsfitz + ')|' + rssymbol + rsseq, 'g');
/** used to match complex or compound words. */
var reunicodeword = regexp([
rsupper + '?' + rslower + '+' + rsoptcontrlower + '(?=' + [rsbreak, rsupper, '$'].join('|') + ')',
rsmiscupper + '+' + rsoptcontrupper + '(?=' + [rsbreak, rsupper + rsmisclower, '$'].join('|') + ')',
rsupper + '?' + rsmisclower + '+' + rsoptcontrlower,
rsupper + '+' + rsoptcontrupper,
rsordupper,
rsordlower,
rsdigits,
rsemoji
].join('|'), 'g');
/** used to detect strings with [zero-width joiners or code points from the astral planes](http://eev.ee/blog/2015/09/12/dark-corners-of-unicode/). */
var rehasunicode = regexp('[' + rszwj + rsastralrange + rscomborange + rsvarrange + ']');
/** used to detect strings that need a more robust regexp to match words. */
var rehasunicodeword = /[a-z][a-z]|[a-z]{2,}[a-z]|[0-9][a-za-z]|[a-za-z][0-9]|[^a-za-z0-9 ]/;
/** used to assign default `context` object properties. */
var contextprops = [
'array', 'buffer', 'dataview', 'date', 'error', 'float32array', 'float64array',
'function', 'int8array', 'int16array', 'int32array', 'map', 'math', 'object',
'promise', 'regexp', 'set', 'string', 'symbol', 'typeerror', 'uint8array',
'uint8clampedarray', 'uint16array', 'uint32array', 'weakmap',
'_', 'cleartimeout', 'isfinite', 'parseint', 'settimeout'
];
/** used to make template sourceurls easier to identify. */
var templatecounter = -1;
/** used to identify `tostringtag` values of typed arrays. */
var typedarraytags = {};
typedarraytags[float32tag] = typedarraytags[float64tag] =
typedarraytags[int8tag] = typedarraytags[int16tag] =
typedarraytags[int32tag] = typedarraytags[uint8tag] =
typedarraytags[uint8clampedtag] = typedarraytags[uint16tag] =
typedarraytags[uint32tag] = true;
typedarraytags[argstag] = typedarraytags[arraytag] =
typedarraytags[arraybuffertag] = typedarraytags[booltag] =
typedarraytags[dataviewtag] = typedarraytags[datetag] =
typedarraytags[errortag] = typedarraytags[functag] =
typedarraytags[maptag] = typedarraytags[numbertag] =
typedarraytags[objecttag] = typedarraytags[regexptag] =
typedarraytags[settag] = typedarraytags[stringtag] =
typedarraytags[weakmaptag] = false;
/** used to identify `tostringtag` values supported by `_.clone`. */
var cloneabletags = {};
cloneabletags[argstag] = cloneabletags[arraytag] =
cloneabletags[arraybuffertag] = cloneabletags[dataviewtag] =
cloneabletags[booltag] = cloneabletags[datetag] =
cloneabletags[float32tag] = cloneabletags[float64tag] =
cloneabletags[int8tag] = cloneabletags[int16tag] =
cloneabletags[int32tag] = cloneabletags[maptag] =
cloneabletags[numbertag] = cloneabletags[objecttag] =
cloneabletags[regexptag] = cloneabletags[settag] =
cloneabletags[stringtag] = cloneabletags[symboltag] =
cloneabletags[uint8tag] = cloneabletags[uint8clampedtag] =
cloneabletags[uint16tag] = cloneabletags[uint32tag] = true;
cloneabletags[errortag] = cloneabletags[functag] =
cloneabletags[weakmaptag] = false;
/** used to map latin unicode letters to basic latin letters. */
var deburredletters = {
// latin-1 supplement block.
'\xc0': 'a', '\xc1': 'a', '\xc2': 'a', '\xc3': 'a', '\xc4': 'a', '\xc5': 'a',
'\xe0': 'a', '\xe1': 'a', '\xe2': 'a', '\xe3': 'a', '\xe4': 'a', '\xe5': 'a',
'\xc7': 'c', '\xe7': 'c',
'\xd0': 'd', '\xf0': 'd',
'\xc8': 'e', '\xc9': 'e', '\xca': 'e', '\xcb': 'e',
'\xe8': 'e', '\xe9': 'e', '\xea': 'e', '\xeb': 'e',
'\xcc': 'i', '\xcd': 'i', '\xce': 'i', '\xcf': 'i',
'\xec': 'i', '\xed': 'i', '\xee': 'i', '\xef': 'i',
'\xd1': 'n', '\xf1': 'n',
'\xd2': 'o', '\xd3': 'o', '\xd4': 'o', '\xd5': 'o', '\xd6': 'o', '\xd8': 'o',
'\xf2': 'o', '\xf3': 'o', '\xf4': 'o', '\xf5': 'o', '\xf6': 'o', '\xf8': 'o',
'\xd9': 'u', '\xda': 'u', '\xdb': 'u', '\xdc': 'u',
'\xf9': 'u', '\xfa': 'u', '\xfb': 'u', '\xfc': 'u',
'\xdd': 'y', '\xfd': 'y', '\xff': 'y',
'\xc6': 'ae', '\xe6': 'ae',
'\xde': 'th', '\xfe': 'th',
'\xdf': 'ss',
// latin extended-a block.
'\u0100': 'a', '\u0102': 'a', '\u0104': 'a',
'\u0101': 'a', '\u0103': 'a', '\u0105': 'a',
'\u0106': 'c', '\u0108': 'c', '\u010a': 'c', '\u010c': 'c',
'\u0107': 'c', '\u0109': 'c', '\u010b': 'c', '\u010d': 'c',
'\u010e': 'd', '\u0110': 'd', '\u010f': 'd', '\u0111': 'd',
'\u0112': 'e', '\u0114': 'e', '\u0116': 'e', '\u0118': 'e', '\u011a': 'e',
'\u0113': 'e', '\u0115': 'e', '\u0117': 'e', '\u0119': 'e', '\u011b': 'e',
'\u011c': 'g', '\u011e': 'g', '\u0120': 'g', '\u0122': 'g',
'\u011d': 'g', '\u011f': 'g', '\u0121': 'g', '\u0123': 'g',
'\u0124': 'h', '\u0126': 'h', '\u0125': 'h', '\u0127': 'h',
'\u0128': 'i', '\u012a': 'i', '\u012c': 'i', '\u012e': 'i', '\u0130': 'i',
'\u0129': 'i', '\u012b': 'i', '\u012d': 'i', '\u012f': 'i', '\u0131': 'i',
'\u0134': 'j', '\u0135': 'j',
'\u0136': 'k', '\u0137': 'k', '\u0138': 'k',
'\u0139': 'l', '\u013b': 'l', '\u013d': 'l', '\u013f': 'l', '\u0141': 'l',
'\u013a': 'l', '\u013c': 'l', '\u013e': 'l', '\u0140': 'l', '\u0142': 'l',
'\u0143': 'n', '\u0145': 'n', '\u0147': 'n', '\u014a': 'n',
'\u0144': 'n', '\u0146': 'n', '\u0148': 'n', '\u014b': 'n',
'\u014c': 'o', '\u014e': 'o', '\u0150': 'o',
'\u014d': 'o', '\u014f': 'o', '\u0151': 'o',
'\u0154': 'r', '\u0156': 'r', '\u0158': 'r',
'\u0155': 'r', '\u0157': 'r', '\u0159': 'r',
'\u015a': 's', '\u015c': 's', '\u015e': 's', '\u0160': 's',
'\u015b': 's', '\u015d': 's', '\u015f': 's', '\u0161': 's',
'\u0162': 't', '\u0164': 't', '\u0166': 't',
'\u0163': 't', '\u0165': 't', '\u0167': 't',
'\u0168': 'u', '\u016a': 'u', '\u016c': 'u', '\u016e': 'u', '\u0170': 'u', '\u0172': 'u',
'\u0169': 'u', '\u016b': 'u', '\u016d': 'u', '\u016f': 'u', '\u0171': 'u', '\u0173': 'u',
'\u0174': 'w', '\u0175': 'w',
'\u0176': 'y', '\u0177': 'y', '\u0178': 'y',
'\u0179': 'z', '\u017b': 'z', '\u017d': 'z',
'\u017a': 'z', '\u017c': 'z', '\u017e': 'z',
'\u0132': 'ij', '\u0133': 'ij',
'\u0152': 'oe', '\u0153': 'oe',
'\u0149': "'n", '\u017f': 's'
};
/** used to map characters to html entities. */
var htmlescapes = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
"'": '''
};
/** used to map html entities to characters. */
var htmlunescapes = {
'&': '&',
'<': '<',
'>': '>',
'"': '"',
''': "'"
};
/** used to escape characters for inclusion in compiled string literals. */
var stringescapes = {
'\\': '\\',
"'": "'",
'\n': 'n',
'\r': 'r',
'\u2028': 'u2028',
'\u2029': 'u2029'
};
/** built-in method references without a dependency on `root`. */
var freeparsefloat = parsefloat,
freeparseint = parseint;
/** detect free variable `global` from node.js. */
var freeglobal = typeof global == 'object' && global && global.object === object && global;
/** detect free variable `self`. */
var freeself = typeof self == 'object' && self && self.object === object && self;
/** used as a reference to the global object. */
var root = freeglobal || freeself || function('return this')();
/** detect free variable `exports`. */
var freeexports = typeof exports == 'object' && exports && !exports.nodetype && exports;
/** detect free variable `module`. */
var freemodule = freeexports && typeof module == 'object' && module && !module.nodetype && module;
/** detect the popular commonjs extension `module.exports`. */
var moduleexports = freemodule && freemodule.exports === freeexports;
/** detect free variable `process` from node.js. */
var freeprocess = moduleexports && freeglobal.process;
/** used to access faster node.js helpers. */
var nodeutil = (function() {
try {
return freeprocess && freeprocess.binding && freeprocess.binding('util');
} catch (e) {}
}());
/* node.js helper references. */
var nodeisarraybuffer = nodeutil && nodeutil.isarraybuffer,
nodeisdate = nodeutil && nodeutil.isdate,
nodeismap = nodeutil && nodeutil.ismap,
nodeisregexp = nodeutil && nodeutil.isregexp,
nodeisset = nodeutil && nodeutil.isset,
nodeistypedarray = nodeutil && nodeutil.istypedarray;
/*--------------------------------------------------------------------------*/
/**
* a faster alternative to `function#apply`, this function invokes `func`
* with the `this` binding of `thisarg` and the arguments of `args`.
*
* @private
* @param {function} func the function to invoke.
* @param {*} thisarg the `this` binding of `func`.
* @param {array} args the arguments to invoke `func` with.
* @returns {*} returns the result of `func`.
*/
function apply(func, thisarg, args) {
switch (args.length) {
case 0: return func.call(thisarg);
case 1: return func.call(thisarg, args[0]);
case 2: return func.call(thisarg, args[0], args[1]);
case 3: return func.call(thisarg, args[0], args[1], args[2]);
}
return func.apply(thisarg, args);
}
/**
* a specialized version of `baseaggregator` for arrays.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} setter the function to set `accumulator` values.
* @param {function} iteratee the iteratee to transform keys.
* @param {object} accumulator the initial aggregated object.
* @returns {function} returns `accumulator`.
*/
function arrayaggregator(array, setter, iteratee, accumulator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
var value = array[index];
setter(accumulator, value, iteratee(value), array);
}
return accumulator;
}
/**
* a specialized version of `_.foreach` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {array} returns `array`.
*/
function arrayeach(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (iteratee(array[index], index, array) === false) {
break;
}
}
return array;
}
/**
* a specialized version of `_.foreachright` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {array} returns `array`.
*/
function arrayeachright(array, iteratee) {
var length = array == null ? 0 : array.length;
while (length--) {
if (iteratee(array[length], length, array) === false) {
break;
}
}
return array;
}
/**
* a specialized version of `_.every` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} predicate the function invoked per iteration.
* @returns {boolean} returns `true` if all elements pass the predicate check,
* else `false`.
*/
function arrayevery(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (!predicate(array[index], index, array)) {
return false;
}
}
return true;
}
/**
* a specialized version of `_.filter` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} predicate the function invoked per iteration.
* @returns {array} returns the new filtered array.
*/
function arrayfilter(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length,
resindex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result[resindex++] = value;
}
}
return result;
}
/**
* a specialized version of `_.includes` for arrays without support for
* specifying an index to search from.
*
* @private
* @param {array} [array] the array to inspect.
* @param {*} target the value to search for.
* @returns {boolean} returns `true` if `target` is found, else `false`.
*/
function arrayincludes(array, value) {
var length = array == null ? 0 : array.length;
return !!length && baseindexof(array, value, 0) > -1;
}
/**
* this function is like `arrayincludes` except that it accepts a comparator.
*
* @private
* @param {array} [array] the array to inspect.
* @param {*} target the value to search for.
* @param {function} comparator the comparator invoked per element.
* @returns {boolean} returns `true` if `target` is found, else `false`.
*/
function arrayincludeswith(array, value, comparator) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (comparator(value, array[index])) {
return true;
}
}
return false;
}
/**
* a specialized version of `_.map` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {array} returns the new mapped array.
*/
function arraymap(array, iteratee) {
var index = -1,
length = array == null ? 0 : array.length,
result = array(length);
while (++index < length) {
result[index] = iteratee(array[index], index, array);
}
return result;
}
/**
* appends the elements of `values` to `array`.
*
* @private
* @param {array} array the array to modify.
* @param {array} values the values to append.
* @returns {array} returns `array`.
*/
function arraypush(array, values) {
var index = -1,
length = values.length,
offset = array.length;
while (++index < length) {
array[offset + index] = values[index];
}
return array;
}
/**
* a specialized version of `_.reduce` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @param {*} [accumulator] the initial value.
* @param {boolean} [initaccum] specify using the first element of `array` as
* the initial value.
* @returns {*} returns the accumulated value.
*/
function arrayreduce(array, iteratee, accumulator, initaccum) {
var index = -1,
length = array == null ? 0 : array.length;
if (initaccum && length) {
accumulator = array[++index];
}
while (++index < length) {
accumulator = iteratee(accumulator, array[index], index, array);
}
return accumulator;
}
/**
* a specialized version of `_.reduceright` for arrays without support for
* iteratee shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @param {*} [accumulator] the initial value.
* @param {boolean} [initaccum] specify using the last element of `array` as
* the initial value.
* @returns {*} returns the accumulated value.
*/
function arrayreduceright(array, iteratee, accumulator, initaccum) {
var length = array == null ? 0 : array.length;
if (initaccum && length) {
accumulator = array[--length];
}
while (length--) {
accumulator = iteratee(accumulator, array[length], length, array);
}
return accumulator;
}
/**
* a specialized version of `_.some` for arrays without support for iteratee
* shorthands.
*
* @private
* @param {array} [array] the array to iterate over.
* @param {function} predicate the function invoked per iteration.
* @returns {boolean} returns `true` if any element passes the predicate check,
* else `false`.
*/
function arraysome(array, predicate) {
var index = -1,
length = array == null ? 0 : array.length;
while (++index < length) {
if (predicate(array[index], index, array)) {
return true;
}
}
return false;
}
/**
* gets the size of an ascii `string`.
*
* @private
* @param {string} string the string inspect.
* @returns {number} returns the string size.
*/
var asciisize = baseproperty('length');
/**
* converts an ascii `string` to an array.
*
* @private
* @param {string} string the string to convert.
* @returns {array} returns the converted array.
*/
function asciitoarray(string) {
return string.split('');
}
/**
* splits an ascii `string` into an array of its words.
*
* @private
* @param {string} the string to inspect.
* @returns {array} returns the words of `string`.
*/
function asciiwords(string) {
return string.match(reasciiword) || [];
}
/**
* the base implementation of methods like `_.findkey` and `_.findlastkey`,
* without support for iteratee shorthands, which iterates over `collection`
* using `eachfunc`.
*
* @private
* @param {array|object} collection the collection to inspect.
* @param {function} predicate the function invoked per iteration.
* @param {function} eachfunc the function to iterate over `collection`.
* @returns {*} returns the found element or its key, else `undefined`.
*/
function basefindkey(collection, predicate, eachfunc) {
var result;
eachfunc(collection, function(value, key, collection) {
if (predicate(value, key, collection)) {
result = key;
return false;
}
});
return result;
}
/**
* the base implementation of `_.findindex` and `_.findlastindex` without
* support for iteratee shorthands.
*
* @private
* @param {array} array the array to inspect.
* @param {function} predicate the function invoked per iteration.
* @param {number} fromindex the index to search from.
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {number} returns the index of the matched value, else `-1`.
*/
function basefindindex(array, predicate, fromindex, fromright) {
var length = array.length,
index = fromindex + (fromright ? 1 : -1);
while ((fromright ? index-- : ++index < length)) {
if (predicate(array[index], index, array)) {
return index;
}
}
return -1;
}
/**
* the base implementation of `_.indexof` without `fromindex` bounds checks.
*
* @private
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @param {number} fromindex the index to search from.
* @returns {number} returns the index of the matched value, else `-1`.
*/
function baseindexof(array, value, fromindex) {
return value === value
? strictindexof(array, value, fromindex)
: basefindindex(array, baseisnan, fromindex);
}
/**
* this function is like `baseindexof` except that it accepts a comparator.
*
* @private
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @param {number} fromindex the index to search from.
* @param {function} comparator the comparator invoked per element.
* @returns {number} returns the index of the matched value, else `-1`.
*/
function baseindexofwith(array, value, fromindex, comparator) {
var index = fromindex - 1,
length = array.length;
while (++index < length) {
if (comparator(array[index], value)) {
return index;
}
}
return -1;
}
/**
* the base implementation of `_.isnan` without support for number objects.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is `nan`, else `false`.
*/
function baseisnan(value) {
return value !== value;
}
/**
* the base implementation of `_.mean` and `_.meanby` without support for
* iteratee shorthands.
*
* @private
* @param {array} array the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {number} returns the mean.
*/
function basemean(array, iteratee) {
var length = array == null ? 0 : array.length;
return length ? (basesum(array, iteratee) / length) : nan;
}
/**
* the base implementation of `_.property` without support for deep paths.
*
* @private
* @param {string} key the key of the property to get.
* @returns {function} returns the new accessor function.
*/
function baseproperty(key) {
return function(object) {
return object == null ? undefined : object[key];
};
}
/**
* the base implementation of `_.propertyof` without support for deep paths.
*
* @private
* @param {object} object the object to query.
* @returns {function} returns the new accessor function.
*/
function basepropertyof(object) {
return function(key) {
return object == null ? undefined : object[key];
};
}
/**
* the base implementation of `_.reduce` and `_.reduceright`, without support
* for iteratee shorthands, which iterates over `collection` using `eachfunc`.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @param {*} accumulator the initial value.
* @param {boolean} initaccum specify using the first or last element of
* `collection` as the initial value.
* @param {function} eachfunc the function to iterate over `collection`.
* @returns {*} returns the accumulated value.
*/
function basereduce(collection, iteratee, accumulator, initaccum, eachfunc) {
eachfunc(collection, function(value, index, collection) {
accumulator = initaccum
? (initaccum = false, value)
: iteratee(accumulator, value, index, collection);
});
return accumulator;
}
/**
* the base implementation of `_.sortby` which uses `comparer` to define the
* sort order of `array` and replaces criteria objects with their corresponding
* values.
*
* @private
* @param {array} array the array to sort.
* @param {function} comparer the function to define sort order.
* @returns {array} returns `array`.
*/
function basesortby(array, comparer) {
var length = array.length;
array.sort(comparer);
while (length--) {
array[length] = array[length].value;
}
return array;
}
/**
* the base implementation of `_.sum` and `_.sumby` without support for
* iteratee shorthands.
*
* @private
* @param {array} array the array to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {number} returns the sum.
*/
function basesum(array, iteratee) {
var result,
index = -1,
length = array.length;
while (++index < length) {
var current = iteratee(array[index]);
if (current !== undefined) {
result = result === undefined ? current : (result + current);
}
}
return result;
}
/**
* the base implementation of `_.times` without support for iteratee shorthands
* or max array length checks.
*
* @private
* @param {number} n the number of times to invoke `iteratee`.
* @param {function} iteratee the function invoked per iteration.
* @returns {array} returns the array of results.
*/
function basetimes(n, iteratee) {
var index = -1,
result = array(n);
while (++index < n) {
result[index] = iteratee(index);
}
return result;
}
/**
* the base implementation of `_.topairs` and `_.topairsin` which creates an array
* of key-value pairs for `object` corresponding to the property names of `props`.
*
* @private
* @param {object} object the object to query.
* @param {array} props the property names to get values for.
* @returns {object} returns the key-value pairs.
*/
function basetopairs(object, props) {
return arraymap(props, function(key) {
return [key, object[key]];
});
}
/**
* the base implementation of `_.unary` without support for storing metadata.
*
* @private
* @param {function} func the function to cap arguments for.
* @returns {function} returns the new capped function.
*/
function baseunary(func) {
return function(value) {
return func(value);
};
}
/**
* the base implementation of `_.values` and `_.valuesin` which creates an
* array of `object` property values corresponding to the property names
* of `props`.
*
* @private
* @param {object} object the object to query.
* @param {array} props the property names to get values for.
* @returns {object} returns the array of property values.
*/
function basevalues(object, props) {
return arraymap(props, function(key) {
return object[key];
});
}
/**
* checks if a `cache` value for `key` exists.
*
* @private
* @param {object} cache the cache to query.
* @param {string} key the key of the entry to check.
* @returns {boolean} returns `true` if an entry for `key` exists, else `false`.
*/
function cachehas(cache, key) {
return cache.has(key);
}
/**
* used by `_.trim` and `_.trimstart` to get the index of the first string symbol
* that is not found in the character symbols.
*
* @private
* @param {array} strsymbols the string symbols to inspect.
* @param {array} chrsymbols the character symbols to find.
* @returns {number} returns the index of the first unmatched string symbol.
*/
function charsstartindex(strsymbols, chrsymbols) {
var index = -1,
length = strsymbols.length;
while (++index < length && baseindexof(chrsymbols, strsymbols[index], 0) > -1) {}
return index;
}
/**
* used by `_.trim` and `_.trimend` to get the index of the last string symbol
* that is not found in the character symbols.
*
* @private
* @param {array} strsymbols the string symbols to inspect.
* @param {array} chrsymbols the character symbols to find.
* @returns {number} returns the index of the last unmatched string symbol.
*/
function charsendindex(strsymbols, chrsymbols) {
var index = strsymbols.length;
while (index-- && baseindexof(chrsymbols, strsymbols[index], 0) > -1) {}
return index;
}
/**
* gets the number of `placeholder` occurrences in `array`.
*
* @private
* @param {array} array the array to inspect.
* @param {*} placeholder the placeholder to search for.
* @returns {number} returns the placeholder count.
*/
function countholders(array, placeholder) {
var length = array.length,
result = 0;
while (length--) {
if (array[length] === placeholder) {
++result;
}
}
return result;
}
/**
* used by `_.deburr` to convert latin-1 supplement and latin extended-a
* letters to basic latin letters.
*
* @private
* @param {string} letter the matched letter to deburr.
* @returns {string} returns the deburred letter.
*/
var deburrletter = basepropertyof(deburredletters);
/**
* used by `_.escape` to convert characters to html entities.
*
* @private
* @param {string} chr the matched character to escape.
* @returns {string} returns the escaped character.
*/
var escapehtmlchar = basepropertyof(htmlescapes);
/**
* used by `_.template` to escape characters for inclusion in compiled string literals.
*
* @private
* @param {string} chr the matched character to escape.
* @returns {string} returns the escaped character.
*/
function escapestringchar(chr) {
return '\\' + stringescapes[chr];
}
/**
* gets the value at `key` of `object`.
*
* @private
* @param {object} [object] the object to query.
* @param {string} key the key of the property to get.
* @returns {*} returns the property value.
*/
function getvalue(object, key) {
return object == null ? undefined : object[key];
}
/**
* checks if `string` contains unicode symbols.
*
* @private
* @param {string} string the string to inspect.
* @returns {boolean} returns `true` if a symbol is found, else `false`.
*/
function hasunicode(string) {
return rehasunicode.test(string);
}
/**
* checks if `string` contains a word composed of unicode symbols.
*
* @private
* @param {string} string the string to inspect.
* @returns {boolean} returns `true` if a word is found, else `false`.
*/
function hasunicodeword(string) {
return rehasunicodeword.test(string);
}
/**
* converts `iterator` to an array.
*
* @private
* @param {object} iterator the iterator to convert.
* @returns {array} returns the converted array.
*/
function iteratortoarray(iterator) {
var data,
result = [];
while (!(data = iterator.next()).done) {
result.push(data.value);
}
return result;
}
/**
* converts `map` to its key-value pairs.
*
* @private
* @param {object} map the map to convert.
* @returns {array} returns the key-value pairs.
*/
function maptoarray(map) {
var index = -1,
result = array(map.size);
map.foreach(function(value, key) {
result[++index] = [key, value];
});
return result;
}
/**
* creates a unary function that invokes `func` with its argument transformed.
*
* @private
* @param {function} func the function to wrap.
* @param {function} transform the argument transform.
* @returns {function} returns the new function.
*/
function overarg(func, transform) {
return function(arg) {
return func(transform(arg));
};
}
/**
* replaces all `placeholder` elements in `array` with an internal placeholder
* and returns an array of their indexes.
*
* @private
* @param {array} array the array to modify.
* @param {*} placeholder the placeholder to replace.
* @returns {array} returns the new array of placeholder indexes.
*/
function replaceholders(array, placeholder) {
var index = -1,
length = array.length,
resindex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value === placeholder || value === placeholder) {
array[index] = placeholder;
result[resindex++] = index;
}
}
return result;
}
/**
* gets the value at `key`, unless `key` is "__proto__".
*
* @private
* @param {object} object the object to query.
* @param {string} key the key of the property to get.
* @returns {*} returns the property value.
*/
function safeget(object, key) {
return key == '__proto__'
? undefined
: object[key];
}
/**
* converts `set` to an array of its values.
*
* @private
* @param {object} set the set to convert.
* @returns {array} returns the values.
*/
function settoarray(set) {
var index = -1,
result = array(set.size);
set.foreach(function(value) {
result[++index] = value;
});
return result;
}
/**
* converts `set` to its value-value pairs.
*
* @private
* @param {object} set the set to convert.
* @returns {array} returns the value-value pairs.
*/
function settopairs(set) {
var index = -1,
result = array(set.size);
set.foreach(function(value) {
result[++index] = [value, value];
});
return result;
}
/**
* a specialized version of `_.indexof` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @param {number} fromindex the index to search from.
* @returns {number} returns the index of the matched value, else `-1`.
*/
function strictindexof(array, value, fromindex) {
var index = fromindex - 1,
length = array.length;
while (++index < length) {
if (array[index] === value) {
return index;
}
}
return -1;
}
/**
* a specialized version of `_.lastindexof` which performs strict equality
* comparisons of values, i.e. `===`.
*
* @private
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @param {number} fromindex the index to search from.
* @returns {number} returns the index of the matched value, else `-1`.
*/
function strictlastindexof(array, value, fromindex) {
var index = fromindex + 1;
while (index--) {
if (array[index] === value) {
return index;
}
}
return index;
}
/**
* gets the number of symbols in `string`.
*
* @private
* @param {string} string the string to inspect.
* @returns {number} returns the string size.
*/
function stringsize(string) {
return hasunicode(string)
? unicodesize(string)
: asciisize(string);
}
/**
* converts `string` to an array.
*
* @private
* @param {string} string the string to convert.
* @returns {array} returns the converted array.
*/
function stringtoarray(string) {
return hasunicode(string)
? unicodetoarray(string)
: asciitoarray(string);
}
/**
* used by `_.unescape` to convert html entities to characters.
*
* @private
* @param {string} chr the matched character to unescape.
* @returns {string} returns the unescaped character.
*/
var unescapehtmlchar = basepropertyof(htmlunescapes);
/**
* gets the size of a unicode `string`.
*
* @private
* @param {string} string the string inspect.
* @returns {number} returns the string size.
*/
function unicodesize(string) {
var result = reunicode.lastindex = 0;
while (reunicode.test(string)) {
++result;
}
return result;
}
/**
* converts a unicode `string` to an array.
*
* @private
* @param {string} string the string to convert.
* @returns {array} returns the converted array.
*/
function unicodetoarray(string) {
return string.match(reunicode) || [];
}
/**
* splits a unicode `string` into an array of its words.
*
* @private
* @param {string} the string to inspect.
* @returns {array} returns the words of `string`.
*/
function unicodewords(string) {
return string.match(reunicodeword) || [];
}
/*--------------------------------------------------------------------------*/
/**
* create a new pristine `lodash` function using the `context` object.
*
* @static
* @memberof _
* @since 1.1.0
* @category util
* @param {object} [context=root] the context object.
* @returns {function} returns a new `lodash` function.
* @example
*
* _.mixin({ 'foo': _.constant('foo') });
*
* var lodash = _.runincontext();
* lodash.mixin({ 'bar': lodash.constant('bar') });
*
* _.isfunction(_.foo);
* // => true
* _.isfunction(_.bar);
* // => false
*
* lodash.isfunction(lodash.foo);
* // => false
* lodash.isfunction(lodash.bar);
* // => true
*
* // create a suped-up `defer` in node.js.
* var defer = _.runincontext({ 'settimeout': setimmediate }).defer;
*/
var runincontext = (function runincontext(context) {
context = context == null ? root : _.defaults(root.object(), context, _.pick(root, contextprops));
/** built-in constructor references. */
var array = context.array,
date = context.date,
error = context.error,
function = context.function,
math = context.math,
object = context.object,
regexp = context.regexp,
string = context.string,
typeerror = context.typeerror;
/** used for built-in method references. */
var arrayproto = array.prototype,
funcproto = function.prototype,
objectproto = object.prototype;
/** used to detect overreaching core-js shims. */
var corejsdata = context['__core-js_shared__'];
/** used to resolve the decompiled source of functions. */
var functostring = funcproto.tostring;
/** used to check objects for own properties. */
var hasownproperty = objectproto.hasownproperty;
/** used to generate unique ids. */
var idcounter = 0;
/** used to detect methods masquerading as native. */
var masksrckey = (function() {
var uid = /[^.]+$/.exec(corejsdata && corejsdata.keys && corejsdata.keys.ie_proto || '');
return uid ? ('symbol(src)_1.' + uid) : '';
}());
/**
* used to resolve the
* [`tostringtag`](http://ecma-international.org/ecma-262/7.0/#sec-object.prototype.tostring)
* of values.
*/
var nativeobjecttostring = objectproto.tostring;
/** used to infer the `object` constructor. */
var objectctorstring = functostring.call(object);
/** used to restore the original `_` reference in `_.noconflict`. */
var olddash = root._;
/** used to detect if a method is native. */
var reisnative = regexp('^' +
functostring.call(hasownproperty).replace(reregexpchar, '\\$&')
.replace(/hasownproperty|(function).*?(?=\\\()| for .+?(?=\\\])/g, '$1.*?') + '$'
);
/** built-in value references. */
var buffer = moduleexports ? context.buffer : undefined,
symbol = context.symbol,
uint8array = context.uint8array,
allocunsafe = buffer ? buffer.allocunsafe : undefined,
getprototype = overarg(object.getprototypeof, object),
objectcreate = object.create,
propertyisenumerable = objectproto.propertyisenumerable,
splice = arrayproto.splice,
spreadablesymbol = symbol ? symbol.isconcatspreadable : undefined,
symiterator = symbol ? symbol.iterator : undefined,
symtostringtag = symbol ? symbol.tostringtag : undefined;
var defineproperty = (function() {
try {
var func = getnative(object, 'defineproperty');
func({}, '', {});
return func;
} catch (e) {}
}());
/** mocked built-ins. */
var ctxcleartimeout = context.cleartimeout !== root.cleartimeout && context.cleartimeout,
ctxnow = date && date.now !== root.date.now && date.now,
ctxsettimeout = context.settimeout !== root.settimeout && context.settimeout;
/* built-in method references for those with the same name as other `lodash` methods. */
var nativeceil = math.ceil,
nativefloor = math.floor,
nativegetsymbols = object.getownpropertysymbols,
nativeisbuffer = buffer ? buffer.isbuffer : undefined,
nativeisfinite = context.isfinite,
nativejoin = arrayproto.join,
nativekeys = overarg(object.keys, object),
nativemax = math.max,
nativemin = math.min,
nativenow = date.now,
nativeparseint = context.parseint,
nativerandom = math.random,
nativereverse = arrayproto.reverse;
/* built-in method references that are verified to be native. */
var dataview = getnative(context, 'dataview'),
map = getnative(context, 'map'),
promise = getnative(context, 'promise'),
set = getnative(context, 'set'),
weakmap = getnative(context, 'weakmap'),
nativecreate = getnative(object, 'create');
/** used to store function metadata. */
var metamap = weakmap && new weakmap;
/** used to lookup unminified function names. */
var realnames = {};
/** used to detect maps, sets, and weakmaps. */
var dataviewctorstring = tosource(dataview),
mapctorstring = tosource(map),
promisectorstring = tosource(promise),
setctorstring = tosource(set),
weakmapctorstring = tosource(weakmap);
/** used to convert symbols to primitives and strings. */
var symbolproto = symbol ? symbol.prototype : undefined,
symbolvalueof = symbolproto ? symbolproto.valueof : undefined,
symboltostring = symbolproto ? symbolproto.tostring : undefined;
/*------------------------------------------------------------------------*/
/**
* creates a `lodash` object which wraps `value` to enable implicit method
* chain sequences. methods that operate on and return arrays, collections,
* and functions can be chained together. methods that retrieve a single value
* or may return a primitive value will automatically end the chain sequence
* and return the unwrapped value. otherwise, the value must be unwrapped
* with `_#value`.
*
* explicit chain sequences, which must be unwrapped with `_#value`, may be
* enabled using `_.chain`.
*
* the execution of chained methods is lazy, that is, it's deferred until
* `_#value` is implicitly or explicitly called.
*
* lazy evaluation allows several methods to support shortcut fusion.
* shortcut fusion is an optimization to merge iteratee calls; this avoids
* the creation of intermediate arrays and can greatly reduce the number of
* iteratee executions. sections of a chain sequence qualify for shortcut
* fusion if the section is applied to an array and iteratees accept only
* one argument. the heuristic for whether a section qualifies for shortcut
* fusion is subject to change.
*
* chaining is supported in custom builds as long as the `_#value` method is
* directly or indirectly included in the build.
*
* in addition to lodash methods, wrappers have `array` and `string` methods.
*
* the wrapper `array` methods are:
* `concat`, `join`, `pop`, `push`, `shift`, `sort`, `splice`, and `unshift`
*
* the wrapper `string` methods are:
* `replace` and `split`
*
* the wrapper methods that support shortcut fusion are:
* `at`, `compact`, `drop`, `dropright`, `dropwhile`, `filter`, `find`,
* `findlast`, `head`, `initial`, `last`, `map`, `reject`, `reverse`, `slice`,
* `tail`, `take`, `takeright`, `takerightwhile`, `takewhile`, and `toarray`
*
* the chainable wrapper methods are:
* `after`, `ary`, `assign`, `assignin`, `assigninwith`, `assignwith`, `at`,
* `before`, `bind`, `bindall`, `bindkey`, `castarray`, `chain`, `chunk`,
* `commit`, `compact`, `concat`, `conforms`, `constant`, `countby`, `create`,
* `curry`, `debounce`, `defaults`, `defaultsdeep`, `defer`, `delay`,
* `difference`, `differenceby`, `differencewith`, `drop`, `dropright`,
* `droprightwhile`, `dropwhile`, `extend`, `extendwith`, `fill`, `filter`,
* `flatmap`, `flatmapdeep`, `flatmapdepth`, `flatten`, `flattendeep`,
* `flattendepth`, `flip`, `flow`, `flowright`, `frompairs`, `functions`,
* `functionsin`, `groupby`, `initial`, `intersection`, `intersectionby`,
* `intersectionwith`, `invert`, `invertby`, `invokemap`, `iteratee`, `keyby`,
* `keys`, `keysin`, `map`, `mapkeys`, `mapvalues`, `matches`, `matchesproperty`,
* `memoize`, `merge`, `mergewith`, `method`, `methodof`, `mixin`, `negate`,
* `ntharg`, `omit`, `omitby`, `once`, `orderby`, `over`, `overargs`,
* `overevery`, `oversome`, `partial`, `partialright`, `partition`, `pick`,
* `pickby`, `plant`, `property`, `propertyof`, `pull`, `pullall`, `pullallby`,
* `pullallwith`, `pullat`, `push`, `range`, `rangeright`, `rearg`, `reject`,
* `remove`, `rest`, `reverse`, `samplesize`, `set`, `setwith`, `shuffle`,
* `slice`, `sort`, `sortby`, `splice`, `spread`, `tail`, `take`, `takeright`,
* `takerightwhile`, `takewhile`, `tap`, `throttle`, `thru`, `toarray`,
* `topairs`, `topairsin`, `topath`, `toplainobject`, `transform`, `unary`,
* `union`, `unionby`, `unionwith`, `uniq`, `uniqby`, `uniqwith`, `unset`,
* `unshift`, `unzip`, `unzipwith`, `update`, `updatewith`, `values`,
* `valuesin`, `without`, `wrap`, `xor`, `xorby`, `xorwith`, `zip`,
* `zipobject`, `zipobjectdeep`, and `zipwith`
*
* the wrapper methods that are **not** chainable by default are:
* `add`, `attempt`, `camelcase`, `capitalize`, `ceil`, `clamp`, `clone`,
* `clonedeep`, `clonedeepwith`, `clonewith`, `conformsto`, `deburr`,
* `defaultto`, `divide`, `each`, `eachright`, `endswith`, `eq`, `escape`,
* `escaperegexp`, `every`, `find`, `findindex`, `findkey`, `findlast`,
* `findlastindex`, `findlastkey`, `first`, `floor`, `foreach`, `foreachright`,
* `forin`, `forinright`, `forown`, `forownright`, `get`, `gt`, `gte`, `has`,
* `hasin`, `head`, `identity`, `includes`, `indexof`, `inrange`, `invoke`,
* `isarguments`, `isarray`, `isarraybuffer`, `isarraylike`, `isarraylikeobject`,
* `isboolean`, `isbuffer`, `isdate`, `iselement`, `isempty`, `isequal`,
* `isequalwith`, `iserror`, `isfinite`, `isfunction`, `isinteger`, `islength`,
* `ismap`, `ismatch`, `ismatchwith`, `isnan`, `isnative`, `isnil`, `isnull`,
* `isnumber`, `isobject`, `isobjectlike`, `isplainobject`, `isregexp`,
* `issafeinteger`, `isset`, `isstring`, `isundefined`, `istypedarray`,
* `isweakmap`, `isweakset`, `join`, `kebabcase`, `last`, `lastindexof`,
* `lowercase`, `lowerfirst`, `lt`, `lte`, `max`, `maxby`, `mean`, `meanby`,
* `min`, `minby`, `multiply`, `noconflict`, `noop`, `now`, `nth`, `pad`,
* `padend`, `padstart`, `parseint`, `pop`, `random`, `reduce`, `reduceright`,
* `repeat`, `result`, `round`, `runincontext`, `sample`, `shift`, `size`,
* `snakecase`, `some`, `sortedindex`, `sortedindexby`, `sortedlastindex`,
* `sortedlastindexby`, `startcase`, `startswith`, `stubarray`, `stubfalse`,
* `stubobject`, `stubstring`, `stubtrue`, `subtract`, `sum`, `sumby`,
* `template`, `times`, `tofinite`, `tointeger`, `tojson`, `tolength`,
* `tolower`, `tonumber`, `tosafeinteger`, `tostring`, `toupper`, `trim`,
* `trimend`, `trimstart`, `truncate`, `unescape`, `uniqueid`, `uppercase`,
* `upperfirst`, `value`, and `words`
*
* @name _
* @constructor
* @category seq
* @param {*} value the value to wrap in a `lodash` instance.
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* function square(n) {
* return n * n;
* }
*
* var wrapped = _([1, 2, 3]);
*
* // returns an unwrapped value.
* wrapped.reduce(_.add);
* // => 6
*
* // returns a wrapped value.
* var squares = wrapped.map(square);
*
* _.isarray(squares);
* // => false
*
* _.isarray(squares.value());
* // => true
*/
function lodash(value) {
if (isobjectlike(value) && !isarray(value) && !(value instanceof lazywrapper)) {
if (value instanceof lodashwrapper) {
return value;
}
if (hasownproperty.call(value, '__wrapped__')) {
return wrapperclone(value);
}
}
return new lodashwrapper(value);
}
/**
* the base implementation of `_.create` without support for assigning
* properties to the created object.
*
* @private
* @param {object} proto the object to inherit from.
* @returns {object} returns the new object.
*/
var basecreate = (function() {
function object() {}
return function(proto) {
if (!isobject(proto)) {
return {};
}
if (objectcreate) {
return objectcreate(proto);
}
object.prototype = proto;
var result = new object;
object.prototype = undefined;
return result;
};
}());
/**
* the function whose prototype chain sequence wrappers inherit from.
*
* @private
*/
function baselodash() {
// no operation performed.
}
/**
* the base constructor for creating `lodash` wrapper objects.
*
* @private
* @param {*} value the value to wrap.
* @param {boolean} [chainall] enable explicit method chain sequences.
*/
function lodashwrapper(value, chainall) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__chain__ = !!chainall;
this.__index__ = 0;
this.__values__ = undefined;
}
/**
* by default, the template delimiters used by lodash are like those in
* embedded ruby (erb) as well as es2015 template strings. change the
* following template settings to use alternative delimiters.
*
* @static
* @memberof _
* @type {object}
*/
lodash.templatesettings = {
/**
* used to detect `data` property values to be html-escaped.
*
* @memberof _.templatesettings
* @type {regexp}
*/
'escape': reescape,
/**
* used to detect code to be evaluated.
*
* @memberof _.templatesettings
* @type {regexp}
*/
'evaluate': reevaluate,
/**
* used to detect `data` property values to inject.
*
* @memberof _.templatesettings
* @type {regexp}
*/
'interpolate': reinterpolate,
/**
* used to reference the data object in the template text.
*
* @memberof _.templatesettings
* @type {string}
*/
'variable': '',
/**
* used to import variables into the compiled template.
*
* @memberof _.templatesettings
* @type {object}
*/
'imports': {
/**
* a reference to the `lodash` function.
*
* @memberof _.templatesettings.imports
* @type {function}
*/
'_': lodash
}
};
// ensure wrappers are instances of `baselodash`.
lodash.prototype = baselodash.prototype;
lodash.prototype.constructor = lodash;
lodashwrapper.prototype = basecreate(baselodash.prototype);
lodashwrapper.prototype.constructor = lodashwrapper;
/*------------------------------------------------------------------------*/
/**
* creates a lazy wrapper object which wraps `value` to enable lazy evaluation.
*
* @private
* @constructor
* @param {*} value the value to wrap.
*/
function lazywrapper(value) {
this.__wrapped__ = value;
this.__actions__ = [];
this.__dir__ = 1;
this.__filtered__ = false;
this.__iteratees__ = [];
this.__takecount__ = max_array_length;
this.__views__ = [];
}
/**
* creates a clone of the lazy wrapper object.
*
* @private
* @name clone
* @memberof lazywrapper
* @returns {object} returns the cloned `lazywrapper` object.
*/
function lazyclone() {
var result = new lazywrapper(this.__wrapped__);
result.__actions__ = copyarray(this.__actions__);
result.__dir__ = this.__dir__;
result.__filtered__ = this.__filtered__;
result.__iteratees__ = copyarray(this.__iteratees__);
result.__takecount__ = this.__takecount__;
result.__views__ = copyarray(this.__views__);
return result;
}
/**
* reverses the direction of lazy iteration.
*
* @private
* @name reverse
* @memberof lazywrapper
* @returns {object} returns the new reversed `lazywrapper` object.
*/
function lazyreverse() {
if (this.__filtered__) {
var result = new lazywrapper(this);
result.__dir__ = -1;
result.__filtered__ = true;
} else {
result = this.clone();
result.__dir__ *= -1;
}
return result;
}
/**
* extracts the unwrapped value from its lazy wrapper.
*
* @private
* @name value
* @memberof lazywrapper
* @returns {*} returns the unwrapped value.
*/
function lazyvalue() {
var array = this.__wrapped__.value(),
dir = this.__dir__,
isarr = isarray(array),
isright = dir < 0,
arrlength = isarr ? array.length : 0,
view = getview(0, arrlength, this.__views__),
start = view.start,
end = view.end,
length = end - start,
index = isright ? end : (start - 1),
iteratees = this.__iteratees__,
iterlength = iteratees.length,
resindex = 0,
takecount = nativemin(length, this.__takecount__);
if (!isarr || (!isright && arrlength == length && takecount == length)) {
return basewrappervalue(array, this.__actions__);
}
var result = [];
outer:
while (length-- && resindex < takecount) {
index += dir;
var iterindex = -1,
value = array[index];
while (++iterindex < iterlength) {
var data = iteratees[iterindex],
iteratee = data.iteratee,
type = data.type,
computed = iteratee(value);
if (type == lazy_map_flag) {
value = computed;
} else if (!computed) {
if (type == lazy_filter_flag) {
continue outer;
} else {
break outer;
}
}
}
result[resindex++] = value;
}
return result;
}
// ensure `lazywrapper` is an instance of `baselodash`.
lazywrapper.prototype = basecreate(baselodash.prototype);
lazywrapper.prototype.constructor = lazywrapper;
/*------------------------------------------------------------------------*/
/**
* creates a hash object.
*
* @private
* @constructor
* @param {array} [entries] the key-value pairs to cache.
*/
function hash(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* removes all key-value entries from the hash.
*
* @private
* @name clear
* @memberof hash
*/
function hashclear() {
this.__data__ = nativecreate ? nativecreate(null) : {};
this.size = 0;
}
/**
* removes `key` and its value from the hash.
*
* @private
* @name delete
* @memberof hash
* @param {object} hash the hash to modify.
* @param {string} key the key of the value to remove.
* @returns {boolean} returns `true` if the entry was removed, else `false`.
*/
function hashdelete(key) {
var result = this.has(key) && delete this.__data__[key];
this.size -= result ? 1 : 0;
return result;
}
/**
* gets the hash value for `key`.
*
* @private
* @name get
* @memberof hash
* @param {string} key the key of the value to get.
* @returns {*} returns the entry value.
*/
function hashget(key) {
var data = this.__data__;
if (nativecreate) {
var result = data[key];
return result === hash_undefined ? undefined : result;
}
return hasownproperty.call(data, key) ? data[key] : undefined;
}
/**
* checks if a hash value for `key` exists.
*
* @private
* @name has
* @memberof hash
* @param {string} key the key of the entry to check.
* @returns {boolean} returns `true` if an entry for `key` exists, else `false`.
*/
function hashhas(key) {
var data = this.__data__;
return nativecreate ? (data[key] !== undefined) : hasownproperty.call(data, key);
}
/**
* sets the hash `key` to `value`.
*
* @private
* @name set
* @memberof hash
* @param {string} key the key of the value to set.
* @param {*} value the value to set.
* @returns {object} returns the hash instance.
*/
function hashset(key, value) {
var data = this.__data__;
this.size += this.has(key) ? 0 : 1;
data[key] = (nativecreate && value === undefined) ? hash_undefined : value;
return this;
}
// add methods to `hash`.
hash.prototype.clear = hashclear;
hash.prototype['delete'] = hashdelete;
hash.prototype.get = hashget;
hash.prototype.has = hashhas;
hash.prototype.set = hashset;
/*------------------------------------------------------------------------*/
/**
* creates an list cache object.
*
* @private
* @constructor
* @param {array} [entries] the key-value pairs to cache.
*/
function listcache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* removes all key-value entries from the list cache.
*
* @private
* @name clear
* @memberof listcache
*/
function listcacheclear() {
this.__data__ = [];
this.size = 0;
}
/**
* removes `key` and its value from the list cache.
*
* @private
* @name delete
* @memberof listcache
* @param {string} key the key of the value to remove.
* @returns {boolean} returns `true` if the entry was removed, else `false`.
*/
function listcachedelete(key) {
var data = this.__data__,
index = associndexof(data, key);
if (index < 0) {
return false;
}
var lastindex = data.length - 1;
if (index == lastindex) {
data.pop();
} else {
splice.call(data, index, 1);
}
--this.size;
return true;
}
/**
* gets the list cache value for `key`.
*
* @private
* @name get
* @memberof listcache
* @param {string} key the key of the value to get.
* @returns {*} returns the entry value.
*/
function listcacheget(key) {
var data = this.__data__,
index = associndexof(data, key);
return index < 0 ? undefined : data[index][1];
}
/**
* checks if a list cache value for `key` exists.
*
* @private
* @name has
* @memberof listcache
* @param {string} key the key of the entry to check.
* @returns {boolean} returns `true` if an entry for `key` exists, else `false`.
*/
function listcachehas(key) {
return associndexof(this.__data__, key) > -1;
}
/**
* sets the list cache `key` to `value`.
*
* @private
* @name set
* @memberof listcache
* @param {string} key the key of the value to set.
* @param {*} value the value to set.
* @returns {object} returns the list cache instance.
*/
function listcacheset(key, value) {
var data = this.__data__,
index = associndexof(data, key);
if (index < 0) {
++this.size;
data.push([key, value]);
} else {
data[index][1] = value;
}
return this;
}
// add methods to `listcache`.
listcache.prototype.clear = listcacheclear;
listcache.prototype['delete'] = listcachedelete;
listcache.prototype.get = listcacheget;
listcache.prototype.has = listcachehas;
listcache.prototype.set = listcacheset;
/*------------------------------------------------------------------------*/
/**
* creates a map cache object to store key-value pairs.
*
* @private
* @constructor
* @param {array} [entries] the key-value pairs to cache.
*/
function mapcache(entries) {
var index = -1,
length = entries == null ? 0 : entries.length;
this.clear();
while (++index < length) {
var entry = entries[index];
this.set(entry[0], entry[1]);
}
}
/**
* removes all key-value entries from the map.
*
* @private
* @name clear
* @memberof mapcache
*/
function mapcacheclear() {
this.size = 0;
this.__data__ = {
'hash': new hash,
'map': new (map || listcache),
'string': new hash
};
}
/**
* removes `key` and its value from the map.
*
* @private
* @name delete
* @memberof mapcache
* @param {string} key the key of the value to remove.
* @returns {boolean} returns `true` if the entry was removed, else `false`.
*/
function mapcachedelete(key) {
var result = getmapdata(this, key)['delete'](key);
this.size -= result ? 1 : 0;
return result;
}
/**
* gets the map value for `key`.
*
* @private
* @name get
* @memberof mapcache
* @param {string} key the key of the value to get.
* @returns {*} returns the entry value.
*/
function mapcacheget(key) {
return getmapdata(this, key).get(key);
}
/**
* checks if a map value for `key` exists.
*
* @private
* @name has
* @memberof mapcache
* @param {string} key the key of the entry to check.
* @returns {boolean} returns `true` if an entry for `key` exists, else `false`.
*/
function mapcachehas(key) {
return getmapdata(this, key).has(key);
}
/**
* sets the map `key` to `value`.
*
* @private
* @name set
* @memberof mapcache
* @param {string} key the key of the value to set.
* @param {*} value the value to set.
* @returns {object} returns the map cache instance.
*/
function mapcacheset(key, value) {
var data = getmapdata(this, key),
size = data.size;
data.set(key, value);
this.size += data.size == size ? 0 : 1;
return this;
}
// add methods to `mapcache`.
mapcache.prototype.clear = mapcacheclear;
mapcache.prototype['delete'] = mapcachedelete;
mapcache.prototype.get = mapcacheget;
mapcache.prototype.has = mapcachehas;
mapcache.prototype.set = mapcacheset;
/*------------------------------------------------------------------------*/
/**
*
* creates an array cache object to store unique values.
*
* @private
* @constructor
* @param {array} [values] the values to cache.
*/
function setcache(values) {
var index = -1,
length = values == null ? 0 : values.length;
this.__data__ = new mapcache;
while (++index < length) {
this.add(values[index]);
}
}
/**
* adds `value` to the array cache.
*
* @private
* @name add
* @memberof setcache
* @alias push
* @param {*} value the value to cache.
* @returns {object} returns the cache instance.
*/
function setcacheadd(value) {
this.__data__.set(value, hash_undefined);
return this;
}
/**
* checks if `value` is in the array cache.
*
* @private
* @name has
* @memberof setcache
* @param {*} value the value to search for.
* @returns {number} returns `true` if `value` is found, else `false`.
*/
function setcachehas(value) {
return this.__data__.has(value);
}
// add methods to `setcache`.
setcache.prototype.add = setcache.prototype.push = setcacheadd;
setcache.prototype.has = setcachehas;
/*------------------------------------------------------------------------*/
/**
* creates a stack cache object to store key-value pairs.
*
* @private
* @constructor
* @param {array} [entries] the key-value pairs to cache.
*/
function stack(entries) {
var data = this.__data__ = new listcache(entries);
this.size = data.size;
}
/**
* removes all key-value entries from the stack.
*
* @private
* @name clear
* @memberof stack
*/
function stackclear() {
this.__data__ = new listcache;
this.size = 0;
}
/**
* removes `key` and its value from the stack.
*
* @private
* @name delete
* @memberof stack
* @param {string} key the key of the value to remove.
* @returns {boolean} returns `true` if the entry was removed, else `false`.
*/
function stackdelete(key) {
var data = this.__data__,
result = data['delete'](key);
this.size = data.size;
return result;
}
/**
* gets the stack value for `key`.
*
* @private
* @name get
* @memberof stack
* @param {string} key the key of the value to get.
* @returns {*} returns the entry value.
*/
function stackget(key) {
return this.__data__.get(key);
}
/**
* checks if a stack value for `key` exists.
*
* @private
* @name has
* @memberof stack
* @param {string} key the key of the entry to check.
* @returns {boolean} returns `true` if an entry for `key` exists, else `false`.
*/
function stackhas(key) {
return this.__data__.has(key);
}
/**
* sets the stack `key` to `value`.
*
* @private
* @name set
* @memberof stack
* @param {string} key the key of the value to set.
* @param {*} value the value to set.
* @returns {object} returns the stack cache instance.
*/
function stackset(key, value) {
var data = this.__data__;
if (data instanceof listcache) {
var pairs = data.__data__;
if (!map || (pairs.length < large_array_size - 1)) {
pairs.push([key, value]);
this.size = ++data.size;
return this;
}
data = this.__data__ = new mapcache(pairs);
}
data.set(key, value);
this.size = data.size;
return this;
}
// add methods to `stack`.
stack.prototype.clear = stackclear;
stack.prototype['delete'] = stackdelete;
stack.prototype.get = stackget;
stack.prototype.has = stackhas;
stack.prototype.set = stackset;
/*------------------------------------------------------------------------*/
/**
* creates an array of the enumerable property names of the array-like `value`.
*
* @private
* @param {*} value the value to query.
* @param {boolean} inherited specify returning inherited property names.
* @returns {array} returns the array of property names.
*/
function arraylikekeys(value, inherited) {
var isarr = isarray(value),
isarg = !isarr && isarguments(value),
isbuff = !isarr && !isarg && isbuffer(value),
istype = !isarr && !isarg && !isbuff && istypedarray(value),
skipindexes = isarr || isarg || isbuff || istype,
result = skipindexes ? basetimes(value.length, string) : [],
length = result.length;
for (var key in value) {
if ((inherited || hasownproperty.call(value, key)) &&
!(skipindexes && (
// safari 9 has enumerable `arguments.length` in strict mode.
key == 'length' ||
// node.js 0.10 has enumerable non-index properties on buffers.
(isbuff && (key == 'offset' || key == 'parent')) ||
// phantomjs 2 has enumerable non-index properties on typed arrays.
(istype && (key == 'buffer' || key == 'bytelength' || key == 'byteoffset')) ||
// skip index properties.
isindex(key, length)
))) {
result.push(key);
}
}
return result;
}
/**
* a specialized version of `_.sample` for arrays.
*
* @private
* @param {array} array the array to sample.
* @returns {*} returns the random element.
*/
function arraysample(array) {
var length = array.length;
return length ? array[baserandom(0, length - 1)] : undefined;
}
/**
* a specialized version of `_.samplesize` for arrays.
*
* @private
* @param {array} array the array to sample.
* @param {number} n the number of elements to sample.
* @returns {array} returns the random elements.
*/
function arraysamplesize(array, n) {
return shuffleself(copyarray(array), baseclamp(n, 0, array.length));
}
/**
* a specialized version of `_.shuffle` for arrays.
*
* @private
* @param {array} array the array to shuffle.
* @returns {array} returns the new shuffled array.
*/
function arrayshuffle(array) {
return shuffleself(copyarray(array));
}
/**
* this function is like `assignvalue` except that it doesn't assign
* `undefined` values.
*
* @private
* @param {object} object the object to modify.
* @param {string} key the key of the property to assign.
* @param {*} value the value to assign.
*/
function assignmergevalue(object, key, value) {
if ((value !== undefined && !eq(object[key], value)) ||
(value === undefined && !(key in object))) {
baseassignvalue(object, key, value);
}
}
/**
* assigns `value` to `key` of `object` if the existing value is not equivalent
* using [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @private
* @param {object} object the object to modify.
* @param {string} key the key of the property to assign.
* @param {*} value the value to assign.
*/
function assignvalue(object, key, value) {
var objvalue = object[key];
if (!(hasownproperty.call(object, key) && eq(objvalue, value)) ||
(value === undefined && !(key in object))) {
baseassignvalue(object, key, value);
}
}
/**
* gets the index at which the `key` is found in `array` of key-value pairs.
*
* @private
* @param {array} array the array to inspect.
* @param {*} key the key to search for.
* @returns {number} returns the index of the matched value, else `-1`.
*/
function associndexof(array, key) {
var length = array.length;
while (length--) {
if (eq(array[length][0], key)) {
return length;
}
}
return -1;
}
/**
* aggregates elements of `collection` on `accumulator` with keys transformed
* by `iteratee` and values set by `setter`.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} setter the function to set `accumulator` values.
* @param {function} iteratee the iteratee to transform keys.
* @param {object} accumulator the initial aggregated object.
* @returns {function} returns `accumulator`.
*/
function baseaggregator(collection, setter, iteratee, accumulator) {
baseeach(collection, function(value, key, collection) {
setter(accumulator, value, iteratee(value), collection);
});
return accumulator;
}
/**
* the base implementation of `_.assign` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {object} object the destination object.
* @param {object} source the source object.
* @returns {object} returns `object`.
*/
function baseassign(object, source) {
return object && copyobject(source, keys(source), object);
}
/**
* the base implementation of `_.assignin` without support for multiple sources
* or `customizer` functions.
*
* @private
* @param {object} object the destination object.
* @param {object} source the source object.
* @returns {object} returns `object`.
*/
function baseassignin(object, source) {
return object && copyobject(source, keysin(source), object);
}
/**
* the base implementation of `assignvalue` and `assignmergevalue` without
* value checks.
*
* @private
* @param {object} object the object to modify.
* @param {string} key the key of the property to assign.
* @param {*} value the value to assign.
*/
function baseassignvalue(object, key, value) {
if (key == '__proto__' && defineproperty) {
defineproperty(object, key, {
'configurable': true,
'enumerable': true,
'value': value,
'writable': true
});
} else {
object[key] = value;
}
}
/**
* the base implementation of `_.at` without support for individual paths.
*
* @private
* @param {object} object the object to iterate over.
* @param {string[]} paths the property paths to pick.
* @returns {array} returns the picked elements.
*/
function baseat(object, paths) {
var index = -1,
length = paths.length,
result = array(length),
skip = object == null;
while (++index < length) {
result[index] = skip ? undefined : get(object, paths[index]);
}
return result;
}
/**
* the base implementation of `_.clamp` which doesn't coerce arguments.
*
* @private
* @param {number} number the number to clamp.
* @param {number} [lower] the lower bound.
* @param {number} upper the upper bound.
* @returns {number} returns the clamped number.
*/
function baseclamp(number, lower, upper) {
if (number === number) {
if (upper !== undefined) {
number = number <= upper ? number : upper;
}
if (lower !== undefined) {
number = number >= lower ? number : lower;
}
}
return number;
}
/**
* the base implementation of `_.clone` and `_.clonedeep` which tracks
* traversed objects.
*
* @private
* @param {*} value the value to clone.
* @param {boolean} bitmask the bitmask flags.
* 1 - deep clone
* 2 - flatten inherited properties
* 4 - clone symbols
* @param {function} [customizer] the function to customize cloning.
* @param {string} [key] the key of `value`.
* @param {object} [object] the parent object of `value`.
* @param {object} [stack] tracks traversed objects and their clone counterparts.
* @returns {*} returns the cloned value.
*/
function baseclone(value, bitmask, customizer, key, object, stack) {
var result,
isdeep = bitmask & clone_deep_flag,
isflat = bitmask & clone_flat_flag,
isfull = bitmask & clone_symbols_flag;
if (customizer) {
result = object ? customizer(value, key, object, stack) : customizer(value);
}
if (result !== undefined) {
return result;
}
if (!isobject(value)) {
return value;
}
var isarr = isarray(value);
if (isarr) {
result = initclonearray(value);
if (!isdeep) {
return copyarray(value, result);
}
} else {
var tag = gettag(value),
isfunc = tag == functag || tag == gentag;
if (isbuffer(value)) {
return clonebuffer(value, isdeep);
}
if (tag == objecttag || tag == argstag || (isfunc && !object)) {
result = (isflat || isfunc) ? {} : initcloneobject(value);
if (!isdeep) {
return isflat
? copysymbolsin(value, baseassignin(result, value))
: copysymbols(value, baseassign(result, value));
}
} else {
if (!cloneabletags[tag]) {
return object ? value : {};
}
result = initclonebytag(value, tag, isdeep);
}
}
// check for circular references and return its corresponding clone.
stack || (stack = new stack);
var stacked = stack.get(value);
if (stacked) {
return stacked;
}
stack.set(value, result);
if (isset(value)) {
value.foreach(function(subvalue) {
result.add(baseclone(subvalue, bitmask, customizer, subvalue, value, stack));
});
return result;
}
if (ismap(value)) {
value.foreach(function(subvalue, key) {
result.set(key, baseclone(subvalue, bitmask, customizer, key, value, stack));
});
return result;
}
var keysfunc = isfull
? (isflat ? getallkeysin : getallkeys)
: (isflat ? keysin : keys);
var props = isarr ? undefined : keysfunc(value);
arrayeach(props || value, function(subvalue, key) {
if (props) {
key = subvalue;
subvalue = value[key];
}
// recursively populate clone (susceptible to call stack limits).
assignvalue(result, key, baseclone(subvalue, bitmask, customizer, key, value, stack));
});
return result;
}
/**
* the base implementation of `_.conforms` which doesn't clone `source`.
*
* @private
* @param {object} source the object of property predicates to conform to.
* @returns {function} returns the new spec function.
*/
function baseconforms(source) {
var props = keys(source);
return function(object) {
return baseconformsto(object, source, props);
};
}
/**
* the base implementation of `_.conformsto` which accepts `props` to check.
*
* @private
* @param {object} object the object to inspect.
* @param {object} source the object of property predicates to conform to.
* @returns {boolean} returns `true` if `object` conforms, else `false`.
*/
function baseconformsto(object, source, props) {
var length = props.length;
if (object == null) {
return !length;
}
object = object(object);
while (length--) {
var key = props[length],
predicate = source[key],
value = object[key];
if ((value === undefined && !(key in object)) || !predicate(value)) {
return false;
}
}
return true;
}
/**
* the base implementation of `_.delay` and `_.defer` which accepts `args`
* to provide to `func`.
*
* @private
* @param {function} func the function to delay.
* @param {number} wait the number of milliseconds to delay invocation.
* @param {array} args the arguments to provide to `func`.
* @returns {number|object} returns the timer id or timeout object.
*/
function basedelay(func, wait, args) {
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
return settimeout(function() { func.apply(undefined, args); }, wait);
}
/**
* the base implementation of methods like `_.difference` without support
* for excluding multiple arrays or iteratee shorthands.
*
* @private
* @param {array} array the array to inspect.
* @param {array} values the values to exclude.
* @param {function} [iteratee] the iteratee invoked per element.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of filtered values.
*/
function basedifference(array, values, iteratee, comparator) {
var index = -1,
includes = arrayincludes,
iscommon = true,
length = array.length,
result = [],
valueslength = values.length;
if (!length) {
return result;
}
if (iteratee) {
values = arraymap(values, baseunary(iteratee));
}
if (comparator) {
includes = arrayincludeswith;
iscommon = false;
}
else if (values.length >= large_array_size) {
includes = cachehas;
iscommon = false;
values = new setcache(values);
}
outer:
while (++index < length) {
var value = array[index],
computed = iteratee == null ? value : iteratee(value);
value = (comparator || value !== 0) ? value : 0;
if (iscommon && computed === computed) {
var valuesindex = valueslength;
while (valuesindex--) {
if (values[valuesindex] === computed) {
continue outer;
}
}
result.push(value);
}
else if (!includes(values, computed, comparator)) {
result.push(value);
}
}
return result;
}
/**
* the base implementation of `_.foreach` without support for iteratee shorthands.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {array|object} returns `collection`.
*/
var baseeach = createbaseeach(baseforown);
/**
* the base implementation of `_.foreachright` without support for iteratee shorthands.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {array|object} returns `collection`.
*/
var baseeachright = createbaseeach(baseforownright, true);
/**
* the base implementation of `_.every` without support for iteratee shorthands.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} predicate the function invoked per iteration.
* @returns {boolean} returns `true` if all elements pass the predicate check,
* else `false`
*/
function baseevery(collection, predicate) {
var result = true;
baseeach(collection, function(value, index, collection) {
result = !!predicate(value, index, collection);
return result;
});
return result;
}
/**
* the base implementation of methods like `_.max` and `_.min` which accepts a
* `comparator` to determine the extremum value.
*
* @private
* @param {array} array the array to iterate over.
* @param {function} iteratee the iteratee invoked per iteration.
* @param {function} comparator the comparator used to compare values.
* @returns {*} returns the extremum value.
*/
function baseextremum(array, iteratee, comparator) {
var index = -1,
length = array.length;
while (++index < length) {
var value = array[index],
current = iteratee(value);
if (current != null && (computed === undefined
? (current === current && !issymbol(current))
: comparator(current, computed)
)) {
var computed = current,
result = value;
}
}
return result;
}
/**
* the base implementation of `_.fill` without an iteratee call guard.
*
* @private
* @param {array} array the array to fill.
* @param {*} value the value to fill `array` with.
* @param {number} [start=0] the start position.
* @param {number} [end=array.length] the end position.
* @returns {array} returns `array`.
*/
function basefill(array, value, start, end) {
var length = array.length;
start = tointeger(start);
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = (end === undefined || end > length) ? length : tointeger(end);
if (end < 0) {
end += length;
}
end = start > end ? 0 : tolength(end);
while (start < end) {
array[start++] = value;
}
return array;
}
/**
* the base implementation of `_.filter` without support for iteratee shorthands.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} predicate the function invoked per iteration.
* @returns {array} returns the new filtered array.
*/
function basefilter(collection, predicate) {
var result = [];
baseeach(collection, function(value, index, collection) {
if (predicate(value, index, collection)) {
result.push(value);
}
});
return result;
}
/**
* the base implementation of `_.flatten` with support for restricting flattening.
*
* @private
* @param {array} array the array to flatten.
* @param {number} depth the maximum recursion depth.
* @param {boolean} [predicate=isflattenable] the function invoked per iteration.
* @param {boolean} [isstrict] restrict to values that pass `predicate` checks.
* @param {array} [result=[]] the initial result value.
* @returns {array} returns the new flattened array.
*/
function baseflatten(array, depth, predicate, isstrict, result) {
var index = -1,
length = array.length;
predicate || (predicate = isflattenable);
result || (result = []);
while (++index < length) {
var value = array[index];
if (depth > 0 && predicate(value)) {
if (depth > 1) {
// recursively flatten arrays (susceptible to call stack limits).
baseflatten(value, depth - 1, predicate, isstrict, result);
} else {
arraypush(result, value);
}
} else if (!isstrict) {
result[result.length] = value;
}
}
return result;
}
/**
* the base implementation of `baseforown` which iterates over `object`
* properties returned by `keysfunc` and invokes `iteratee` for each property.
* iteratee functions may exit iteration early by explicitly returning `false`.
*
* @private
* @param {object} object the object to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @param {function} keysfunc the function to get the keys of `object`.
* @returns {object} returns `object`.
*/
var basefor = createbasefor();
/**
* this function is like `basefor` except that it iterates over properties
* in the opposite order.
*
* @private
* @param {object} object the object to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @param {function} keysfunc the function to get the keys of `object`.
* @returns {object} returns `object`.
*/
var baseforright = createbasefor(true);
/**
* the base implementation of `_.forown` without support for iteratee shorthands.
*
* @private
* @param {object} object the object to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {object} returns `object`.
*/
function baseforown(object, iteratee) {
return object && basefor(object, iteratee, keys);
}
/**
* the base implementation of `_.forownright` without support for iteratee shorthands.
*
* @private
* @param {object} object the object to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {object} returns `object`.
*/
function baseforownright(object, iteratee) {
return object && baseforright(object, iteratee, keys);
}
/**
* the base implementation of `_.functions` which creates an array of
* `object` function property names filtered from `props`.
*
* @private
* @param {object} object the object to inspect.
* @param {array} props the property names to filter.
* @returns {array} returns the function names.
*/
function basefunctions(object, props) {
return arrayfilter(props, function(key) {
return isfunction(object[key]);
});
}
/**
* the base implementation of `_.get` without support for default values.
*
* @private
* @param {object} object the object to query.
* @param {array|string} path the path of the property to get.
* @returns {*} returns the resolved value.
*/
function baseget(object, path) {
path = castpath(path, object);
var index = 0,
length = path.length;
while (object != null && index < length) {
object = object[tokey(path[index++])];
}
return (index && index == length) ? object : undefined;
}
/**
* the base implementation of `getallkeys` and `getallkeysin` which uses
* `keysfunc` and `symbolsfunc` to get the enumerable property names and
* symbols of `object`.
*
* @private
* @param {object} object the object to query.
* @param {function} keysfunc the function to get the keys of `object`.
* @param {function} symbolsfunc the function to get the symbols of `object`.
* @returns {array} returns the array of property names and symbols.
*/
function basegetallkeys(object, keysfunc, symbolsfunc) {
var result = keysfunc(object);
return isarray(object) ? result : arraypush(result, symbolsfunc(object));
}
/**
* the base implementation of `gettag` without fallbacks for buggy environments.
*
* @private
* @param {*} value the value to query.
* @returns {string} returns the `tostringtag`.
*/
function basegettag(value) {
if (value == null) {
return value === undefined ? undefinedtag : nulltag;
}
return (symtostringtag && symtostringtag in object(value))
? getrawtag(value)
: objecttostring(value);
}
/**
* the base implementation of `_.gt` which doesn't coerce arguments.
*
* @private
* @param {*} value the value to compare.
* @param {*} other the other value to compare.
* @returns {boolean} returns `true` if `value` is greater than `other`,
* else `false`.
*/
function basegt(value, other) {
return value > other;
}
/**
* the base implementation of `_.has` without support for deep paths.
*
* @private
* @param {object} [object] the object to query.
* @param {array|string} key the key to check.
* @returns {boolean} returns `true` if `key` exists, else `false`.
*/
function basehas(object, key) {
return object != null && hasownproperty.call(object, key);
}
/**
* the base implementation of `_.hasin` without support for deep paths.
*
* @private
* @param {object} [object] the object to query.
* @param {array|string} key the key to check.
* @returns {boolean} returns `true` if `key` exists, else `false`.
*/
function basehasin(object, key) {
return object != null && key in object(object);
}
/**
* the base implementation of `_.inrange` which doesn't coerce arguments.
*
* @private
* @param {number} number the number to check.
* @param {number} start the start of the range.
* @param {number} end the end of the range.
* @returns {boolean} returns `true` if `number` is in the range, else `false`.
*/
function baseinrange(number, start, end) {
return number >= nativemin(start, end) && number < nativemax(start, end);
}
/**
* the base implementation of methods like `_.intersection`, without support
* for iteratee shorthands, that accepts an array of arrays to inspect.
*
* @private
* @param {array} arrays the arrays to inspect.
* @param {function} [iteratee] the iteratee invoked per element.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of shared values.
*/
function baseintersection(arrays, iteratee, comparator) {
var includes = comparator ? arrayincludeswith : arrayincludes,
length = arrays[0].length,
othlength = arrays.length,
othindex = othlength,
caches = array(othlength),
maxlength = infinity,
result = [];
while (othindex--) {
var array = arrays[othindex];
if (othindex && iteratee) {
array = arraymap(array, baseunary(iteratee));
}
maxlength = nativemin(array.length, maxlength);
caches[othindex] = !comparator && (iteratee || (length >= 120 && array.length >= 120))
? new setcache(othindex && array)
: undefined;
}
array = arrays[0];
var index = -1,
seen = caches[0];
outer:
while (++index < length && result.length < maxlength) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (!(seen
? cachehas(seen, computed)
: includes(result, computed, comparator)
)) {
othindex = othlength;
while (--othindex) {
var cache = caches[othindex];
if (!(cache
? cachehas(cache, computed)
: includes(arrays[othindex], computed, comparator))
) {
continue outer;
}
}
if (seen) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
/**
* the base implementation of `_.invert` and `_.invertby` which inverts
* `object` with values transformed by `iteratee` and set by `setter`.
*
* @private
* @param {object} object the object to iterate over.
* @param {function} setter the function to set `accumulator` values.
* @param {function} iteratee the iteratee to transform values.
* @param {object} accumulator the initial inverted object.
* @returns {function} returns `accumulator`.
*/
function baseinverter(object, setter, iteratee, accumulator) {
baseforown(object, function(value, key, object) {
setter(accumulator, iteratee(value), key, object);
});
return accumulator;
}
/**
* the base implementation of `_.invoke` without support for individual
* method arguments.
*
* @private
* @param {object} object the object to query.
* @param {array|string} path the path of the method to invoke.
* @param {array} args the arguments to invoke the method with.
* @returns {*} returns the result of the invoked method.
*/
function baseinvoke(object, path, args) {
path = castpath(path, object);
object = parent(object, path);
var func = object == null ? object : object[tokey(last(path))];
return func == null ? undefined : apply(func, object, args);
}
/**
* the base implementation of `_.isarguments`.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is an `arguments` object,
*/
function baseisarguments(value) {
return isobjectlike(value) && basegettag(value) == argstag;
}
/**
* the base implementation of `_.isarraybuffer` without node.js optimizations.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is an array buffer, else `false`.
*/
function baseisarraybuffer(value) {
return isobjectlike(value) && basegettag(value) == arraybuffertag;
}
/**
* the base implementation of `_.isdate` without node.js optimizations.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a date object, else `false`.
*/
function baseisdate(value) {
return isobjectlike(value) && basegettag(value) == datetag;
}
/**
* the base implementation of `_.isequal` which supports partial comparisons
* and tracks traversed objects.
*
* @private
* @param {*} value the value to compare.
* @param {*} other the other value to compare.
* @param {boolean} bitmask the bitmask flags.
* 1 - unordered comparison
* 2 - partial comparison
* @param {function} [customizer] the function to customize comparisons.
* @param {object} [stack] tracks traversed `value` and `other` objects.
* @returns {boolean} returns `true` if the values are equivalent, else `false`.
*/
function baseisequal(value, other, bitmask, customizer, stack) {
if (value === other) {
return true;
}
if (value == null || other == null || (!isobjectlike(value) && !isobjectlike(other))) {
return value !== value && other !== other;
}
return baseisequaldeep(value, other, bitmask, customizer, baseisequal, stack);
}
/**
* a specialized version of `baseisequal` for arrays and objects which performs
* deep comparisons and tracks traversed objects enabling objects with circular
* references to be compared.
*
* @private
* @param {object} object the object to compare.
* @param {object} other the other object to compare.
* @param {number} bitmask the bitmask flags. see `baseisequal` for more details.
* @param {function} customizer the function to customize comparisons.
* @param {function} equalfunc the function to determine equivalents of values.
* @param {object} [stack] tracks traversed `object` and `other` objects.
* @returns {boolean} returns `true` if the objects are equivalent, else `false`.
*/
function baseisequaldeep(object, other, bitmask, customizer, equalfunc, stack) {
var objisarr = isarray(object),
othisarr = isarray(other),
objtag = objisarr ? arraytag : gettag(object),
othtag = othisarr ? arraytag : gettag(other);
objtag = objtag == argstag ? objecttag : objtag;
othtag = othtag == argstag ? objecttag : othtag;
var objisobj = objtag == objecttag,
othisobj = othtag == objecttag,
issametag = objtag == othtag;
if (issametag && isbuffer(object)) {
if (!isbuffer(other)) {
return false;
}
objisarr = true;
objisobj = false;
}
if (issametag && !objisobj) {
stack || (stack = new stack);
return (objisarr || istypedarray(object))
? equalarrays(object, other, bitmask, customizer, equalfunc, stack)
: equalbytag(object, other, objtag, bitmask, customizer, equalfunc, stack);
}
if (!(bitmask & compare_partial_flag)) {
var objiswrapped = objisobj && hasownproperty.call(object, '__wrapped__'),
othiswrapped = othisobj && hasownproperty.call(other, '__wrapped__');
if (objiswrapped || othiswrapped) {
var objunwrapped = objiswrapped ? object.value() : object,
othunwrapped = othiswrapped ? other.value() : other;
stack || (stack = new stack);
return equalfunc(objunwrapped, othunwrapped, bitmask, customizer, stack);
}
}
if (!issametag) {
return false;
}
stack || (stack = new stack);
return equalobjects(object, other, bitmask, customizer, equalfunc, stack);
}
/**
* the base implementation of `_.ismap` without node.js optimizations.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a map, else `false`.
*/
function baseismap(value) {
return isobjectlike(value) && gettag(value) == maptag;
}
/**
* the base implementation of `_.ismatch` without support for iteratee shorthands.
*
* @private
* @param {object} object the object to inspect.
* @param {object} source the object of property values to match.
* @param {array} matchdata the property names, values, and compare flags to match.
* @param {function} [customizer] the function to customize comparisons.
* @returns {boolean} returns `true` if `object` is a match, else `false`.
*/
function baseismatch(object, source, matchdata, customizer) {
var index = matchdata.length,
length = index,
nocustomizer = !customizer;
if (object == null) {
return !length;
}
object = object(object);
while (index--) {
var data = matchdata[index];
if ((nocustomizer && data[2])
? data[1] !== object[data[0]]
: !(data[0] in object)
) {
return false;
}
}
while (++index < length) {
data = matchdata[index];
var key = data[0],
objvalue = object[key],
srcvalue = data[1];
if (nocustomizer && data[2]) {
if (objvalue === undefined && !(key in object)) {
return false;
}
} else {
var stack = new stack;
if (customizer) {
var result = customizer(objvalue, srcvalue, key, object, source, stack);
}
if (!(result === undefined
? baseisequal(srcvalue, objvalue, compare_partial_flag | compare_unordered_flag, customizer, stack)
: result
)) {
return false;
}
}
}
return true;
}
/**
* the base implementation of `_.isnative` without bad shim checks.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a native function,
* else `false`.
*/
function baseisnative(value) {
if (!isobject(value) || ismasked(value)) {
return false;
}
var pattern = isfunction(value) ? reisnative : reishostctor;
return pattern.test(tosource(value));
}
/**
* the base implementation of `_.isregexp` without node.js optimizations.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a regexp, else `false`.
*/
function baseisregexp(value) {
return isobjectlike(value) && basegettag(value) == regexptag;
}
/**
* the base implementation of `_.isset` without node.js optimizations.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a set, else `false`.
*/
function baseisset(value) {
return isobjectlike(value) && gettag(value) == settag;
}
/**
* the base implementation of `_.istypedarray` without node.js optimizations.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a typed array, else `false`.
*/
function baseistypedarray(value) {
return isobjectlike(value) &&
islength(value.length) && !!typedarraytags[basegettag(value)];
}
/**
* the base implementation of `_.iteratee`.
*
* @private
* @param {*} [value=_.identity] the value to convert to an iteratee.
* @returns {function} returns the iteratee.
*/
function baseiteratee(value) {
// don't store the `typeof` result in a variable to avoid a jit bug in safari 9.
// see https://bugs.webkit.org/show_bug.cgi?id=156034 for more details.
if (typeof value == 'function') {
return value;
}
if (value == null) {
return identity;
}
if (typeof value == 'object') {
return isarray(value)
? basematchesproperty(value[0], value[1])
: basematches(value);
}
return property(value);
}
/**
* the base implementation of `_.keys` which doesn't treat sparse arrays as dense.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of property names.
*/
function basekeys(object) {
if (!isprototype(object)) {
return nativekeys(object);
}
var result = [];
for (var key in object(object)) {
if (hasownproperty.call(object, key) && key != 'constructor') {
result.push(key);
}
}
return result;
}
/**
* the base implementation of `_.keysin` which doesn't treat sparse arrays as dense.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of property names.
*/
function basekeysin(object) {
if (!isobject(object)) {
return nativekeysin(object);
}
var isproto = isprototype(object),
result = [];
for (var key in object) {
if (!(key == 'constructor' && (isproto || !hasownproperty.call(object, key)))) {
result.push(key);
}
}
return result;
}
/**
* the base implementation of `_.lt` which doesn't coerce arguments.
*
* @private
* @param {*} value the value to compare.
* @param {*} other the other value to compare.
* @returns {boolean} returns `true` if `value` is less than `other`,
* else `false`.
*/
function baselt(value, other) {
return value < other;
}
/**
* the base implementation of `_.map` without support for iteratee shorthands.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} iteratee the function invoked per iteration.
* @returns {array} returns the new mapped array.
*/
function basemap(collection, iteratee) {
var index = -1,
result = isarraylike(collection) ? array(collection.length) : [];
baseeach(collection, function(value, key, collection) {
result[++index] = iteratee(value, key, collection);
});
return result;
}
/**
* the base implementation of `_.matches` which doesn't clone `source`.
*
* @private
* @param {object} source the object of property values to match.
* @returns {function} returns the new spec function.
*/
function basematches(source) {
var matchdata = getmatchdata(source);
if (matchdata.length == 1 && matchdata[0][2]) {
return matchesstrictcomparable(matchdata[0][0], matchdata[0][1]);
}
return function(object) {
return object === source || baseismatch(object, source, matchdata);
};
}
/**
* the base implementation of `_.matchesproperty` which doesn't clone `srcvalue`.
*
* @private
* @param {string} path the path of the property to get.
* @param {*} srcvalue the value to match.
* @returns {function} returns the new spec function.
*/
function basematchesproperty(path, srcvalue) {
if (iskey(path) && isstrictcomparable(srcvalue)) {
return matchesstrictcomparable(tokey(path), srcvalue);
}
return function(object) {
var objvalue = get(object, path);
return (objvalue === undefined && objvalue === srcvalue)
? hasin(object, path)
: baseisequal(srcvalue, objvalue, compare_partial_flag | compare_unordered_flag);
};
}
/**
* the base implementation of `_.merge` without support for multiple sources.
*
* @private
* @param {object} object the destination object.
* @param {object} source the source object.
* @param {number} srcindex the index of `source`.
* @param {function} [customizer] the function to customize merged values.
* @param {object} [stack] tracks traversed source values and their merged
* counterparts.
*/
function basemerge(object, source, srcindex, customizer, stack) {
if (object === source) {
return;
}
basefor(source, function(srcvalue, key) {
if (isobject(srcvalue)) {
stack || (stack = new stack);
basemergedeep(object, source, key, srcindex, basemerge, customizer, stack);
}
else {
var newvalue = customizer
? customizer(safeget(object, key), srcvalue, (key + ''), object, source, stack)
: undefined;
if (newvalue === undefined) {
newvalue = srcvalue;
}
assignmergevalue(object, key, newvalue);
}
}, keysin);
}
/**
* a specialized version of `basemerge` for arrays and objects which performs
* deep merges and tracks traversed objects enabling objects with circular
* references to be merged.
*
* @private
* @param {object} object the destination object.
* @param {object} source the source object.
* @param {string} key the key of the value to merge.
* @param {number} srcindex the index of `source`.
* @param {function} mergefunc the function to merge values.
* @param {function} [customizer] the function to customize assigned values.
* @param {object} [stack] tracks traversed source values and their merged
* counterparts.
*/
function basemergedeep(object, source, key, srcindex, mergefunc, customizer, stack) {
var objvalue = safeget(object, key),
srcvalue = safeget(source, key),
stacked = stack.get(srcvalue);
if (stacked) {
assignmergevalue(object, key, stacked);
return;
}
var newvalue = customizer
? customizer(objvalue, srcvalue, (key + ''), object, source, stack)
: undefined;
var iscommon = newvalue === undefined;
if (iscommon) {
var isarr = isarray(srcvalue),
isbuff = !isarr && isbuffer(srcvalue),
istyped = !isarr && !isbuff && istypedarray(srcvalue);
newvalue = srcvalue;
if (isarr || isbuff || istyped) {
if (isarray(objvalue)) {
newvalue = objvalue;
}
else if (isarraylikeobject(objvalue)) {
newvalue = copyarray(objvalue);
}
else if (isbuff) {
iscommon = false;
newvalue = clonebuffer(srcvalue, true);
}
else if (istyped) {
iscommon = false;
newvalue = clonetypedarray(srcvalue, true);
}
else {
newvalue = [];
}
}
else if (isplainobject(srcvalue) || isarguments(srcvalue)) {
newvalue = objvalue;
if (isarguments(objvalue)) {
newvalue = toplainobject(objvalue);
}
else if (!isobject(objvalue) || (srcindex && isfunction(objvalue))) {
newvalue = initcloneobject(srcvalue);
}
}
else {
iscommon = false;
}
}
if (iscommon) {
// recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcvalue, newvalue);
mergefunc(newvalue, srcvalue, srcindex, customizer, stack);
stack['delete'](srcvalue);
}
assignmergevalue(object, key, newvalue);
}
/**
* the base implementation of `_.nth` which doesn't coerce arguments.
*
* @private
* @param {array} array the array to query.
* @param {number} n the index of the element to return.
* @returns {*} returns the nth element of `array`.
*/
function basenth(array, n) {
var length = array.length;
if (!length) {
return;
}
n += n < 0 ? length : 0;
return isindex(n, length) ? array[n] : undefined;
}
/**
* the base implementation of `_.orderby` without param guards.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function[]|object[]|string[]} iteratees the iteratees to sort by.
* @param {string[]} orders the sort orders of `iteratees`.
* @returns {array} returns the new sorted array.
*/
function baseorderby(collection, iteratees, orders) {
var index = -1;
iteratees = arraymap(iteratees.length ? iteratees : [identity], baseunary(getiteratee()));
var result = basemap(collection, function(value, key, collection) {
var criteria = arraymap(iteratees, function(iteratee) {
return iteratee(value);
});
return { 'criteria': criteria, 'index': ++index, 'value': value };
});
return basesortby(result, function(object, other) {
return comparemultiple(object, other, orders);
});
}
/**
* the base implementation of `_.pick` without support for individual
* property identifiers.
*
* @private
* @param {object} object the source object.
* @param {string[]} paths the property paths to pick.
* @returns {object} returns the new object.
*/
function basepick(object, paths) {
return basepickby(object, paths, function(value, path) {
return hasin(object, path);
});
}
/**
* the base implementation of `_.pickby` without support for iteratee shorthands.
*
* @private
* @param {object} object the source object.
* @param {string[]} paths the property paths to pick.
* @param {function} predicate the function invoked per property.
* @returns {object} returns the new object.
*/
function basepickby(object, paths, predicate) {
var index = -1,
length = paths.length,
result = {};
while (++index < length) {
var path = paths[index],
value = baseget(object, path);
if (predicate(value, path)) {
baseset(result, castpath(path, object), value);
}
}
return result;
}
/**
* a specialized version of `baseproperty` which supports deep paths.
*
* @private
* @param {array|string} path the path of the property to get.
* @returns {function} returns the new accessor function.
*/
function basepropertydeep(path) {
return function(object) {
return baseget(object, path);
};
}
/**
* the base implementation of `_.pullallby` without support for iteratee
* shorthands.
*
* @private
* @param {array} array the array to modify.
* @param {array} values the values to remove.
* @param {function} [iteratee] the iteratee invoked per element.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns `array`.
*/
function basepullall(array, values, iteratee, comparator) {
var indexof = comparator ? baseindexofwith : baseindexof,
index = -1,
length = values.length,
seen = array;
if (array === values) {
values = copyarray(values);
}
if (iteratee) {
seen = arraymap(array, baseunary(iteratee));
}
while (++index < length) {
var fromindex = 0,
value = values[index],
computed = iteratee ? iteratee(value) : value;
while ((fromindex = indexof(seen, computed, fromindex, comparator)) > -1) {
if (seen !== array) {
splice.call(seen, fromindex, 1);
}
splice.call(array, fromindex, 1);
}
}
return array;
}
/**
* the base implementation of `_.pullat` without support for individual
* indexes or capturing the removed elements.
*
* @private
* @param {array} array the array to modify.
* @param {number[]} indexes the indexes of elements to remove.
* @returns {array} returns `array`.
*/
function basepullat(array, indexes) {
var length = array ? indexes.length : 0,
lastindex = length - 1;
while (length--) {
var index = indexes[length];
if (length == lastindex || index !== previous) {
var previous = index;
if (isindex(index)) {
splice.call(array, index, 1);
} else {
baseunset(array, index);
}
}
}
return array;
}
/**
* the base implementation of `_.random` without support for returning
* floating-point numbers.
*
* @private
* @param {number} lower the lower bound.
* @param {number} upper the upper bound.
* @returns {number} returns the random number.
*/
function baserandom(lower, upper) {
return lower + nativefloor(nativerandom() * (upper - lower + 1));
}
/**
* the base implementation of `_.range` and `_.rangeright` which doesn't
* coerce arguments.
*
* @private
* @param {number} start the start of the range.
* @param {number} end the end of the range.
* @param {number} step the value to increment or decrement by.
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {array} returns the range of numbers.
*/
function baserange(start, end, step, fromright) {
var index = -1,
length = nativemax(nativeceil((end - start) / (step || 1)), 0),
result = array(length);
while (length--) {
result[fromright ? length : ++index] = start;
start += step;
}
return result;
}
/**
* the base implementation of `_.repeat` which doesn't coerce arguments.
*
* @private
* @param {string} string the string to repeat.
* @param {number} n the number of times to repeat the string.
* @returns {string} returns the repeated string.
*/
function baserepeat(string, n) {
var result = '';
if (!string || n < 1 || n > max_safe_integer) {
return result;
}
// leverage the exponentiation by squaring algorithm for a faster repeat.
// see https://en.wikipedia.org/wiki/exponentiation_by_squaring for more details.
do {
if (n % 2) {
result += string;
}
n = nativefloor(n / 2);
if (n) {
string += string;
}
} while (n);
return result;
}
/**
* the base implementation of `_.rest` which doesn't validate or coerce arguments.
*
* @private
* @param {function} func the function to apply a rest parameter to.
* @param {number} [start=func.length-1] the start position of the rest parameter.
* @returns {function} returns the new function.
*/
function baserest(func, start) {
return settostring(overrest(func, start, identity), func + '');
}
/**
* the base implementation of `_.sample`.
*
* @private
* @param {array|object} collection the collection to sample.
* @returns {*} returns the random element.
*/
function basesample(collection) {
return arraysample(values(collection));
}
/**
* the base implementation of `_.samplesize` without param guards.
*
* @private
* @param {array|object} collection the collection to sample.
* @param {number} n the number of elements to sample.
* @returns {array} returns the random elements.
*/
function basesamplesize(collection, n) {
var array = values(collection);
return shuffleself(array, baseclamp(n, 0, array.length));
}
/**
* the base implementation of `_.set`.
*
* @private
* @param {object} object the object to modify.
* @param {array|string} path the path of the property to set.
* @param {*} value the value to set.
* @param {function} [customizer] the function to customize path creation.
* @returns {object} returns `object`.
*/
function baseset(object, path, value, customizer) {
if (!isobject(object)) {
return object;
}
path = castpath(path, object);
var index = -1,
length = path.length,
lastindex = length - 1,
nested = object;
while (nested != null && ++index < length) {
var key = tokey(path[index]),
newvalue = value;
if (index != lastindex) {
var objvalue = nested[key];
newvalue = customizer ? customizer(objvalue, key, nested) : undefined;
if (newvalue === undefined) {
newvalue = isobject(objvalue)
? objvalue
: (isindex(path[index + 1]) ? [] : {});
}
}
assignvalue(nested, key, newvalue);
nested = nested[key];
}
return object;
}
/**
* the base implementation of `setdata` without support for hot loop shorting.
*
* @private
* @param {function} func the function to associate metadata with.
* @param {*} data the metadata.
* @returns {function} returns `func`.
*/
var basesetdata = !metamap ? identity : function(func, data) {
metamap.set(func, data);
return func;
};
/**
* the base implementation of `settostring` without support for hot loop shorting.
*
* @private
* @param {function} func the function to modify.
* @param {function} string the `tostring` result.
* @returns {function} returns `func`.
*/
var basesettostring = !defineproperty ? identity : function(func, string) {
return defineproperty(func, 'tostring', {
'configurable': true,
'enumerable': false,
'value': constant(string),
'writable': true
});
};
/**
* the base implementation of `_.shuffle`.
*
* @private
* @param {array|object} collection the collection to shuffle.
* @returns {array} returns the new shuffled array.
*/
function baseshuffle(collection) {
return shuffleself(values(collection));
}
/**
* the base implementation of `_.slice` without an iteratee call guard.
*
* @private
* @param {array} array the array to slice.
* @param {number} [start=0] the start position.
* @param {number} [end=array.length] the end position.
* @returns {array} returns the slice of `array`.
*/
function baseslice(array, start, end) {
var index = -1,
length = array.length;
if (start < 0) {
start = -start > length ? 0 : (length + start);
}
end = end > length ? length : end;
if (end < 0) {
end += length;
}
length = start > end ? 0 : ((end - start) >>> 0);
start >>>= 0;
var result = array(length);
while (++index < length) {
result[index] = array[index + start];
}
return result;
}
/**
* the base implementation of `_.some` without support for iteratee shorthands.
*
* @private
* @param {array|object} collection the collection to iterate over.
* @param {function} predicate the function invoked per iteration.
* @returns {boolean} returns `true` if any element passes the predicate check,
* else `false`.
*/
function basesome(collection, predicate) {
var result;
baseeach(collection, function(value, index, collection) {
result = predicate(value, index, collection);
return !result;
});
return !!result;
}
/**
* the base implementation of `_.sortedindex` and `_.sortedlastindex` which
* performs a binary search of `array` to determine the index at which `value`
* should be inserted into `array` in order to maintain its sort order.
*
* @private
* @param {array} array the sorted array to inspect.
* @param {*} value the value to evaluate.
* @param {boolean} [rethighest] specify returning the highest qualified index.
* @returns {number} returns the index at which `value` should be inserted
* into `array`.
*/
function basesortedindex(array, value, rethighest) {
var low = 0,
high = array == null ? low : array.length;
if (typeof value == 'number' && value === value && high <= half_max_array_length) {
while (low < high) {
var mid = (low + high) >>> 1,
computed = array[mid];
if (computed !== null && !issymbol(computed) &&
(rethighest ? (computed <= value) : (computed < value))) {
low = mid + 1;
} else {
high = mid;
}
}
return high;
}
return basesortedindexby(array, value, identity, rethighest);
}
/**
* the base implementation of `_.sortedindexby` and `_.sortedlastindexby`
* which invokes `iteratee` for `value` and each element of `array` to compute
* their sort ranking. the iteratee is invoked with one argument; (value).
*
* @private
* @param {array} array the sorted array to inspect.
* @param {*} value the value to evaluate.
* @param {function} iteratee the iteratee invoked per element.
* @param {boolean} [rethighest] specify returning the highest qualified index.
* @returns {number} returns the index at which `value` should be inserted
* into `array`.
*/
function basesortedindexby(array, value, iteratee, rethighest) {
value = iteratee(value);
var low = 0,
high = array == null ? 0 : array.length,
valisnan = value !== value,
valisnull = value === null,
valissymbol = issymbol(value),
valisundefined = value === undefined;
while (low < high) {
var mid = nativefloor((low + high) / 2),
computed = iteratee(array[mid]),
othisdefined = computed !== undefined,
othisnull = computed === null,
othisreflexive = computed === computed,
othissymbol = issymbol(computed);
if (valisnan) {
var setlow = rethighest || othisreflexive;
} else if (valisundefined) {
setlow = othisreflexive && (rethighest || othisdefined);
} else if (valisnull) {
setlow = othisreflexive && othisdefined && (rethighest || !othisnull);
} else if (valissymbol) {
setlow = othisreflexive && othisdefined && !othisnull && (rethighest || !othissymbol);
} else if (othisnull || othissymbol) {
setlow = false;
} else {
setlow = rethighest ? (computed <= value) : (computed < value);
}
if (setlow) {
low = mid + 1;
} else {
high = mid;
}
}
return nativemin(high, max_array_index);
}
/**
* the base implementation of `_.sorteduniq` and `_.sorteduniqby` without
* support for iteratee shorthands.
*
* @private
* @param {array} array the array to inspect.
* @param {function} [iteratee] the iteratee invoked per element.
* @returns {array} returns the new duplicate free array.
*/
function basesorteduniq(array, iteratee) {
var index = -1,
length = array.length,
resindex = 0,
result = [];
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
if (!index || !eq(computed, seen)) {
var seen = computed;
result[resindex++] = value === 0 ? 0 : value;
}
}
return result;
}
/**
* the base implementation of `_.tonumber` which doesn't ensure correct
* conversions of binary, hexadecimal, or octal string values.
*
* @private
* @param {*} value the value to process.
* @returns {number} returns the number.
*/
function basetonumber(value) {
if (typeof value == 'number') {
return value;
}
if (issymbol(value)) {
return nan;
}
return +value;
}
/**
* the base implementation of `_.tostring` which doesn't convert nullish
* values to empty strings.
*
* @private
* @param {*} value the value to process.
* @returns {string} returns the string.
*/
function basetostring(value) {
// exit early for strings to avoid a performance hit in some environments.
if (typeof value == 'string') {
return value;
}
if (isarray(value)) {
// recursively convert values (susceptible to call stack limits).
return arraymap(value, basetostring) + '';
}
if (issymbol(value)) {
return symboltostring ? symboltostring.call(value) : '';
}
var result = (value + '');
return (result == '0' && (1 / value) == -infinity) ? '-0' : result;
}
/**
* the base implementation of `_.uniqby` without support for iteratee shorthands.
*
* @private
* @param {array} array the array to inspect.
* @param {function} [iteratee] the iteratee invoked per element.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new duplicate free array.
*/
function baseuniq(array, iteratee, comparator) {
var index = -1,
includes = arrayincludes,
length = array.length,
iscommon = true,
result = [],
seen = result;
if (comparator) {
iscommon = false;
includes = arrayincludeswith;
}
else if (length >= large_array_size) {
var set = iteratee ? null : createset(array);
if (set) {
return settoarray(set);
}
iscommon = false;
includes = cachehas;
seen = new setcache;
}
else {
seen = iteratee ? [] : result;
}
outer:
while (++index < length) {
var value = array[index],
computed = iteratee ? iteratee(value) : value;
value = (comparator || value !== 0) ? value : 0;
if (iscommon && computed === computed) {
var seenindex = seen.length;
while (seenindex--) {
if (seen[seenindex] === computed) {
continue outer;
}
}
if (iteratee) {
seen.push(computed);
}
result.push(value);
}
else if (!includes(seen, computed, comparator)) {
if (seen !== result) {
seen.push(computed);
}
result.push(value);
}
}
return result;
}
/**
* the base implementation of `_.unset`.
*
* @private
* @param {object} object the object to modify.
* @param {array|string} path the property path to unset.
* @returns {boolean} returns `true` if the property is deleted, else `false`.
*/
function baseunset(object, path) {
path = castpath(path, object);
object = parent(object, path);
return object == null || delete object[tokey(last(path))];
}
/**
* the base implementation of `_.update`.
*
* @private
* @param {object} object the object to modify.
* @param {array|string} path the path of the property to update.
* @param {function} updater the function to produce the updated value.
* @param {function} [customizer] the function to customize path creation.
* @returns {object} returns `object`.
*/
function baseupdate(object, path, updater, customizer) {
return baseset(object, path, updater(baseget(object, path)), customizer);
}
/**
* the base implementation of methods like `_.dropwhile` and `_.takewhile`
* without support for iteratee shorthands.
*
* @private
* @param {array} array the array to query.
* @param {function} predicate the function invoked per iteration.
* @param {boolean} [isdrop] specify dropping elements instead of taking them.
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {array} returns the slice of `array`.
*/
function basewhile(array, predicate, isdrop, fromright) {
var length = array.length,
index = fromright ? length : -1;
while ((fromright ? index-- : ++index < length) &&
predicate(array[index], index, array)) {}
return isdrop
? baseslice(array, (fromright ? 0 : index), (fromright ? index + 1 : length))
: baseslice(array, (fromright ? index + 1 : 0), (fromright ? length : index));
}
/**
* the base implementation of `wrappervalue` which returns the result of
* performing a sequence of actions on the unwrapped `value`, where each
* successive action is supplied the return value of the previous.
*
* @private
* @param {*} value the unwrapped value.
* @param {array} actions actions to perform to resolve the unwrapped value.
* @returns {*} returns the resolved value.
*/
function basewrappervalue(value, actions) {
var result = value;
if (result instanceof lazywrapper) {
result = result.value();
}
return arrayreduce(actions, function(result, action) {
return action.func.apply(action.thisarg, arraypush([result], action.args));
}, result);
}
/**
* the base implementation of methods like `_.xor`, without support for
* iteratee shorthands, that accepts an array of arrays to inspect.
*
* @private
* @param {array} arrays the arrays to inspect.
* @param {function} [iteratee] the iteratee invoked per element.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of values.
*/
function basexor(arrays, iteratee, comparator) {
var length = arrays.length;
if (length < 2) {
return length ? baseuniq(arrays[0]) : [];
}
var index = -1,
result = array(length);
while (++index < length) {
var array = arrays[index],
othindex = -1;
while (++othindex < length) {
if (othindex != index) {
result[index] = basedifference(result[index] || array, arrays[othindex], iteratee, comparator);
}
}
}
return baseuniq(baseflatten(result, 1), iteratee, comparator);
}
/**
* this base implementation of `_.zipobject` which assigns values using `assignfunc`.
*
* @private
* @param {array} props the property identifiers.
* @param {array} values the property values.
* @param {function} assignfunc the function to assign values.
* @returns {object} returns the new object.
*/
function basezipobject(props, values, assignfunc) {
var index = -1,
length = props.length,
valslength = values.length,
result = {};
while (++index < length) {
var value = index < valslength ? values[index] : undefined;
assignfunc(result, props[index], value);
}
return result;
}
/**
* casts `value` to an empty array if it's not an array like object.
*
* @private
* @param {*} value the value to inspect.
* @returns {array|object} returns the cast array-like object.
*/
function castarraylikeobject(value) {
return isarraylikeobject(value) ? value : [];
}
/**
* casts `value` to `identity` if it's not a function.
*
* @private
* @param {*} value the value to inspect.
* @returns {function} returns cast function.
*/
function castfunction(value) {
return typeof value == 'function' ? value : identity;
}
/**
* casts `value` to a path array if it's not one.
*
* @private
* @param {*} value the value to inspect.
* @param {object} [object] the object to query keys on.
* @returns {array} returns the cast property path array.
*/
function castpath(value, object) {
if (isarray(value)) {
return value;
}
return iskey(value, object) ? [value] : stringtopath(tostring(value));
}
/**
* a `baserest` alias which can be replaced with `identity` by module
* replacement plugins.
*
* @private
* @type {function}
* @param {function} func the function to apply a rest parameter to.
* @returns {function} returns the new function.
*/
var castrest = baserest;
/**
* casts `array` to a slice if it's needed.
*
* @private
* @param {array} array the array to inspect.
* @param {number} start the start position.
* @param {number} [end=array.length] the end position.
* @returns {array} returns the cast slice.
*/
function castslice(array, start, end) {
var length = array.length;
end = end === undefined ? length : end;
return (!start && end >= length) ? array : baseslice(array, start, end);
}
/**
* a simple wrapper around the global [`cleartimeout`](https://mdn.io/cleartimeout).
*
* @private
* @param {number|object} id the timer id or timeout object of the timer to clear.
*/
var cleartimeout = ctxcleartimeout || function(id) {
return root.cleartimeout(id);
};
/**
* creates a clone of `buffer`.
*
* @private
* @param {buffer} buffer the buffer to clone.
* @param {boolean} [isdeep] specify a deep clone.
* @returns {buffer} returns the cloned buffer.
*/
function clonebuffer(buffer, isdeep) {
if (isdeep) {
return buffer.slice();
}
var length = buffer.length,
result = allocunsafe ? allocunsafe(length) : new buffer.constructor(length);
buffer.copy(result);
return result;
}
/**
* creates a clone of `arraybuffer`.
*
* @private
* @param {arraybuffer} arraybuffer the array buffer to clone.
* @returns {arraybuffer} returns the cloned array buffer.
*/
function clonearraybuffer(arraybuffer) {
var result = new arraybuffer.constructor(arraybuffer.bytelength);
new uint8array(result).set(new uint8array(arraybuffer));
return result;
}
/**
* creates a clone of `dataview`.
*
* @private
* @param {object} dataview the data view to clone.
* @param {boolean} [isdeep] specify a deep clone.
* @returns {object} returns the cloned data view.
*/
function clonedataview(dataview, isdeep) {
var buffer = isdeep ? clonearraybuffer(dataview.buffer) : dataview.buffer;
return new dataview.constructor(buffer, dataview.byteoffset, dataview.bytelength);
}
/**
* creates a clone of `regexp`.
*
* @private
* @param {object} regexp the regexp to clone.
* @returns {object} returns the cloned regexp.
*/
function cloneregexp(regexp) {
var result = new regexp.constructor(regexp.source, reflags.exec(regexp));
result.lastindex = regexp.lastindex;
return result;
}
/**
* creates a clone of the `symbol` object.
*
* @private
* @param {object} symbol the symbol object to clone.
* @returns {object} returns the cloned symbol object.
*/
function clonesymbol(symbol) {
return symbolvalueof ? object(symbolvalueof.call(symbol)) : {};
}
/**
* creates a clone of `typedarray`.
*
* @private
* @param {object} typedarray the typed array to clone.
* @param {boolean} [isdeep] specify a deep clone.
* @returns {object} returns the cloned typed array.
*/
function clonetypedarray(typedarray, isdeep) {
var buffer = isdeep ? clonearraybuffer(typedarray.buffer) : typedarray.buffer;
return new typedarray.constructor(buffer, typedarray.byteoffset, typedarray.length);
}
/**
* compares values to sort them in ascending order.
*
* @private
* @param {*} value the value to compare.
* @param {*} other the other value to compare.
* @returns {number} returns the sort order indicator for `value`.
*/
function compareascending(value, other) {
if (value !== other) {
var valisdefined = value !== undefined,
valisnull = value === null,
valisreflexive = value === value,
valissymbol = issymbol(value);
var othisdefined = other !== undefined,
othisnull = other === null,
othisreflexive = other === other,
othissymbol = issymbol(other);
if ((!othisnull && !othissymbol && !valissymbol && value > other) ||
(valissymbol && othisdefined && othisreflexive && !othisnull && !othissymbol) ||
(valisnull && othisdefined && othisreflexive) ||
(!valisdefined && othisreflexive) ||
!valisreflexive) {
return 1;
}
if ((!valisnull && !valissymbol && !othissymbol && value < other) ||
(othissymbol && valisdefined && valisreflexive && !valisnull && !valissymbol) ||
(othisnull && valisdefined && valisreflexive) ||
(!othisdefined && valisreflexive) ||
!othisreflexive) {
return -1;
}
}
return 0;
}
/**
* used by `_.orderby` to compare multiple properties of a value to another
* and stable sort them.
*
* if `orders` is unspecified, all values are sorted in ascending order. otherwise,
* specify an order of "desc" for descending or "asc" for ascending sort order
* of corresponding values.
*
* @private
* @param {object} object the object to compare.
* @param {object} other the other object to compare.
* @param {boolean[]|string[]} orders the order to sort by for each property.
* @returns {number} returns the sort order indicator for `object`.
*/
function comparemultiple(object, other, orders) {
var index = -1,
objcriteria = object.criteria,
othcriteria = other.criteria,
length = objcriteria.length,
orderslength = orders.length;
while (++index < length) {
var result = compareascending(objcriteria[index], othcriteria[index]);
if (result) {
if (index >= orderslength) {
return result;
}
var order = orders[index];
return result * (order == 'desc' ? -1 : 1);
}
}
// fixes an `array#sort` bug in the js engine embedded in adobe applications
// that causes it, under certain circumstances, to provide the same value for
// `object` and `other`. see https://github.com/jashkenas/underscore/pull/1247
// for more details.
//
// this also ensures a stable sort in v8 and other engines.
// see https://bugs.chromium.org/p/v8/issues/detail?id=90 for more details.
return object.index - other.index;
}
/**
* creates an array that is the composition of partially applied arguments,
* placeholders, and provided arguments into a single array of arguments.
*
* @private
* @param {array} args the provided arguments.
* @param {array} partials the arguments to prepend to those provided.
* @param {array} holders the `partials` placeholder indexes.
* @params {boolean} [iscurried] specify composing for a curried function.
* @returns {array} returns the new array of composed arguments.
*/
function composeargs(args, partials, holders, iscurried) {
var argsindex = -1,
argslength = args.length,
holderslength = holders.length,
leftindex = -1,
leftlength = partials.length,
rangelength = nativemax(argslength - holderslength, 0),
result = array(leftlength + rangelength),
isuncurried = !iscurried;
while (++leftindex < leftlength) {
result[leftindex] = partials[leftindex];
}
while (++argsindex < holderslength) {
if (isuncurried || argsindex < argslength) {
result[holders[argsindex]] = args[argsindex];
}
}
while (rangelength--) {
result[leftindex++] = args[argsindex++];
}
return result;
}
/**
* this function is like `composeargs` except that the arguments composition
* is tailored for `_.partialright`.
*
* @private
* @param {array} args the provided arguments.
* @param {array} partials the arguments to append to those provided.
* @param {array} holders the `partials` placeholder indexes.
* @params {boolean} [iscurried] specify composing for a curried function.
* @returns {array} returns the new array of composed arguments.
*/
function composeargsright(args, partials, holders, iscurried) {
var argsindex = -1,
argslength = args.length,
holdersindex = -1,
holderslength = holders.length,
rightindex = -1,
rightlength = partials.length,
rangelength = nativemax(argslength - holderslength, 0),
result = array(rangelength + rightlength),
isuncurried = !iscurried;
while (++argsindex < rangelength) {
result[argsindex] = args[argsindex];
}
var offset = argsindex;
while (++rightindex < rightlength) {
result[offset + rightindex] = partials[rightindex];
}
while (++holdersindex < holderslength) {
if (isuncurried || argsindex < argslength) {
result[offset + holders[holdersindex]] = args[argsindex++];
}
}
return result;
}
/**
* copies the values of `source` to `array`.
*
* @private
* @param {array} source the array to copy values from.
* @param {array} [array=[]] the array to copy values to.
* @returns {array} returns `array`.
*/
function copyarray(source, array) {
var index = -1,
length = source.length;
array || (array = array(length));
while (++index < length) {
array[index] = source[index];
}
return array;
}
/**
* copies properties of `source` to `object`.
*
* @private
* @param {object} source the object to copy properties from.
* @param {array} props the property identifiers to copy.
* @param {object} [object={}] the object to copy properties to.
* @param {function} [customizer] the function to customize copied values.
* @returns {object} returns `object`.
*/
function copyobject(source, props, object, customizer) {
var isnew = !object;
object || (object = {});
var index = -1,
length = props.length;
while (++index < length) {
var key = props[index];
var newvalue = customizer
? customizer(object[key], source[key], key, object, source)
: undefined;
if (newvalue === undefined) {
newvalue = source[key];
}
if (isnew) {
baseassignvalue(object, key, newvalue);
} else {
assignvalue(object, key, newvalue);
}
}
return object;
}
/**
* copies own symbols of `source` to `object`.
*
* @private
* @param {object} source the object to copy symbols from.
* @param {object} [object={}] the object to copy symbols to.
* @returns {object} returns `object`.
*/
function copysymbols(source, object) {
return copyobject(source, getsymbols(source), object);
}
/**
* copies own and inherited symbols of `source` to `object`.
*
* @private
* @param {object} source the object to copy symbols from.
* @param {object} [object={}] the object to copy symbols to.
* @returns {object} returns `object`.
*/
function copysymbolsin(source, object) {
return copyobject(source, getsymbolsin(source), object);
}
/**
* creates a function like `_.groupby`.
*
* @private
* @param {function} setter the function to set accumulator values.
* @param {function} [initializer] the accumulator object initializer.
* @returns {function} returns the new aggregator function.
*/
function createaggregator(setter, initializer) {
return function(collection, iteratee) {
var func = isarray(collection) ? arrayaggregator : baseaggregator,
accumulator = initializer ? initializer() : {};
return func(collection, setter, getiteratee(iteratee, 2), accumulator);
};
}
/**
* creates a function like `_.assign`.
*
* @private
* @param {function} assigner the function to assign values.
* @returns {function} returns the new assigner function.
*/
function createassigner(assigner) {
return baserest(function(object, sources) {
var index = -1,
length = sources.length,
customizer = length > 1 ? sources[length - 1] : undefined,
guard = length > 2 ? sources[2] : undefined;
customizer = (assigner.length > 3 && typeof customizer == 'function')
? (length--, customizer)
: undefined;
if (guard && isiterateecall(sources[0], sources[1], guard)) {
customizer = length < 3 ? undefined : customizer;
length = 1;
}
object = object(object);
while (++index < length) {
var source = sources[index];
if (source) {
assigner(object, source, index, customizer);
}
}
return object;
});
}
/**
* creates a `baseeach` or `baseeachright` function.
*
* @private
* @param {function} eachfunc the function to iterate over a collection.
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {function} returns the new base function.
*/
function createbaseeach(eachfunc, fromright) {
return function(collection, iteratee) {
if (collection == null) {
return collection;
}
if (!isarraylike(collection)) {
return eachfunc(collection, iteratee);
}
var length = collection.length,
index = fromright ? length : -1,
iterable = object(collection);
while ((fromright ? index-- : ++index < length)) {
if (iteratee(iterable[index], index, iterable) === false) {
break;
}
}
return collection;
};
}
/**
* creates a base function for methods like `_.forin` and `_.forown`.
*
* @private
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {function} returns the new base function.
*/
function createbasefor(fromright) {
return function(object, iteratee, keysfunc) {
var index = -1,
iterable = object(object),
props = keysfunc(object),
length = props.length;
while (length--) {
var key = props[fromright ? length : ++index];
if (iteratee(iterable[key], key, iterable) === false) {
break;
}
}
return object;
};
}
/**
* creates a function that wraps `func` to invoke it with the optional `this`
* binding of `thisarg`.
*
* @private
* @param {function} func the function to wrap.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @param {*} [thisarg] the `this` binding of `func`.
* @returns {function} returns the new wrapped function.
*/
function createbind(func, bitmask, thisarg) {
var isbind = bitmask & wrap_bind_flag,
ctor = creatector(func);
function wrapper() {
var fn = (this && this !== root && this instanceof wrapper) ? ctor : func;
return fn.apply(isbind ? thisarg : this, arguments);
}
return wrapper;
}
/**
* creates a function like `_.lowerfirst`.
*
* @private
* @param {string} methodname the name of the `string` case method to use.
* @returns {function} returns the new case function.
*/
function createcasefirst(methodname) {
return function(string) {
string = tostring(string);
var strsymbols = hasunicode(string)
? stringtoarray(string)
: undefined;
var chr = strsymbols
? strsymbols[0]
: string.charat(0);
var trailing = strsymbols
? castslice(strsymbols, 1).join('')
: string.slice(1);
return chr[methodname]() + trailing;
};
}
/**
* creates a function like `_.camelcase`.
*
* @private
* @param {function} callback the function to combine each word.
* @returns {function} returns the new compounder function.
*/
function createcompounder(callback) {
return function(string) {
return arrayreduce(words(deburr(string).replace(reapos, '')), callback, '');
};
}
/**
* creates a function that produces an instance of `ctor` regardless of
* whether it was invoked as part of a `new` expression or by `call` or `apply`.
*
* @private
* @param {function} ctor the constructor to wrap.
* @returns {function} returns the new wrapped function.
*/
function creatector(ctor) {
return function() {
// use a `switch` statement to work with class constructors. see
// http://ecma-international.org/ecma-262/7.0/#sec-ecmascript-function-objects-call-thisargument-argumentslist
// for more details.
var args = arguments;
switch (args.length) {
case 0: return new ctor;
case 1: return new ctor(args[0]);
case 2: return new ctor(args[0], args[1]);
case 3: return new ctor(args[0], args[1], args[2]);
case 4: return new ctor(args[0], args[1], args[2], args[3]);
case 5: return new ctor(args[0], args[1], args[2], args[3], args[4]);
case 6: return new ctor(args[0], args[1], args[2], args[3], args[4], args[5]);
case 7: return new ctor(args[0], args[1], args[2], args[3], args[4], args[5], args[6]);
}
var thisbinding = basecreate(ctor.prototype),
result = ctor.apply(thisbinding, args);
// mimic the constructor's `return` behavior.
// see https://es5.github.io/#x13.2.2 for more details.
return isobject(result) ? result : thisbinding;
};
}
/**
* creates a function that wraps `func` to enable currying.
*
* @private
* @param {function} func the function to wrap.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @param {number} arity the arity of `func`.
* @returns {function} returns the new wrapped function.
*/
function createcurry(func, bitmask, arity) {
var ctor = creatector(func);
function wrapper() {
var length = arguments.length,
args = array(length),
index = length,
placeholder = getholder(wrapper);
while (index--) {
args[index] = arguments[index];
}
var holders = (length < 3 && args[0] !== placeholder && args[length - 1] !== placeholder)
? []
: replaceholders(args, placeholder);
length -= holders.length;
if (length < arity) {
return createrecurry(
func, bitmask, createhybrid, wrapper.placeholder, undefined,
args, holders, undefined, undefined, arity - length);
}
var fn = (this && this !== root && this instanceof wrapper) ? ctor : func;
return apply(fn, this, args);
}
return wrapper;
}
/**
* creates a `_.find` or `_.findlast` function.
*
* @private
* @param {function} findindexfunc the function to find the collection index.
* @returns {function} returns the new find function.
*/
function createfind(findindexfunc) {
return function(collection, predicate, fromindex) {
var iterable = object(collection);
if (!isarraylike(collection)) {
var iteratee = getiteratee(predicate, 3);
collection = keys(collection);
predicate = function(key) { return iteratee(iterable[key], key, iterable); };
}
var index = findindexfunc(collection, predicate, fromindex);
return index > -1 ? iterable[iteratee ? collection[index] : index] : undefined;
};
}
/**
* creates a `_.flow` or `_.flowright` function.
*
* @private
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {function} returns the new flow function.
*/
function createflow(fromright) {
return flatrest(function(funcs) {
var length = funcs.length,
index = length,
prereq = lodashwrapper.prototype.thru;
if (fromright) {
funcs.reverse();
}
while (index--) {
var func = funcs[index];
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
if (prereq && !wrapper && getfuncname(func) == 'wrapper') {
var wrapper = new lodashwrapper([], true);
}
}
index = wrapper ? index : length;
while (++index < length) {
func = funcs[index];
var funcname = getfuncname(func),
data = funcname == 'wrapper' ? getdata(func) : undefined;
if (data && islaziable(data[0]) &&
data[1] == (wrap_ary_flag | wrap_curry_flag | wrap_partial_flag | wrap_rearg_flag) &&
!data[4].length && data[9] == 1
) {
wrapper = wrapper[getfuncname(data[0])].apply(wrapper, data[3]);
} else {
wrapper = (func.length == 1 && islaziable(func))
? wrapper[funcname]()
: wrapper.thru(func);
}
}
return function() {
var args = arguments,
value = args[0];
if (wrapper && args.length == 1 && isarray(value)) {
return wrapper.plant(value).value();
}
var index = 0,
result = length ? funcs[index].apply(this, args) : value;
while (++index < length) {
result = funcs[index].call(this, result);
}
return result;
};
});
}
/**
* creates a function that wraps `func` to invoke it with optional `this`
* binding of `thisarg`, partial application, and currying.
*
* @private
* @param {function|string} func the function or method name to wrap.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @param {*} [thisarg] the `this` binding of `func`.
* @param {array} [partials] the arguments to prepend to those provided to
* the new function.
* @param {array} [holders] the `partials` placeholder indexes.
* @param {array} [partialsright] the arguments to append to those provided
* to the new function.
* @param {array} [holdersright] the `partialsright` placeholder indexes.
* @param {array} [argpos] the argument positions of the new function.
* @param {number} [ary] the arity cap of `func`.
* @param {number} [arity] the arity of `func`.
* @returns {function} returns the new wrapped function.
*/
function createhybrid(func, bitmask, thisarg, partials, holders, partialsright, holdersright, argpos, ary, arity) {
var isary = bitmask & wrap_ary_flag,
isbind = bitmask & wrap_bind_flag,
isbindkey = bitmask & wrap_bind_key_flag,
iscurried = bitmask & (wrap_curry_flag | wrap_curry_right_flag),
isflip = bitmask & wrap_flip_flag,
ctor = isbindkey ? undefined : creatector(func);
function wrapper() {
var length = arguments.length,
args = array(length),
index = length;
while (index--) {
args[index] = arguments[index];
}
if (iscurried) {
var placeholder = getholder(wrapper),
holderscount = countholders(args, placeholder);
}
if (partials) {
args = composeargs(args, partials, holders, iscurried);
}
if (partialsright) {
args = composeargsright(args, partialsright, holdersright, iscurried);
}
length -= holderscount;
if (iscurried && length < arity) {
var newholders = replaceholders(args, placeholder);
return createrecurry(
func, bitmask, createhybrid, wrapper.placeholder, thisarg,
args, newholders, argpos, ary, arity - length
);
}
var thisbinding = isbind ? thisarg : this,
fn = isbindkey ? thisbinding[func] : func;
length = args.length;
if (argpos) {
args = reorder(args, argpos);
} else if (isflip && length > 1) {
args.reverse();
}
if (isary && ary < length) {
args.length = ary;
}
if (this && this !== root && this instanceof wrapper) {
fn = ctor || creatector(fn);
}
return fn.apply(thisbinding, args);
}
return wrapper;
}
/**
* creates a function like `_.invertby`.
*
* @private
* @param {function} setter the function to set accumulator values.
* @param {function} toiteratee the function to resolve iteratees.
* @returns {function} returns the new inverter function.
*/
function createinverter(setter, toiteratee) {
return function(object, iteratee) {
return baseinverter(object, setter, toiteratee(iteratee), {});
};
}
/**
* creates a function that performs a mathematical operation on two values.
*
* @private
* @param {function} operator the function to perform the operation.
* @param {number} [defaultvalue] the value used for `undefined` arguments.
* @returns {function} returns the new mathematical operation function.
*/
function createmathoperation(operator, defaultvalue) {
return function(value, other) {
var result;
if (value === undefined && other === undefined) {
return defaultvalue;
}
if (value !== undefined) {
result = value;
}
if (other !== undefined) {
if (result === undefined) {
return other;
}
if (typeof value == 'string' || typeof other == 'string') {
value = basetostring(value);
other = basetostring(other);
} else {
value = basetonumber(value);
other = basetonumber(other);
}
result = operator(value, other);
}
return result;
};
}
/**
* creates a function like `_.over`.
*
* @private
* @param {function} arrayfunc the function to iterate over iteratees.
* @returns {function} returns the new over function.
*/
function createover(arrayfunc) {
return flatrest(function(iteratees) {
iteratees = arraymap(iteratees, baseunary(getiteratee()));
return baserest(function(args) {
var thisarg = this;
return arrayfunc(iteratees, function(iteratee) {
return apply(iteratee, thisarg, args);
});
});
});
}
/**
* creates the padding for `string` based on `length`. the `chars` string
* is truncated if the number of characters exceeds `length`.
*
* @private
* @param {number} length the padding length.
* @param {string} [chars=' '] the string used as padding.
* @returns {string} returns the padding for `string`.
*/
function createpadding(length, chars) {
chars = chars === undefined ? ' ' : basetostring(chars);
var charslength = chars.length;
if (charslength < 2) {
return charslength ? baserepeat(chars, length) : chars;
}
var result = baserepeat(chars, nativeceil(length / stringsize(chars)));
return hasunicode(chars)
? castslice(stringtoarray(result), 0, length).join('')
: result.slice(0, length);
}
/**
* creates a function that wraps `func` to invoke it with the `this` binding
* of `thisarg` and `partials` prepended to the arguments it receives.
*
* @private
* @param {function} func the function to wrap.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @param {*} thisarg the `this` binding of `func`.
* @param {array} partials the arguments to prepend to those provided to
* the new function.
* @returns {function} returns the new wrapped function.
*/
function createpartial(func, bitmask, thisarg, partials) {
var isbind = bitmask & wrap_bind_flag,
ctor = creatector(func);
function wrapper() {
var argsindex = -1,
argslength = arguments.length,
leftindex = -1,
leftlength = partials.length,
args = array(leftlength + argslength),
fn = (this && this !== root && this instanceof wrapper) ? ctor : func;
while (++leftindex < leftlength) {
args[leftindex] = partials[leftindex];
}
while (argslength--) {
args[leftindex++] = arguments[++argsindex];
}
return apply(fn, isbind ? thisarg : this, args);
}
return wrapper;
}
/**
* creates a `_.range` or `_.rangeright` function.
*
* @private
* @param {boolean} [fromright] specify iterating from right to left.
* @returns {function} returns the new range function.
*/
function createrange(fromright) {
return function(start, end, step) {
if (step && typeof step != 'number' && isiterateecall(start, end, step)) {
end = step = undefined;
}
// ensure the sign of `-0` is preserved.
start = tofinite(start);
if (end === undefined) {
end = start;
start = 0;
} else {
end = tofinite(end);
}
step = step === undefined ? (start < end ? 1 : -1) : tofinite(step);
return baserange(start, end, step, fromright);
};
}
/**
* creates a function that performs a relational operation on two values.
*
* @private
* @param {function} operator the function to perform the operation.
* @returns {function} returns the new relational operation function.
*/
function createrelationaloperation(operator) {
return function(value, other) {
if (!(typeof value == 'string' && typeof other == 'string')) {
value = tonumber(value);
other = tonumber(other);
}
return operator(value, other);
};
}
/**
* creates a function that wraps `func` to continue currying.
*
* @private
* @param {function} func the function to wrap.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @param {function} wrapfunc the function to create the `func` wrapper.
* @param {*} placeholder the placeholder value.
* @param {*} [thisarg] the `this` binding of `func`.
* @param {array} [partials] the arguments to prepend to those provided to
* the new function.
* @param {array} [holders] the `partials` placeholder indexes.
* @param {array} [argpos] the argument positions of the new function.
* @param {number} [ary] the arity cap of `func`.
* @param {number} [arity] the arity of `func`.
* @returns {function} returns the new wrapped function.
*/
function createrecurry(func, bitmask, wrapfunc, placeholder, thisarg, partials, holders, argpos, ary, arity) {
var iscurry = bitmask & wrap_curry_flag,
newholders = iscurry ? holders : undefined,
newholdersright = iscurry ? undefined : holders,
newpartials = iscurry ? partials : undefined,
newpartialsright = iscurry ? undefined : partials;
bitmask |= (iscurry ? wrap_partial_flag : wrap_partial_right_flag);
bitmask &= ~(iscurry ? wrap_partial_right_flag : wrap_partial_flag);
if (!(bitmask & wrap_curry_bound_flag)) {
bitmask &= ~(wrap_bind_flag | wrap_bind_key_flag);
}
var newdata = [
func, bitmask, thisarg, newpartials, newholders, newpartialsright,
newholdersright, argpos, ary, arity
];
var result = wrapfunc.apply(undefined, newdata);
if (islaziable(func)) {
setdata(result, newdata);
}
result.placeholder = placeholder;
return setwraptostring(result, func, bitmask);
}
/**
* creates a function like `_.round`.
*
* @private
* @param {string} methodname the name of the `math` method to use when rounding.
* @returns {function} returns the new round function.
*/
function createround(methodname) {
var func = math[methodname];
return function(number, precision) {
number = tonumber(number);
precision = precision == null ? 0 : nativemin(tointeger(precision), 292);
if (precision) {
// shift with exponential notation to avoid floating-point issues.
// see [mdn](https://mdn.io/round#examples) for more details.
var pair = (tostring(number) + 'e').split('e'),
value = func(pair[0] + 'e' + (+pair[1] + precision));
pair = (tostring(value) + 'e').split('e');
return +(pair[0] + 'e' + (+pair[1] - precision));
}
return func(number);
};
}
/**
* creates a set object of `values`.
*
* @private
* @param {array} values the values to add to the set.
* @returns {object} returns the new set.
*/
var createset = !(set && (1 / settoarray(new set([,-0]))[1]) == infinity) ? noop : function(values) {
return new set(values);
};
/**
* creates a `_.topairs` or `_.topairsin` function.
*
* @private
* @param {function} keysfunc the function to get the keys of a given object.
* @returns {function} returns the new pairs function.
*/
function createtopairs(keysfunc) {
return function(object) {
var tag = gettag(object);
if (tag == maptag) {
return maptoarray(object);
}
if (tag == settag) {
return settopairs(object);
}
return basetopairs(object, keysfunc(object));
};
}
/**
* creates a function that either curries or invokes `func` with optional
* `this` binding and partially applied arguments.
*
* @private
* @param {function|string} func the function or method name to wrap.
* @param {number} bitmask the bitmask flags.
* 1 - `_.bind`
* 2 - `_.bindkey`
* 4 - `_.curry` or `_.curryright` of a bound function
* 8 - `_.curry`
* 16 - `_.curryright`
* 32 - `_.partial`
* 64 - `_.partialright`
* 128 - `_.rearg`
* 256 - `_.ary`
* 512 - `_.flip`
* @param {*} [thisarg] the `this` binding of `func`.
* @param {array} [partials] the arguments to be partially applied.
* @param {array} [holders] the `partials` placeholder indexes.
* @param {array} [argpos] the argument positions of the new function.
* @param {number} [ary] the arity cap of `func`.
* @param {number} [arity] the arity of `func`.
* @returns {function} returns the new wrapped function.
*/
function createwrap(func, bitmask, thisarg, partials, holders, argpos, ary, arity) {
var isbindkey = bitmask & wrap_bind_key_flag;
if (!isbindkey && typeof func != 'function') {
throw new typeerror(func_error_text);
}
var length = partials ? partials.length : 0;
if (!length) {
bitmask &= ~(wrap_partial_flag | wrap_partial_right_flag);
partials = holders = undefined;
}
ary = ary === undefined ? ary : nativemax(tointeger(ary), 0);
arity = arity === undefined ? arity : tointeger(arity);
length -= holders ? holders.length : 0;
if (bitmask & wrap_partial_right_flag) {
var partialsright = partials,
holdersright = holders;
partials = holders = undefined;
}
var data = isbindkey ? undefined : getdata(func);
var newdata = [
func, bitmask, thisarg, partials, holders, partialsright, holdersright,
argpos, ary, arity
];
if (data) {
mergedata(newdata, data);
}
func = newdata[0];
bitmask = newdata[1];
thisarg = newdata[2];
partials = newdata[3];
holders = newdata[4];
arity = newdata[9] = newdata[9] === undefined
? (isbindkey ? 0 : func.length)
: nativemax(newdata[9] - length, 0);
if (!arity && bitmask & (wrap_curry_flag | wrap_curry_right_flag)) {
bitmask &= ~(wrap_curry_flag | wrap_curry_right_flag);
}
if (!bitmask || bitmask == wrap_bind_flag) {
var result = createbind(func, bitmask, thisarg);
} else if (bitmask == wrap_curry_flag || bitmask == wrap_curry_right_flag) {
result = createcurry(func, bitmask, arity);
} else if ((bitmask == wrap_partial_flag || bitmask == (wrap_bind_flag | wrap_partial_flag)) && !holders.length) {
result = createpartial(func, bitmask, thisarg, partials);
} else {
result = createhybrid.apply(undefined, newdata);
}
var setter = data ? basesetdata : setdata;
return setwraptostring(setter(result, newdata), func, bitmask);
}
/**
* used by `_.defaults` to customize its `_.assignin` use to assign properties
* of source objects to the destination object for all destination properties
* that resolve to `undefined`.
*
* @private
* @param {*} objvalue the destination value.
* @param {*} srcvalue the source value.
* @param {string} key the key of the property to assign.
* @param {object} object the parent object of `objvalue`.
* @returns {*} returns the value to assign.
*/
function customdefaultsassignin(objvalue, srcvalue, key, object) {
if (objvalue === undefined ||
(eq(objvalue, objectproto[key]) && !hasownproperty.call(object, key))) {
return srcvalue;
}
return objvalue;
}
/**
* used by `_.defaultsdeep` to customize its `_.merge` use to merge source
* objects into destination objects that are passed thru.
*
* @private
* @param {*} objvalue the destination value.
* @param {*} srcvalue the source value.
* @param {string} key the key of the property to merge.
* @param {object} object the parent object of `objvalue`.
* @param {object} source the parent object of `srcvalue`.
* @param {object} [stack] tracks traversed source values and their merged
* counterparts.
* @returns {*} returns the value to assign.
*/
function customdefaultsmerge(objvalue, srcvalue, key, object, source, stack) {
if (isobject(objvalue) && isobject(srcvalue)) {
// recursively merge objects and arrays (susceptible to call stack limits).
stack.set(srcvalue, objvalue);
basemerge(objvalue, srcvalue, undefined, customdefaultsmerge, stack);
stack['delete'](srcvalue);
}
return objvalue;
}
/**
* used by `_.omit` to customize its `_.clonedeep` use to only clone plain
* objects.
*
* @private
* @param {*} value the value to inspect.
* @param {string} key the key of the property to inspect.
* @returns {*} returns the uncloned value or `undefined` to defer cloning to `_.clonedeep`.
*/
function customomitclone(value) {
return isplainobject(value) ? undefined : value;
}
/**
* a specialized version of `baseisequaldeep` for arrays with support for
* partial deep comparisons.
*
* @private
* @param {array} array the array to compare.
* @param {array} other the other array to compare.
* @param {number} bitmask the bitmask flags. see `baseisequal` for more details.
* @param {function} customizer the function to customize comparisons.
* @param {function} equalfunc the function to determine equivalents of values.
* @param {object} stack tracks traversed `array` and `other` objects.
* @returns {boolean} returns `true` if the arrays are equivalent, else `false`.
*/
function equalarrays(array, other, bitmask, customizer, equalfunc, stack) {
var ispartial = bitmask & compare_partial_flag,
arrlength = array.length,
othlength = other.length;
if (arrlength != othlength && !(ispartial && othlength > arrlength)) {
return false;
}
// assume cyclic values are equal.
var stacked = stack.get(array);
if (stacked && stack.get(other)) {
return stacked == other;
}
var index = -1,
result = true,
seen = (bitmask & compare_unordered_flag) ? new setcache : undefined;
stack.set(array, other);
stack.set(other, array);
// ignore non-index properties.
while (++index < arrlength) {
var arrvalue = array[index],
othvalue = other[index];
if (customizer) {
var compared = ispartial
? customizer(othvalue, arrvalue, index, other, array, stack)
: customizer(arrvalue, othvalue, index, array, other, stack);
}
if (compared !== undefined) {
if (compared) {
continue;
}
result = false;
break;
}
// recursively compare arrays (susceptible to call stack limits).
if (seen) {
if (!arraysome(other, function(othvalue, othindex) {
if (!cachehas(seen, othindex) &&
(arrvalue === othvalue || equalfunc(arrvalue, othvalue, bitmask, customizer, stack))) {
return seen.push(othindex);
}
})) {
result = false;
break;
}
} else if (!(
arrvalue === othvalue ||
equalfunc(arrvalue, othvalue, bitmask, customizer, stack)
)) {
result = false;
break;
}
}
stack['delete'](array);
stack['delete'](other);
return result;
}
/**
* a specialized version of `baseisequaldeep` for comparing objects of
* the same `tostringtag`.
*
* **note:** this function only supports comparing values with tags of
* `boolean`, `date`, `error`, `number`, `regexp`, or `string`.
*
* @private
* @param {object} object the object to compare.
* @param {object} other the other object to compare.
* @param {string} tag the `tostringtag` of the objects to compare.
* @param {number} bitmask the bitmask flags. see `baseisequal` for more details.
* @param {function} customizer the function to customize comparisons.
* @param {function} equalfunc the function to determine equivalents of values.
* @param {object} stack tracks traversed `object` and `other` objects.
* @returns {boolean} returns `true` if the objects are equivalent, else `false`.
*/
function equalbytag(object, other, tag, bitmask, customizer, equalfunc, stack) {
switch (tag) {
case dataviewtag:
if ((object.bytelength != other.bytelength) ||
(object.byteoffset != other.byteoffset)) {
return false;
}
object = object.buffer;
other = other.buffer;
case arraybuffertag:
if ((object.bytelength != other.bytelength) ||
!equalfunc(new uint8array(object), new uint8array(other))) {
return false;
}
return true;
case booltag:
case datetag:
case numbertag:
// coerce booleans to `1` or `0` and dates to milliseconds.
// invalid dates are coerced to `nan`.
return eq(+object, +other);
case errortag:
return object.name == other.name && object.message == other.message;
case regexptag:
case stringtag:
// coerce regexes to strings and treat strings, primitives and objects,
// as equal. see http://www.ecma-international.org/ecma-262/7.0/#sec-regexp.prototype.tostring
// for more details.
return object == (other + '');
case maptag:
var convert = maptoarray;
case settag:
var ispartial = bitmask & compare_partial_flag;
convert || (convert = settoarray);
if (object.size != other.size && !ispartial) {
return false;
}
// assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked) {
return stacked == other;
}
bitmask |= compare_unordered_flag;
// recursively compare objects (susceptible to call stack limits).
stack.set(object, other);
var result = equalarrays(convert(object), convert(other), bitmask, customizer, equalfunc, stack);
stack['delete'](object);
return result;
case symboltag:
if (symbolvalueof) {
return symbolvalueof.call(object) == symbolvalueof.call(other);
}
}
return false;
}
/**
* a specialized version of `baseisequaldeep` for objects with support for
* partial deep comparisons.
*
* @private
* @param {object} object the object to compare.
* @param {object} other the other object to compare.
* @param {number} bitmask the bitmask flags. see `baseisequal` for more details.
* @param {function} customizer the function to customize comparisons.
* @param {function} equalfunc the function to determine equivalents of values.
* @param {object} stack tracks traversed `object` and `other` objects.
* @returns {boolean} returns `true` if the objects are equivalent, else `false`.
*/
function equalobjects(object, other, bitmask, customizer, equalfunc, stack) {
var ispartial = bitmask & compare_partial_flag,
objprops = getallkeys(object),
objlength = objprops.length,
othprops = getallkeys(other),
othlength = othprops.length;
if (objlength != othlength && !ispartial) {
return false;
}
var index = objlength;
while (index--) {
var key = objprops[index];
if (!(ispartial ? key in other : hasownproperty.call(other, key))) {
return false;
}
}
// assume cyclic values are equal.
var stacked = stack.get(object);
if (stacked && stack.get(other)) {
return stacked == other;
}
var result = true;
stack.set(object, other);
stack.set(other, object);
var skipctor = ispartial;
while (++index < objlength) {
key = objprops[index];
var objvalue = object[key],
othvalue = other[key];
if (customizer) {
var compared = ispartial
? customizer(othvalue, objvalue, key, other, object, stack)
: customizer(objvalue, othvalue, key, object, other, stack);
}
// recursively compare objects (susceptible to call stack limits).
if (!(compared === undefined
? (objvalue === othvalue || equalfunc(objvalue, othvalue, bitmask, customizer, stack))
: compared
)) {
result = false;
break;
}
skipctor || (skipctor = key == 'constructor');
}
if (result && !skipctor) {
var objctor = object.constructor,
othctor = other.constructor;
// non `object` object instances with different constructors are not equal.
if (objctor != othctor &&
('constructor' in object && 'constructor' in other) &&
!(typeof objctor == 'function' && objctor instanceof objctor &&
typeof othctor == 'function' && othctor instanceof othctor)) {
result = false;
}
}
stack['delete'](object);
stack['delete'](other);
return result;
}
/**
* a specialized version of `baserest` which flattens the rest array.
*
* @private
* @param {function} func the function to apply a rest parameter to.
* @returns {function} returns the new function.
*/
function flatrest(func) {
return settostring(overrest(func, undefined, flatten), func + '');
}
/**
* creates an array of own enumerable property names and symbols of `object`.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of property names and symbols.
*/
function getallkeys(object) {
return basegetallkeys(object, keys, getsymbols);
}
/**
* creates an array of own and inherited enumerable property names and
* symbols of `object`.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of property names and symbols.
*/
function getallkeysin(object) {
return basegetallkeys(object, keysin, getsymbolsin);
}
/**
* gets metadata for `func`.
*
* @private
* @param {function} func the function to query.
* @returns {*} returns the metadata for `func`.
*/
var getdata = !metamap ? noop : function(func) {
return metamap.get(func);
};
/**
* gets the name of `func`.
*
* @private
* @param {function} func the function to query.
* @returns {string} returns the function name.
*/
function getfuncname(func) {
var result = (func.name + ''),
array = realnames[result],
length = hasownproperty.call(realnames, result) ? array.length : 0;
while (length--) {
var data = array[length],
otherfunc = data.func;
if (otherfunc == null || otherfunc == func) {
return data.name;
}
}
return result;
}
/**
* gets the argument placeholder value for `func`.
*
* @private
* @param {function} func the function to inspect.
* @returns {*} returns the placeholder value.
*/
function getholder(func) {
var object = hasownproperty.call(lodash, 'placeholder') ? lodash : func;
return object.placeholder;
}
/**
* gets the appropriate "iteratee" function. if `_.iteratee` is customized,
* this function returns the custom method, otherwise it returns `baseiteratee`.
* if arguments are provided, the chosen function is invoked with them and
* its result is returned.
*
* @private
* @param {*} [value] the value to convert to an iteratee.
* @param {number} [arity] the arity of the created iteratee.
* @returns {function} returns the chosen function or its result.
*/
function getiteratee() {
var result = lodash.iteratee || iteratee;
result = result === iteratee ? baseiteratee : result;
return arguments.length ? result(arguments[0], arguments[1]) : result;
}
/**
* gets the data for `map`.
*
* @private
* @param {object} map the map to query.
* @param {string} key the reference key.
* @returns {*} returns the map data.
*/
function getmapdata(map, key) {
var data = map.__data__;
return iskeyable(key)
? data[typeof key == 'string' ? 'string' : 'hash']
: data.map;
}
/**
* gets the property names, values, and compare flags of `object`.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the match data of `object`.
*/
function getmatchdata(object) {
var result = keys(object),
length = result.length;
while (length--) {
var key = result[length],
value = object[key];
result[length] = [key, value, isstrictcomparable(value)];
}
return result;
}
/**
* gets the native function at `key` of `object`.
*
* @private
* @param {object} object the object to query.
* @param {string} key the key of the method to get.
* @returns {*} returns the function if it's native, else `undefined`.
*/
function getnative(object, key) {
var value = getvalue(object, key);
return baseisnative(value) ? value : undefined;
}
/**
* a specialized version of `basegettag` which ignores `symbol.tostringtag` values.
*
* @private
* @param {*} value the value to query.
* @returns {string} returns the raw `tostringtag`.
*/
function getrawtag(value) {
var isown = hasownproperty.call(value, symtostringtag),
tag = value[symtostringtag];
try {
value[symtostringtag] = undefined;
var unmasked = true;
} catch (e) {}
var result = nativeobjecttostring.call(value);
if (unmasked) {
if (isown) {
value[symtostringtag] = tag;
} else {
delete value[symtostringtag];
}
}
return result;
}
/**
* creates an array of the own enumerable symbols of `object`.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of symbols.
*/
var getsymbols = !nativegetsymbols ? stubarray : function(object) {
if (object == null) {
return [];
}
object = object(object);
return arrayfilter(nativegetsymbols(object), function(symbol) {
return propertyisenumerable.call(object, symbol);
});
};
/**
* creates an array of the own and inherited enumerable symbols of `object`.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of symbols.
*/
var getsymbolsin = !nativegetsymbols ? stubarray : function(object) {
var result = [];
while (object) {
arraypush(result, getsymbols(object));
object = getprototype(object);
}
return result;
};
/**
* gets the `tostringtag` of `value`.
*
* @private
* @param {*} value the value to query.
* @returns {string} returns the `tostringtag`.
*/
var gettag = basegettag;
// fallback for data views, maps, sets, and weak maps in ie 11 and promises in node.js < 6.
if ((dataview && gettag(new dataview(new arraybuffer(1))) != dataviewtag) ||
(map && gettag(new map) != maptag) ||
(promise && gettag(promise.resolve()) != promisetag) ||
(set && gettag(new set) != settag) ||
(weakmap && gettag(new weakmap) != weakmaptag)) {
gettag = function(value) {
var result = basegettag(value),
ctor = result == objecttag ? value.constructor : undefined,
ctorstring = ctor ? tosource(ctor) : '';
if (ctorstring) {
switch (ctorstring) {
case dataviewctorstring: return dataviewtag;
case mapctorstring: return maptag;
case promisectorstring: return promisetag;
case setctorstring: return settag;
case weakmapctorstring: return weakmaptag;
}
}
return result;
};
}
/**
* gets the view, applying any `transforms` to the `start` and `end` positions.
*
* @private
* @param {number} start the start of the view.
* @param {number} end the end of the view.
* @param {array} transforms the transformations to apply to the view.
* @returns {object} returns an object containing the `start` and `end`
* positions of the view.
*/
function getview(start, end, transforms) {
var index = -1,
length = transforms.length;
while (++index < length) {
var data = transforms[index],
size = data.size;
switch (data.type) {
case 'drop': start += size; break;
case 'dropright': end -= size; break;
case 'take': end = nativemin(end, start + size); break;
case 'takeright': start = nativemax(start, end - size); break;
}
}
return { 'start': start, 'end': end };
}
/**
* extracts wrapper details from the `source` body comment.
*
* @private
* @param {string} source the source to inspect.
* @returns {array} returns the wrapper details.
*/
function getwrapdetails(source) {
var match = source.match(rewrapdetails);
return match ? match[1].split(resplitdetails) : [];
}
/**
* checks if `path` exists on `object`.
*
* @private
* @param {object} object the object to query.
* @param {array|string} path the path to check.
* @param {function} hasfunc the function to check properties.
* @returns {boolean} returns `true` if `path` exists, else `false`.
*/
function haspath(object, path, hasfunc) {
path = castpath(path, object);
var index = -1,
length = path.length,
result = false;
while (++index < length) {
var key = tokey(path[index]);
if (!(result = object != null && hasfunc(object, key))) {
break;
}
object = object[key];
}
if (result || ++index != length) {
return result;
}
length = object == null ? 0 : object.length;
return !!length && islength(length) && isindex(key, length) &&
(isarray(object) || isarguments(object));
}
/**
* initializes an array clone.
*
* @private
* @param {array} array the array to clone.
* @returns {array} returns the initialized clone.
*/
function initclonearray(array) {
var length = array.length,
result = new array.constructor(length);
// add properties assigned by `regexp#exec`.
if (length && typeof array[0] == 'string' && hasownproperty.call(array, 'index')) {
result.index = array.index;
result.input = array.input;
}
return result;
}
/**
* initializes an object clone.
*
* @private
* @param {object} object the object to clone.
* @returns {object} returns the initialized clone.
*/
function initcloneobject(object) {
return (typeof object.constructor == 'function' && !isprototype(object))
? basecreate(getprototype(object))
: {};
}
/**
* initializes an object clone based on its `tostringtag`.
*
* **note:** this function only supports cloning values with tags of
* `boolean`, `date`, `error`, `map`, `number`, `regexp`, `set`, or `string`.
*
* @private
* @param {object} object the object to clone.
* @param {string} tag the `tostringtag` of the object to clone.
* @param {boolean} [isdeep] specify a deep clone.
* @returns {object} returns the initialized clone.
*/
function initclonebytag(object, tag, isdeep) {
var ctor = object.constructor;
switch (tag) {
case arraybuffertag:
return clonearraybuffer(object);
case booltag:
case datetag:
return new ctor(+object);
case dataviewtag:
return clonedataview(object, isdeep);
case float32tag: case float64tag:
case int8tag: case int16tag: case int32tag:
case uint8tag: case uint8clampedtag: case uint16tag: case uint32tag:
return clonetypedarray(object, isdeep);
case maptag:
return new ctor;
case numbertag:
case stringtag:
return new ctor(object);
case regexptag:
return cloneregexp(object);
case settag:
return new ctor;
case symboltag:
return clonesymbol(object);
}
}
/**
* inserts wrapper `details` in a comment at the top of the `source` body.
*
* @private
* @param {string} source the source to modify.
* @returns {array} details the details to insert.
* @returns {string} returns the modified source.
*/
function insertwrapdetails(source, details) {
var length = details.length;
if (!length) {
return source;
}
var lastindex = length - 1;
details[lastindex] = (length > 1 ? '& ' : '') + details[lastindex];
details = details.join(length > 2 ? ', ' : ' ');
return source.replace(rewrapcomment, '{\n/* [wrapped with ' + details + '] */\n');
}
/**
* checks if `value` is a flattenable `arguments` object or array.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is flattenable, else `false`.
*/
function isflattenable(value) {
return isarray(value) || isarguments(value) ||
!!(spreadablesymbol && value && value[spreadablesymbol]);
}
/**
* checks if `value` is a valid array-like index.
*
* @private
* @param {*} value the value to check.
* @param {number} [length=max_safe_integer] the upper bounds of a valid index.
* @returns {boolean} returns `true` if `value` is a valid index, else `false`.
*/
function isindex(value, length) {
var type = typeof value;
length = length == null ? max_safe_integer : length;
return !!length &&
(type == 'number' ||
(type != 'symbol' && reisuint.test(value))) &&
(value > -1 && value % 1 == 0 && value < length);
}
/**
* checks if the given arguments are from an iteratee call.
*
* @private
* @param {*} value the potential iteratee value argument.
* @param {*} index the potential iteratee index or key argument.
* @param {*} object the potential iteratee object argument.
* @returns {boolean} returns `true` if the arguments are from an iteratee call,
* else `false`.
*/
function isiterateecall(value, index, object) {
if (!isobject(object)) {
return false;
}
var type = typeof index;
if (type == 'number'
? (isarraylike(object) && isindex(index, object.length))
: (type == 'string' && index in object)
) {
return eq(object[index], value);
}
return false;
}
/**
* checks if `value` is a property name and not a property path.
*
* @private
* @param {*} value the value to check.
* @param {object} [object] the object to query keys on.
* @returns {boolean} returns `true` if `value` is a property name, else `false`.
*/
function iskey(value, object) {
if (isarray(value)) {
return false;
}
var type = typeof value;
if (type == 'number' || type == 'symbol' || type == 'boolean' ||
value == null || issymbol(value)) {
return true;
}
return reisplainprop.test(value) || !reisdeepprop.test(value) ||
(object != null && value in object(object));
}
/**
* checks if `value` is suitable for use as unique object key.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is suitable, else `false`.
*/
function iskeyable(value) {
var type = typeof value;
return (type == 'string' || type == 'number' || type == 'symbol' || type == 'boolean')
? (value !== '__proto__')
: (value === null);
}
/**
* checks if `func` has a lazy counterpart.
*
* @private
* @param {function} func the function to check.
* @returns {boolean} returns `true` if `func` has a lazy counterpart,
* else `false`.
*/
function islaziable(func) {
var funcname = getfuncname(func),
other = lodash[funcname];
if (typeof other != 'function' || !(funcname in lazywrapper.prototype)) {
return false;
}
if (func === other) {
return true;
}
var data = getdata(other);
return !!data && func === data[0];
}
/**
* checks if `func` has its source masked.
*
* @private
* @param {function} func the function to check.
* @returns {boolean} returns `true` if `func` is masked, else `false`.
*/
function ismasked(func) {
return !!masksrckey && (masksrckey in func);
}
/**
* checks if `func` is capable of being masked.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `func` is maskable, else `false`.
*/
var ismaskable = corejsdata ? isfunction : stubfalse;
/**
* checks if `value` is likely a prototype object.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` is a prototype, else `false`.
*/
function isprototype(value) {
var ctor = value && value.constructor,
proto = (typeof ctor == 'function' && ctor.prototype) || objectproto;
return value === proto;
}
/**
* checks if `value` is suitable for strict equality comparisons, i.e. `===`.
*
* @private
* @param {*} value the value to check.
* @returns {boolean} returns `true` if `value` if suitable for strict
* equality comparisons, else `false`.
*/
function isstrictcomparable(value) {
return value === value && !isobject(value);
}
/**
* a specialized version of `matchesproperty` for source values suitable
* for strict equality comparisons, i.e. `===`.
*
* @private
* @param {string} key the key of the property to get.
* @param {*} srcvalue the value to match.
* @returns {function} returns the new spec function.
*/
function matchesstrictcomparable(key, srcvalue) {
return function(object) {
if (object == null) {
return false;
}
return object[key] === srcvalue &&
(srcvalue !== undefined || (key in object(object)));
};
}
/**
* a specialized version of `_.memoize` which clears the memoized function's
* cache when it exceeds `max_memoize_size`.
*
* @private
* @param {function} func the function to have its output memoized.
* @returns {function} returns the new memoized function.
*/
function memoizecapped(func) {
var result = memoize(func, function(key) {
if (cache.size === max_memoize_size) {
cache.clear();
}
return key;
});
var cache = result.cache;
return result;
}
/**
* merges the function metadata of `source` into `data`.
*
* merging metadata reduces the number of wrappers used to invoke a function.
* this is possible because methods like `_.bind`, `_.curry`, and `_.partial`
* may be applied regardless of execution order. methods like `_.ary` and
* `_.rearg` modify function arguments, making the order in which they are
* executed important, preventing the merging of metadata. however, we make
* an exception for a safe combined case where curried functions have `_.ary`
* and or `_.rearg` applied.
*
* @private
* @param {array} data the destination metadata.
* @param {array} source the source metadata.
* @returns {array} returns `data`.
*/
function mergedata(data, source) {
var bitmask = data[1],
srcbitmask = source[1],
newbitmask = bitmask | srcbitmask,
iscommon = newbitmask < (wrap_bind_flag | wrap_bind_key_flag | wrap_ary_flag);
var iscombo =
((srcbitmask == wrap_ary_flag) && (bitmask == wrap_curry_flag)) ||
((srcbitmask == wrap_ary_flag) && (bitmask == wrap_rearg_flag) && (data[7].length <= source[8])) ||
((srcbitmask == (wrap_ary_flag | wrap_rearg_flag)) && (source[7].length <= source[8]) && (bitmask == wrap_curry_flag));
// exit early if metadata can't be merged.
if (!(iscommon || iscombo)) {
return data;
}
// use source `thisarg` if available.
if (srcbitmask & wrap_bind_flag) {
data[2] = source[2];
// set when currying a bound function.
newbitmask |= bitmask & wrap_bind_flag ? 0 : wrap_curry_bound_flag;
}
// compose partial arguments.
var value = source[3];
if (value) {
var partials = data[3];
data[3] = partials ? composeargs(partials, value, source[4]) : value;
data[4] = partials ? replaceholders(data[3], placeholder) : source[4];
}
// compose partial right arguments.
value = source[5];
if (value) {
partials = data[5];
data[5] = partials ? composeargsright(partials, value, source[6]) : value;
data[6] = partials ? replaceholders(data[5], placeholder) : source[6];
}
// use source `argpos` if available.
value = source[7];
if (value) {
data[7] = value;
}
// use source `ary` if it's smaller.
if (srcbitmask & wrap_ary_flag) {
data[8] = data[8] == null ? source[8] : nativemin(data[8], source[8]);
}
// use source `arity` if one is not provided.
if (data[9] == null) {
data[9] = source[9];
}
// use source `func` and merge bitmasks.
data[0] = source[0];
data[1] = newbitmask;
return data;
}
/**
* this function is like
* [`object.keys`](http://ecma-international.org/ecma-262/7.0/#sec-object.keys)
* except that it includes inherited enumerable properties.
*
* @private
* @param {object} object the object to query.
* @returns {array} returns the array of property names.
*/
function nativekeysin(object) {
var result = [];
if (object != null) {
for (var key in object(object)) {
result.push(key);
}
}
return result;
}
/**
* converts `value` to a string using `object.prototype.tostring`.
*
* @private
* @param {*} value the value to convert.
* @returns {string} returns the converted string.
*/
function objecttostring(value) {
return nativeobjecttostring.call(value);
}
/**
* a specialized version of `baserest` which transforms the rest array.
*
* @private
* @param {function} func the function to apply a rest parameter to.
* @param {number} [start=func.length-1] the start position of the rest parameter.
* @param {function} transform the rest array transform.
* @returns {function} returns the new function.
*/
function overrest(func, start, transform) {
start = nativemax(start === undefined ? (func.length - 1) : start, 0);
return function() {
var args = arguments,
index = -1,
length = nativemax(args.length - start, 0),
array = array(length);
while (++index < length) {
array[index] = args[start + index];
}
index = -1;
var otherargs = array(start + 1);
while (++index < start) {
otherargs[index] = args[index];
}
otherargs[start] = transform(array);
return apply(func, this, otherargs);
};
}
/**
* gets the parent value at `path` of `object`.
*
* @private
* @param {object} object the object to query.
* @param {array} path the path to get the parent value of.
* @returns {*} returns the parent value.
*/
function parent(object, path) {
return path.length < 2 ? object : baseget(object, baseslice(path, 0, -1));
}
/**
* reorder `array` according to the specified indexes where the element at
* the first index is assigned as the first element, the element at
* the second index is assigned as the second element, and so on.
*
* @private
* @param {array} array the array to reorder.
* @param {array} indexes the arranged array indexes.
* @returns {array} returns `array`.
*/
function reorder(array, indexes) {
var arrlength = array.length,
length = nativemin(indexes.length, arrlength),
oldarray = copyarray(array);
while (length--) {
var index = indexes[length];
array[length] = isindex(index, arrlength) ? oldarray[index] : undefined;
}
return array;
}
/**
* sets metadata for `func`.
*
* **note:** if this function becomes hot, i.e. is invoked a lot in a short
* period of time, it will trip its breaker and transition to an identity
* function to avoid garbage collection pauses in v8. see
* [v8 issue 2070](https://bugs.chromium.org/p/v8/issues/detail?id=2070)
* for more details.
*
* @private
* @param {function} func the function to associate metadata with.
* @param {*} data the metadata.
* @returns {function} returns `func`.
*/
var setdata = shortout(basesetdata);
/**
* a simple wrapper around the global [`settimeout`](https://mdn.io/settimeout).
*
* @private
* @param {function} func the function to delay.
* @param {number} wait the number of milliseconds to delay invocation.
* @returns {number|object} returns the timer id or timeout object.
*/
var settimeout = ctxsettimeout || function(func, wait) {
return root.settimeout(func, wait);
};
/**
* sets the `tostring` method of `func` to return `string`.
*
* @private
* @param {function} func the function to modify.
* @param {function} string the `tostring` result.
* @returns {function} returns `func`.
*/
var settostring = shortout(basesettostring);
/**
* sets the `tostring` method of `wrapper` to mimic the source of `reference`
* with wrapper details in a comment at the top of the source body.
*
* @private
* @param {function} wrapper the function to modify.
* @param {function} reference the reference function.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @returns {function} returns `wrapper`.
*/
function setwraptostring(wrapper, reference, bitmask) {
var source = (reference + '');
return settostring(wrapper, insertwrapdetails(source, updatewrapdetails(getwrapdetails(source), bitmask)));
}
/**
* creates a function that'll short out and invoke `identity` instead
* of `func` when it's called `hot_count` or more times in `hot_span`
* milliseconds.
*
* @private
* @param {function} func the function to restrict.
* @returns {function} returns the new shortable function.
*/
function shortout(func) {
var count = 0,
lastcalled = 0;
return function() {
var stamp = nativenow(),
remaining = hot_span - (stamp - lastcalled);
lastcalled = stamp;
if (remaining > 0) {
if (++count >= hot_count) {
return arguments[0];
}
} else {
count = 0;
}
return func.apply(undefined, arguments);
};
}
/**
* a specialized version of `_.shuffle` which mutates and sets the size of `array`.
*
* @private
* @param {array} array the array to shuffle.
* @param {number} [size=array.length] the size of `array`.
* @returns {array} returns `array`.
*/
function shuffleself(array, size) {
var index = -1,
length = array.length,
lastindex = length - 1;
size = size === undefined ? length : size;
while (++index < size) {
var rand = baserandom(index, lastindex),
value = array[rand];
array[rand] = array[index];
array[index] = value;
}
array.length = size;
return array;
}
/**
* converts `string` to a property path array.
*
* @private
* @param {string} string the string to convert.
* @returns {array} returns the property path array.
*/
var stringtopath = memoizecapped(function(string) {
var result = [];
if (string.charcodeat(0) === 46 /* . */) {
result.push('');
}
string.replace(repropname, function(match, number, quote, substring) {
result.push(quote ? substring.replace(reescapechar, '$1') : (number || match));
});
return result;
});
/**
* converts `value` to a string key if it's not a string or symbol.
*
* @private
* @param {*} value the value to inspect.
* @returns {string|symbol} returns the key.
*/
function tokey(value) {
if (typeof value == 'string' || issymbol(value)) {
return value;
}
var result = (value + '');
return (result == '0' && (1 / value) == -infinity) ? '-0' : result;
}
/**
* converts `func` to its source code.
*
* @private
* @param {function} func the function to convert.
* @returns {string} returns the source code.
*/
function tosource(func) {
if (func != null) {
try {
return functostring.call(func);
} catch (e) {}
try {
return (func + '');
} catch (e) {}
}
return '';
}
/**
* updates wrapper `details` based on `bitmask` flags.
*
* @private
* @returns {array} details the details to modify.
* @param {number} bitmask the bitmask flags. see `createwrap` for more details.
* @returns {array} returns `details`.
*/
function updatewrapdetails(details, bitmask) {
arrayeach(wrapflags, function(pair) {
var value = '_.' + pair[0];
if ((bitmask & pair[1]) && !arrayincludes(details, value)) {
details.push(value);
}
});
return details.sort();
}
/**
* creates a clone of `wrapper`.
*
* @private
* @param {object} wrapper the wrapper to clone.
* @returns {object} returns the cloned wrapper.
*/
function wrapperclone(wrapper) {
if (wrapper instanceof lazywrapper) {
return wrapper.clone();
}
var result = new lodashwrapper(wrapper.__wrapped__, wrapper.__chain__);
result.__actions__ = copyarray(wrapper.__actions__);
result.__index__ = wrapper.__index__;
result.__values__ = wrapper.__values__;
return result;
}
/*------------------------------------------------------------------------*/
/**
* creates an array of elements split into groups the length of `size`.
* if `array` can't be split evenly, the final chunk will be the remaining
* elements.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to process.
* @param {number} [size=1] the length of each chunk
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {array} returns the new array of chunks.
* @example
*
* _.chunk(['a', 'b', 'c', 'd'], 2);
* // => [['a', 'b'], ['c', 'd']]
*
* _.chunk(['a', 'b', 'c', 'd'], 3);
* // => [['a', 'b', 'c'], ['d']]
*/
function chunk(array, size, guard) {
if ((guard ? isiterateecall(array, size, guard) : size === undefined)) {
size = 1;
} else {
size = nativemax(tointeger(size), 0);
}
var length = array == null ? 0 : array.length;
if (!length || size < 1) {
return [];
}
var index = 0,
resindex = 0,
result = array(nativeceil(length / size));
while (index < length) {
result[resindex++] = baseslice(array, index, (index += size));
}
return result;
}
/**
* creates an array with all falsey values removed. the values `false`, `null`,
* `0`, `""`, `undefined`, and `nan` are falsey.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to compact.
* @returns {array} returns the new array of filtered values.
* @example
*
* _.compact([0, 1, false, 2, '', 3]);
* // => [1, 2, 3]
*/
function compact(array) {
var index = -1,
length = array == null ? 0 : array.length,
resindex = 0,
result = [];
while (++index < length) {
var value = array[index];
if (value) {
result[resindex++] = value;
}
}
return result;
}
/**
* creates a new array concatenating `array` with any additional arrays
* and/or values.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to concatenate.
* @param {...*} [values] the values to concatenate.
* @returns {array} returns the new concatenated array.
* @example
*
* var array = [1];
* var other = _.concat(array, 2, [3], [[4]]);
*
* console.log(other);
* // => [1, 2, 3, [4]]
*
* console.log(array);
* // => [1]
*/
function concat() {
var length = arguments.length;
if (!length) {
return [];
}
var args = array(length - 1),
array = arguments[0],
index = length;
while (index--) {
args[index - 1] = arguments[index];
}
return arraypush(isarray(array) ? copyarray(array) : [array], baseflatten(args, 1));
}
/**
* creates an array of `array` values not included in the other given arrays
* using [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. the order and references of result values are
* determined by the first array.
*
* **note:** unlike `_.pullall`, this method returns a new array.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to inspect.
* @param {...array} [values] the values to exclude.
* @returns {array} returns the new array of filtered values.
* @see _.without, _.xor
* @example
*
* _.difference([2, 1], [2, 3]);
* // => [1]
*/
var difference = baserest(function(array, values) {
return isarraylikeobject(array)
? basedifference(array, baseflatten(values, 1, isarraylikeobject, true))
: [];
});
/**
* this method is like `_.difference` except that it accepts `iteratee` which
* is invoked for each element of `array` and `values` to generate the criterion
* by which they're compared. the order and references of result values are
* determined by the first array. the iteratee is invoked with one argument:
* (value).
*
* **note:** unlike `_.pullallby`, this method returns a new array.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {...array} [values] the values to exclude.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {array} returns the new array of filtered values.
* @example
*
* _.differenceby([2.1, 1.2], [2.3, 3.4], math.floor);
* // => [1.2]
*
* // the `_.property` iteratee shorthand.
* _.differenceby([{ 'x': 2 }, { 'x': 1 }], [{ 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
var differenceby = baserest(function(array, values) {
var iteratee = last(values);
if (isarraylikeobject(iteratee)) {
iteratee = undefined;
}
return isarraylikeobject(array)
? basedifference(array, baseflatten(values, 1, isarraylikeobject, true), getiteratee(iteratee, 2))
: [];
});
/**
* this method is like `_.difference` except that it accepts `comparator`
* which is invoked to compare elements of `array` to `values`. the order and
* references of result values are determined by the first array. the comparator
* is invoked with two arguments: (arrval, othval).
*
* **note:** unlike `_.pullallwith`, this method returns a new array.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {...array} [values] the values to exclude.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of filtered values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
*
* _.differencewith(objects, [{ 'x': 1, 'y': 2 }], _.isequal);
* // => [{ 'x': 2, 'y': 1 }]
*/
var differencewith = baserest(function(array, values) {
var comparator = last(values);
if (isarraylikeobject(comparator)) {
comparator = undefined;
}
return isarraylikeobject(array)
? basedifference(array, baseflatten(values, 1, isarraylikeobject, true), undefined, comparator)
: [];
});
/**
* creates a slice of `array` with `n` elements dropped from the beginning.
*
* @static
* @memberof _
* @since 0.5.0
* @category array
* @param {array} array the array to query.
* @param {number} [n=1] the number of elements to drop.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {array} returns the slice of `array`.
* @example
*
* _.drop([1, 2, 3]);
* // => [2, 3]
*
* _.drop([1, 2, 3], 2);
* // => [3]
*
* _.drop([1, 2, 3], 5);
* // => []
*
* _.drop([1, 2, 3], 0);
* // => [1, 2, 3]
*/
function drop(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : tointeger(n);
return baseslice(array, n < 0 ? 0 : n, length);
}
/**
* creates a slice of `array` with `n` elements dropped from the end.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to query.
* @param {number} [n=1] the number of elements to drop.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {array} returns the slice of `array`.
* @example
*
* _.dropright([1, 2, 3]);
* // => [1, 2]
*
* _.dropright([1, 2, 3], 2);
* // => [1]
*
* _.dropright([1, 2, 3], 5);
* // => []
*
* _.dropright([1, 2, 3], 0);
* // => [1, 2, 3]
*/
function dropright(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : tointeger(n);
n = length - n;
return baseslice(array, 0, n < 0 ? 0 : n);
}
/**
* creates a slice of `array` excluding elements dropped from the end.
* elements are dropped until `predicate` returns falsey. the predicate is
* invoked with three arguments: (value, index, array).
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to query.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.droprightwhile(users, function(o) { return !o.active; });
* // => objects for ['barney']
*
* // the `_.matches` iteratee shorthand.
* _.droprightwhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['barney', 'fred']
*
* // the `_.matchesproperty` iteratee shorthand.
* _.droprightwhile(users, ['active', false]);
* // => objects for ['barney']
*
* // the `_.property` iteratee shorthand.
* _.droprightwhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
function droprightwhile(array, predicate) {
return (array && array.length)
? basewhile(array, getiteratee(predicate, 3), true, true)
: [];
}
/**
* creates a slice of `array` excluding elements dropped from the beginning.
* elements are dropped until `predicate` returns falsey. the predicate is
* invoked with three arguments: (value, index, array).
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to query.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.dropwhile(users, function(o) { return !o.active; });
* // => objects for ['pebbles']
*
* // the `_.matches` iteratee shorthand.
* _.dropwhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['fred', 'pebbles']
*
* // the `_.matchesproperty` iteratee shorthand.
* _.dropwhile(users, ['active', false]);
* // => objects for ['pebbles']
*
* // the `_.property` iteratee shorthand.
* _.dropwhile(users, 'active');
* // => objects for ['barney', 'fred', 'pebbles']
*/
function dropwhile(array, predicate) {
return (array && array.length)
? basewhile(array, getiteratee(predicate, 3), true)
: [];
}
/**
* fills elements of `array` with `value` from `start` up to, but not
* including, `end`.
*
* **note:** this method mutates `array`.
*
* @static
* @memberof _
* @since 3.2.0
* @category array
* @param {array} array the array to fill.
* @param {*} value the value to fill `array` with.
* @param {number} [start=0] the start position.
* @param {number} [end=array.length] the end position.
* @returns {array} returns `array`.
* @example
*
* var array = [1, 2, 3];
*
* _.fill(array, 'a');
* console.log(array);
* // => ['a', 'a', 'a']
*
* _.fill(array(3), 2);
* // => [2, 2, 2]
*
* _.fill([4, 6, 8, 10], '*', 1, 3);
* // => [4, '*', '*', 10]
*/
function fill(array, value, start, end) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
if (start && typeof start != 'number' && isiterateecall(array, value, start)) {
start = 0;
end = length;
}
return basefill(array, value, start, end);
}
/**
* this method is like `_.find` except that it returns the index of the first
* element `predicate` returns truthy for instead of the element itself.
*
* @static
* @memberof _
* @since 1.1.0
* @category array
* @param {array} array the array to inspect.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @param {number} [fromindex=0] the index to search from.
* @returns {number} returns the index of the found element, else `-1`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.findindex(users, function(o) { return o.user == 'barney'; });
* // => 0
*
* // the `_.matches` iteratee shorthand.
* _.findindex(users, { 'user': 'fred', 'active': false });
* // => 1
*
* // the `_.matchesproperty` iteratee shorthand.
* _.findindex(users, ['active', false]);
* // => 0
*
* // the `_.property` iteratee shorthand.
* _.findindex(users, 'active');
* // => 2
*/
function findindex(array, predicate, fromindex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = fromindex == null ? 0 : tointeger(fromindex);
if (index < 0) {
index = nativemax(length + index, 0);
}
return basefindindex(array, getiteratee(predicate, 3), index);
}
/**
* this method is like `_.findindex` except that it iterates over elements
* of `collection` from right to left.
*
* @static
* @memberof _
* @since 2.0.0
* @category array
* @param {array} array the array to inspect.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @param {number} [fromindex=array.length-1] the index to search from.
* @returns {number} returns the index of the found element, else `-1`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.findlastindex(users, function(o) { return o.user == 'pebbles'; });
* // => 2
*
* // the `_.matches` iteratee shorthand.
* _.findlastindex(users, { 'user': 'barney', 'active': true });
* // => 0
*
* // the `_.matchesproperty` iteratee shorthand.
* _.findlastindex(users, ['active', false]);
* // => 2
*
* // the `_.property` iteratee shorthand.
* _.findlastindex(users, 'active');
* // => 0
*/
function findlastindex(array, predicate, fromindex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = length - 1;
if (fromindex !== undefined) {
index = tointeger(fromindex);
index = fromindex < 0
? nativemax(length + index, 0)
: nativemin(index, length - 1);
}
return basefindindex(array, getiteratee(predicate, 3), index, true);
}
/**
* flattens `array` a single level deep.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to flatten.
* @returns {array} returns the new flattened array.
* @example
*
* _.flatten([1, [2, [3, [4]], 5]]);
* // => [1, 2, [3, [4]], 5]
*/
function flatten(array) {
var length = array == null ? 0 : array.length;
return length ? baseflatten(array, 1) : [];
}
/**
* recursively flattens `array`.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to flatten.
* @returns {array} returns the new flattened array.
* @example
*
* _.flattendeep([1, [2, [3, [4]], 5]]);
* // => [1, 2, 3, 4, 5]
*/
function flattendeep(array) {
var length = array == null ? 0 : array.length;
return length ? baseflatten(array, infinity) : [];
}
/**
* recursively flatten `array` up to `depth` times.
*
* @static
* @memberof _
* @since 4.4.0
* @category array
* @param {array} array the array to flatten.
* @param {number} [depth=1] the maximum recursion depth.
* @returns {array} returns the new flattened array.
* @example
*
* var array = [1, [2, [3, [4]], 5]];
*
* _.flattendepth(array, 1);
* // => [1, 2, [3, [4]], 5]
*
* _.flattendepth(array, 2);
* // => [1, 2, 3, [4], 5]
*/
function flattendepth(array, depth) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
depth = depth === undefined ? 1 : tointeger(depth);
return baseflatten(array, depth);
}
/**
* the inverse of `_.topairs`; this method returns an object composed
* from key-value `pairs`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} pairs the key-value pairs.
* @returns {object} returns the new object.
* @example
*
* _.frompairs([['a', 1], ['b', 2]]);
* // => { 'a': 1, 'b': 2 }
*/
function frompairs(pairs) {
var index = -1,
length = pairs == null ? 0 : pairs.length,
result = {};
while (++index < length) {
var pair = pairs[index];
result[pair[0]] = pair[1];
}
return result;
}
/**
* gets the first element of `array`.
*
* @static
* @memberof _
* @since 0.1.0
* @alias first
* @category array
* @param {array} array the array to query.
* @returns {*} returns the first element of `array`.
* @example
*
* _.head([1, 2, 3]);
* // => 1
*
* _.head([]);
* // => undefined
*/
function head(array) {
return (array && array.length) ? array[0] : undefined;
}
/**
* gets the index at which the first occurrence of `value` is found in `array`
* using [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. if `fromindex` is negative, it's used as the
* offset from the end of `array`.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @param {number} [fromindex=0] the index to search from.
* @returns {number} returns the index of the matched value, else `-1`.
* @example
*
* _.indexof([1, 2, 1, 2], 2);
* // => 1
*
* // search from the `fromindex`.
* _.indexof([1, 2, 1, 2], 2, 2);
* // => 3
*/
function indexof(array, value, fromindex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = fromindex == null ? 0 : tointeger(fromindex);
if (index < 0) {
index = nativemax(length + index, 0);
}
return baseindexof(array, value, index);
}
/**
* gets all but the last element of `array`.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to query.
* @returns {array} returns the slice of `array`.
* @example
*
* _.initial([1, 2, 3]);
* // => [1, 2]
*/
function initial(array) {
var length = array == null ? 0 : array.length;
return length ? baseslice(array, 0, -1) : [];
}
/**
* creates an array of unique values that are included in all given arrays
* using [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons. the order and references of result values are
* determined by the first array.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @returns {array} returns the new array of intersecting values.
* @example
*
* _.intersection([2, 1], [2, 3]);
* // => [2]
*/
var intersection = baserest(function(arrays) {
var mapped = arraymap(arrays, castarraylikeobject);
return (mapped.length && mapped[0] === arrays[0])
? baseintersection(mapped)
: [];
});
/**
* this method is like `_.intersection` except that it accepts `iteratee`
* which is invoked for each element of each `arrays` to generate the criterion
* by which they're compared. the order and references of result values are
* determined by the first array. the iteratee is invoked with one argument:
* (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {array} returns the new array of intersecting values.
* @example
*
* _.intersectionby([2.1, 1.2], [2.3, 3.4], math.floor);
* // => [2.1]
*
* // the `_.property` iteratee shorthand.
* _.intersectionby([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }]
*/
var intersectionby = baserest(function(arrays) {
var iteratee = last(arrays),
mapped = arraymap(arrays, castarraylikeobject);
if (iteratee === last(mapped)) {
iteratee = undefined;
} else {
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])
? baseintersection(mapped, getiteratee(iteratee, 2))
: [];
});
/**
* this method is like `_.intersection` except that it accepts `comparator`
* which is invoked to compare elements of `arrays`. the order and references
* of result values are determined by the first array. the comparator is
* invoked with two arguments: (arrval, othval).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of intersecting values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.intersectionwith(objects, others, _.isequal);
* // => [{ 'x': 1, 'y': 2 }]
*/
var intersectionwith = baserest(function(arrays) {
var comparator = last(arrays),
mapped = arraymap(arrays, castarraylikeobject);
comparator = typeof comparator == 'function' ? comparator : undefined;
if (comparator) {
mapped.pop();
}
return (mapped.length && mapped[0] === arrays[0])
? baseintersection(mapped, undefined, comparator)
: [];
});
/**
* converts all elements in `array` into a string separated by `separator`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to convert.
* @param {string} [separator=','] the element separator.
* @returns {string} returns the joined string.
* @example
*
* _.join(['a', 'b', 'c'], '~');
* // => 'a~b~c'
*/
function join(array, separator) {
return array == null ? '' : nativejoin.call(array, separator);
}
/**
* gets the last element of `array`.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to query.
* @returns {*} returns the last element of `array`.
* @example
*
* _.last([1, 2, 3]);
* // => 3
*/
function last(array) {
var length = array == null ? 0 : array.length;
return length ? array[length - 1] : undefined;
}
/**
* this method is like `_.indexof` except that it iterates over elements of
* `array` from right to left.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @param {number} [fromindex=array.length-1] the index to search from.
* @returns {number} returns the index of the matched value, else `-1`.
* @example
*
* _.lastindexof([1, 2, 1, 2], 2);
* // => 3
*
* // search from the `fromindex`.
* _.lastindexof([1, 2, 1, 2], 2, 2);
* // => 1
*/
function lastindexof(array, value, fromindex) {
var length = array == null ? 0 : array.length;
if (!length) {
return -1;
}
var index = length;
if (fromindex !== undefined) {
index = tointeger(fromindex);
index = index < 0 ? nativemax(length + index, 0) : nativemin(index, length - 1);
}
return value === value
? strictlastindexof(array, value, index)
: basefindindex(array, baseisnan, index, true);
}
/**
* gets the element at index `n` of `array`. if `n` is negative, the nth
* element from the end is returned.
*
* @static
* @memberof _
* @since 4.11.0
* @category array
* @param {array} array the array to query.
* @param {number} [n=0] the index of the element to return.
* @returns {*} returns the nth element of `array`.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
*
* _.nth(array, 1);
* // => 'b'
*
* _.nth(array, -2);
* // => 'c';
*/
function nth(array, n) {
return (array && array.length) ? basenth(array, tointeger(n)) : undefined;
}
/**
* removes all given values from `array` using
* [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* **note:** unlike `_.without`, this method mutates `array`. use `_.remove`
* to remove elements from an array by predicate.
*
* @static
* @memberof _
* @since 2.0.0
* @category array
* @param {array} array the array to modify.
* @param {...*} [values] the values to remove.
* @returns {array} returns `array`.
* @example
*
* var array = ['a', 'b', 'c', 'a', 'b', 'c'];
*
* _.pull(array, 'a', 'c');
* console.log(array);
* // => ['b', 'b']
*/
var pull = baserest(pullall);
/**
* this method is like `_.pull` except that it accepts an array of values to remove.
*
* **note:** unlike `_.difference`, this method mutates `array`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to modify.
* @param {array} values the values to remove.
* @returns {array} returns `array`.
* @example
*
* var array = ['a', 'b', 'c', 'a', 'b', 'c'];
*
* _.pullall(array, ['a', 'c']);
* console.log(array);
* // => ['b', 'b']
*/
function pullall(array, values) {
return (array && array.length && values && values.length)
? basepullall(array, values)
: array;
}
/**
* this method is like `_.pullall` except that it accepts `iteratee` which is
* invoked for each element of `array` and `values` to generate the criterion
* by which they're compared. the iteratee is invoked with one argument: (value).
*
* **note:** unlike `_.differenceby`, this method mutates `array`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to modify.
* @param {array} values the values to remove.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {array} returns `array`.
* @example
*
* var array = [{ 'x': 1 }, { 'x': 2 }, { 'x': 3 }, { 'x': 1 }];
*
* _.pullallby(array, [{ 'x': 1 }, { 'x': 3 }], 'x');
* console.log(array);
* // => [{ 'x': 2 }]
*/
function pullallby(array, values, iteratee) {
return (array && array.length && values && values.length)
? basepullall(array, values, getiteratee(iteratee, 2))
: array;
}
/**
* this method is like `_.pullall` except that it accepts `comparator` which
* is invoked to compare elements of `array` to `values`. the comparator is
* invoked with two arguments: (arrval, othval).
*
* **note:** unlike `_.differencewith`, this method mutates `array`.
*
* @static
* @memberof _
* @since 4.6.0
* @category array
* @param {array} array the array to modify.
* @param {array} values the values to remove.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns `array`.
* @example
*
* var array = [{ 'x': 1, 'y': 2 }, { 'x': 3, 'y': 4 }, { 'x': 5, 'y': 6 }];
*
* _.pullallwith(array, [{ 'x': 3, 'y': 4 }], _.isequal);
* console.log(array);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 5, 'y': 6 }]
*/
function pullallwith(array, values, comparator) {
return (array && array.length && values && values.length)
? basepullall(array, values, undefined, comparator)
: array;
}
/**
* removes elements from `array` corresponding to `indexes` and returns an
* array of removed elements.
*
* **note:** unlike `_.at`, this method mutates `array`.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to modify.
* @param {...(number|number[])} [indexes] the indexes of elements to remove.
* @returns {array} returns the new array of removed elements.
* @example
*
* var array = ['a', 'b', 'c', 'd'];
* var pulled = _.pullat(array, [1, 3]);
*
* console.log(array);
* // => ['a', 'c']
*
* console.log(pulled);
* // => ['b', 'd']
*/
var pullat = flatrest(function(array, indexes) {
var length = array == null ? 0 : array.length,
result = baseat(array, indexes);
basepullat(array, arraymap(indexes, function(index) {
return isindex(index, length) ? +index : index;
}).sort(compareascending));
return result;
});
/**
* removes all elements from `array` that `predicate` returns truthy for
* and returns an array of the removed elements. the predicate is invoked
* with three arguments: (value, index, array).
*
* **note:** unlike `_.filter`, this method mutates `array`. use `_.pull`
* to pull elements from an array by value.
*
* @static
* @memberof _
* @since 2.0.0
* @category array
* @param {array} array the array to modify.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the new array of removed elements.
* @example
*
* var array = [1, 2, 3, 4];
* var evens = _.remove(array, function(n) {
* return n % 2 == 0;
* });
*
* console.log(array);
* // => [1, 3]
*
* console.log(evens);
* // => [2, 4]
*/
function remove(array, predicate) {
var result = [];
if (!(array && array.length)) {
return result;
}
var index = -1,
indexes = [],
length = array.length;
predicate = getiteratee(predicate, 3);
while (++index < length) {
var value = array[index];
if (predicate(value, index, array)) {
result.push(value);
indexes.push(index);
}
}
basepullat(array, indexes);
return result;
}
/**
* reverses `array` so that the first element becomes the last, the second
* element becomes the second to last, and so on.
*
* **note:** this method mutates `array` and is based on
* [`array#reverse`](https://mdn.io/array/reverse).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to modify.
* @returns {array} returns `array`.
* @example
*
* var array = [1, 2, 3];
*
* _.reverse(array);
* // => [3, 2, 1]
*
* console.log(array);
* // => [3, 2, 1]
*/
function reverse(array) {
return array == null ? array : nativereverse.call(array);
}
/**
* creates a slice of `array` from `start` up to, but not including, `end`.
*
* **note:** this method is used instead of
* [`array#slice`](https://mdn.io/array/slice) to ensure dense arrays are
* returned.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to slice.
* @param {number} [start=0] the start position.
* @param {number} [end=array.length] the end position.
* @returns {array} returns the slice of `array`.
*/
function slice(array, start, end) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
if (end && typeof end != 'number' && isiterateecall(array, start, end)) {
start = 0;
end = length;
}
else {
start = start == null ? 0 : tointeger(start);
end = end === undefined ? length : tointeger(end);
}
return baseslice(array, start, end);
}
/**
* uses a binary search to determine the lowest index at which `value`
* should be inserted into `array` in order to maintain its sort order.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the sorted array to inspect.
* @param {*} value the value to evaluate.
* @returns {number} returns the index at which `value` should be inserted
* into `array`.
* @example
*
* _.sortedindex([30, 50], 40);
* // => 1
*/
function sortedindex(array, value) {
return basesortedindex(array, value);
}
/**
* this method is like `_.sortedindex` except that it accepts `iteratee`
* which is invoked for `value` and each element of `array` to compute their
* sort ranking. the iteratee is invoked with one argument: (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the sorted array to inspect.
* @param {*} value the value to evaluate.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {number} returns the index at which `value` should be inserted
* into `array`.
* @example
*
* var objects = [{ 'x': 4 }, { 'x': 5 }];
*
* _.sortedindexby(objects, { 'x': 4 }, function(o) { return o.x; });
* // => 0
*
* // the `_.property` iteratee shorthand.
* _.sortedindexby(objects, { 'x': 4 }, 'x');
* // => 0
*/
function sortedindexby(array, value, iteratee) {
return basesortedindexby(array, value, getiteratee(iteratee, 2));
}
/**
* this method is like `_.indexof` except that it performs a binary
* search on a sorted `array`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @returns {number} returns the index of the matched value, else `-1`.
* @example
*
* _.sortedindexof([4, 5, 5, 5, 6], 5);
* // => 1
*/
function sortedindexof(array, value) {
var length = array == null ? 0 : array.length;
if (length) {
var index = basesortedindex(array, value);
if (index < length && eq(array[index], value)) {
return index;
}
}
return -1;
}
/**
* this method is like `_.sortedindex` except that it returns the highest
* index at which `value` should be inserted into `array` in order to
* maintain its sort order.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the sorted array to inspect.
* @param {*} value the value to evaluate.
* @returns {number} returns the index at which `value` should be inserted
* into `array`.
* @example
*
* _.sortedlastindex([4, 5, 5, 5, 6], 5);
* // => 4
*/
function sortedlastindex(array, value) {
return basesortedindex(array, value, true);
}
/**
* this method is like `_.sortedlastindex` except that it accepts `iteratee`
* which is invoked for `value` and each element of `array` to compute their
* sort ranking. the iteratee is invoked with one argument: (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the sorted array to inspect.
* @param {*} value the value to evaluate.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {number} returns the index at which `value` should be inserted
* into `array`.
* @example
*
* var objects = [{ 'x': 4 }, { 'x': 5 }];
*
* _.sortedlastindexby(objects, { 'x': 4 }, function(o) { return o.x; });
* // => 1
*
* // the `_.property` iteratee shorthand.
* _.sortedlastindexby(objects, { 'x': 4 }, 'x');
* // => 1
*/
function sortedlastindexby(array, value, iteratee) {
return basesortedindexby(array, value, getiteratee(iteratee, 2), true);
}
/**
* this method is like `_.lastindexof` except that it performs a binary
* search on a sorted `array`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {*} value the value to search for.
* @returns {number} returns the index of the matched value, else `-1`.
* @example
*
* _.sortedlastindexof([4, 5, 5, 5, 6], 5);
* // => 3
*/
function sortedlastindexof(array, value) {
var length = array == null ? 0 : array.length;
if (length) {
var index = basesortedindex(array, value, true) - 1;
if (eq(array[index], value)) {
return index;
}
}
return -1;
}
/**
* this method is like `_.uniq` except that it's designed and optimized
* for sorted arrays.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @returns {array} returns the new duplicate free array.
* @example
*
* _.sorteduniq([1, 1, 2]);
* // => [1, 2]
*/
function sorteduniq(array) {
return (array && array.length)
? basesorteduniq(array)
: [];
}
/**
* this method is like `_.uniqby` except that it's designed and optimized
* for sorted arrays.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {function} [iteratee] the iteratee invoked per element.
* @returns {array} returns the new duplicate free array.
* @example
*
* _.sorteduniqby([1.1, 1.2, 2.3, 2.4], math.floor);
* // => [1.1, 2.3]
*/
function sorteduniqby(array, iteratee) {
return (array && array.length)
? basesorteduniq(array, getiteratee(iteratee, 2))
: [];
}
/**
* gets all but the first element of `array`.
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to query.
* @returns {array} returns the slice of `array`.
* @example
*
* _.tail([1, 2, 3]);
* // => [2, 3]
*/
function tail(array) {
var length = array == null ? 0 : array.length;
return length ? baseslice(array, 1, length) : [];
}
/**
* creates a slice of `array` with `n` elements taken from the beginning.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to query.
* @param {number} [n=1] the number of elements to take.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {array} returns the slice of `array`.
* @example
*
* _.take([1, 2, 3]);
* // => [1]
*
* _.take([1, 2, 3], 2);
* // => [1, 2]
*
* _.take([1, 2, 3], 5);
* // => [1, 2, 3]
*
* _.take([1, 2, 3], 0);
* // => []
*/
function take(array, n, guard) {
if (!(array && array.length)) {
return [];
}
n = (guard || n === undefined) ? 1 : tointeger(n);
return baseslice(array, 0, n < 0 ? 0 : n);
}
/**
* creates a slice of `array` with `n` elements taken from the end.
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to query.
* @param {number} [n=1] the number of elements to take.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {array} returns the slice of `array`.
* @example
*
* _.takeright([1, 2, 3]);
* // => [3]
*
* _.takeright([1, 2, 3], 2);
* // => [2, 3]
*
* _.takeright([1, 2, 3], 5);
* // => [1, 2, 3]
*
* _.takeright([1, 2, 3], 0);
* // => []
*/
function takeright(array, n, guard) {
var length = array == null ? 0 : array.length;
if (!length) {
return [];
}
n = (guard || n === undefined) ? 1 : tointeger(n);
n = length - n;
return baseslice(array, n < 0 ? 0 : n, length);
}
/**
* creates a slice of `array` with elements taken from the end. elements are
* taken until `predicate` returns falsey. the predicate is invoked with
* three arguments: (value, index, array).
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to query.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': false }
* ];
*
* _.takerightwhile(users, function(o) { return !o.active; });
* // => objects for ['fred', 'pebbles']
*
* // the `_.matches` iteratee shorthand.
* _.takerightwhile(users, { 'user': 'pebbles', 'active': false });
* // => objects for ['pebbles']
*
* // the `_.matchesproperty` iteratee shorthand.
* _.takerightwhile(users, ['active', false]);
* // => objects for ['fred', 'pebbles']
*
* // the `_.property` iteratee shorthand.
* _.takerightwhile(users, 'active');
* // => []
*/
function takerightwhile(array, predicate) {
return (array && array.length)
? basewhile(array, getiteratee(predicate, 3), false, true)
: [];
}
/**
* creates a slice of `array` with elements taken from the beginning. elements
* are taken until `predicate` returns falsey. the predicate is invoked with
* three arguments: (value, index, array).
*
* @static
* @memberof _
* @since 3.0.0
* @category array
* @param {array} array the array to query.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the slice of `array`.
* @example
*
* var users = [
* { 'user': 'barney', 'active': false },
* { 'user': 'fred', 'active': false },
* { 'user': 'pebbles', 'active': true }
* ];
*
* _.takewhile(users, function(o) { return !o.active; });
* // => objects for ['barney', 'fred']
*
* // the `_.matches` iteratee shorthand.
* _.takewhile(users, { 'user': 'barney', 'active': false });
* // => objects for ['barney']
*
* // the `_.matchesproperty` iteratee shorthand.
* _.takewhile(users, ['active', false]);
* // => objects for ['barney', 'fred']
*
* // the `_.property` iteratee shorthand.
* _.takewhile(users, 'active');
* // => []
*/
function takewhile(array, predicate) {
return (array && array.length)
? basewhile(array, getiteratee(predicate, 3))
: [];
}
/**
* creates an array of unique values, in order, from all given arrays using
* [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @returns {array} returns the new array of combined values.
* @example
*
* _.union([2], [1, 2]);
* // => [2, 1]
*/
var union = baserest(function(arrays) {
return baseuniq(baseflatten(arrays, 1, isarraylikeobject, true));
});
/**
* this method is like `_.union` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by
* which uniqueness is computed. result values are chosen from the first
* array in which the value occurs. the iteratee is invoked with one argument:
* (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {array} returns the new array of combined values.
* @example
*
* _.unionby([2.1], [1.2, 2.3], math.floor);
* // => [2.1, 1.2]
*
* // the `_.property` iteratee shorthand.
* _.unionby([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
var unionby = baserest(function(arrays) {
var iteratee = last(arrays);
if (isarraylikeobject(iteratee)) {
iteratee = undefined;
}
return baseuniq(baseflatten(arrays, 1, isarraylikeobject, true), getiteratee(iteratee, 2));
});
/**
* this method is like `_.union` except that it accepts `comparator` which
* is invoked to compare elements of `arrays`. result values are chosen from
* the first array in which the value occurs. the comparator is invoked
* with two arguments: (arrval, othval).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of combined values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.unionwith(objects, others, _.isequal);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
var unionwith = baserest(function(arrays) {
var comparator = last(arrays);
comparator = typeof comparator == 'function' ? comparator : undefined;
return baseuniq(baseflatten(arrays, 1, isarraylikeobject, true), undefined, comparator);
});
/**
* creates a duplicate-free version of an array, using
* [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons, in which only the first occurrence of each element
* is kept. the order of result values is determined by the order they occur
* in the array.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to inspect.
* @returns {array} returns the new duplicate free array.
* @example
*
* _.uniq([2, 1, 2]);
* // => [2, 1]
*/
function uniq(array) {
return (array && array.length) ? baseuniq(array) : [];
}
/**
* this method is like `_.uniq` except that it accepts `iteratee` which is
* invoked for each element in `array` to generate the criterion by which
* uniqueness is computed. the order of result values is determined by the
* order they occur in the array. the iteratee is invoked with one argument:
* (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {array} returns the new duplicate free array.
* @example
*
* _.uniqby([2.1, 1.2, 2.3], math.floor);
* // => [2.1, 1.2]
*
* // the `_.property` iteratee shorthand.
* _.uniqby([{ 'x': 1 }, { 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 1 }, { 'x': 2 }]
*/
function uniqby(array, iteratee) {
return (array && array.length) ? baseuniq(array, getiteratee(iteratee, 2)) : [];
}
/**
* this method is like `_.uniq` except that it accepts `comparator` which
* is invoked to compare elements of `array`. the order of result values is
* determined by the order they occur in the array.the comparator is invoked
* with two arguments: (arrval, othval).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {array} array the array to inspect.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new duplicate free array.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.uniqwith(objects, _.isequal);
* // => [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }]
*/
function uniqwith(array, comparator) {
comparator = typeof comparator == 'function' ? comparator : undefined;
return (array && array.length) ? baseuniq(array, undefined, comparator) : [];
}
/**
* this method is like `_.zip` except that it accepts an array of grouped
* elements and creates an array regrouping the elements to their pre-zip
* configuration.
*
* @static
* @memberof _
* @since 1.2.0
* @category array
* @param {array} array the array of grouped elements to process.
* @returns {array} returns the new array of regrouped elements.
* @example
*
* var zipped = _.zip(['a', 'b'], [1, 2], [true, false]);
* // => [['a', 1, true], ['b', 2, false]]
*
* _.unzip(zipped);
* // => [['a', 'b'], [1, 2], [true, false]]
*/
function unzip(array) {
if (!(array && array.length)) {
return [];
}
var length = 0;
array = arrayfilter(array, function(group) {
if (isarraylikeobject(group)) {
length = nativemax(group.length, length);
return true;
}
});
return basetimes(length, function(index) {
return arraymap(array, baseproperty(index));
});
}
/**
* this method is like `_.unzip` except that it accepts `iteratee` to specify
* how regrouped values should be combined. the iteratee is invoked with the
* elements of each group: (...group).
*
* @static
* @memberof _
* @since 3.8.0
* @category array
* @param {array} array the array of grouped elements to process.
* @param {function} [iteratee=_.identity] the function to combine
* regrouped values.
* @returns {array} returns the new array of regrouped elements.
* @example
*
* var zipped = _.zip([1, 2], [10, 20], [100, 200]);
* // => [[1, 10, 100], [2, 20, 200]]
*
* _.unzipwith(zipped, _.add);
* // => [3, 30, 300]
*/
function unzipwith(array, iteratee) {
if (!(array && array.length)) {
return [];
}
var result = unzip(array);
if (iteratee == null) {
return result;
}
return arraymap(result, function(group) {
return apply(iteratee, undefined, group);
});
}
/**
* creates an array excluding all given values using
* [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* for equality comparisons.
*
* **note:** unlike `_.pull`, this method returns a new array.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {array} array the array to inspect.
* @param {...*} [values] the values to exclude.
* @returns {array} returns the new array of filtered values.
* @see _.difference, _.xor
* @example
*
* _.without([2, 1, 2, 3], 1, 2);
* // => [3]
*/
var without = baserest(function(array, values) {
return isarraylikeobject(array)
? basedifference(array, values)
: [];
});
/**
* creates an array of unique values that is the
* [symmetric difference](https://en.wikipedia.org/wiki/symmetric_difference)
* of the given arrays. the order of result values is determined by the order
* they occur in the arrays.
*
* @static
* @memberof _
* @since 2.4.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @returns {array} returns the new array of filtered values.
* @see _.difference, _.without
* @example
*
* _.xor([2, 1], [2, 3]);
* // => [1, 3]
*/
var xor = baserest(function(arrays) {
return basexor(arrayfilter(arrays, isarraylikeobject));
});
/**
* this method is like `_.xor` except that it accepts `iteratee` which is
* invoked for each element of each `arrays` to generate the criterion by
* which by which they're compared. the order of result values is determined
* by the order they occur in the arrays. the iteratee is invoked with one
* argument: (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @param {function} [iteratee=_.identity] the iteratee invoked per element.
* @returns {array} returns the new array of filtered values.
* @example
*
* _.xorby([2.1, 1.2], [2.3, 3.4], math.floor);
* // => [1.2, 3.4]
*
* // the `_.property` iteratee shorthand.
* _.xorby([{ 'x': 1 }], [{ 'x': 2 }, { 'x': 1 }], 'x');
* // => [{ 'x': 2 }]
*/
var xorby = baserest(function(arrays) {
var iteratee = last(arrays);
if (isarraylikeobject(iteratee)) {
iteratee = undefined;
}
return basexor(arrayfilter(arrays, isarraylikeobject), getiteratee(iteratee, 2));
});
/**
* this method is like `_.xor` except that it accepts `comparator` which is
* invoked to compare elements of `arrays`. the order of result values is
* determined by the order they occur in the arrays. the comparator is invoked
* with two arguments: (arrval, othval).
*
* @static
* @memberof _
* @since 4.0.0
* @category array
* @param {...array} [arrays] the arrays to inspect.
* @param {function} [comparator] the comparator invoked per element.
* @returns {array} returns the new array of filtered values.
* @example
*
* var objects = [{ 'x': 1, 'y': 2 }, { 'x': 2, 'y': 1 }];
* var others = [{ 'x': 1, 'y': 1 }, { 'x': 1, 'y': 2 }];
*
* _.xorwith(objects, others, _.isequal);
* // => [{ 'x': 2, 'y': 1 }, { 'x': 1, 'y': 1 }]
*/
var xorwith = baserest(function(arrays) {
var comparator = last(arrays);
comparator = typeof comparator == 'function' ? comparator : undefined;
return basexor(arrayfilter(arrays, isarraylikeobject), undefined, comparator);
});
/**
* creates an array of grouped elements, the first of which contains the
* first elements of the given arrays, the second of which contains the
* second elements of the given arrays, and so on.
*
* @static
* @memberof _
* @since 0.1.0
* @category array
* @param {...array} [arrays] the arrays to process.
* @returns {array} returns the new array of grouped elements.
* @example
*
* _.zip(['a', 'b'], [1, 2], [true, false]);
* // => [['a', 1, true], ['b', 2, false]]
*/
var zip = baserest(unzip);
/**
* this method is like `_.frompairs` except that it accepts two arrays,
* one of property identifiers and one of corresponding values.
*
* @static
* @memberof _
* @since 0.4.0
* @category array
* @param {array} [props=[]] the property identifiers.
* @param {array} [values=[]] the property values.
* @returns {object} returns the new object.
* @example
*
* _.zipobject(['a', 'b'], [1, 2]);
* // => { 'a': 1, 'b': 2 }
*/
function zipobject(props, values) {
return basezipobject(props || [], values || [], assignvalue);
}
/**
* this method is like `_.zipobject` except that it supports property paths.
*
* @static
* @memberof _
* @since 4.1.0
* @category array
* @param {array} [props=[]] the property identifiers.
* @param {array} [values=[]] the property values.
* @returns {object} returns the new object.
* @example
*
* _.zipobjectdeep(['a.b[0].c', 'a.b[1].d'], [1, 2]);
* // => { 'a': { 'b': [{ 'c': 1 }, { 'd': 2 }] } }
*/
function zipobjectdeep(props, values) {
return basezipobject(props || [], values || [], baseset);
}
/**
* this method is like `_.zip` except that it accepts `iteratee` to specify
* how grouped values should be combined. the iteratee is invoked with the
* elements of each group: (...group).
*
* @static
* @memberof _
* @since 3.8.0
* @category array
* @param {...array} [arrays] the arrays to process.
* @param {function} [iteratee=_.identity] the function to combine
* grouped values.
* @returns {array} returns the new array of grouped elements.
* @example
*
* _.zipwith([1, 2], [10, 20], [100, 200], function(a, b, c) {
* return a + b + c;
* });
* // => [111, 222]
*/
var zipwith = baserest(function(arrays) {
var length = arrays.length,
iteratee = length > 1 ? arrays[length - 1] : undefined;
iteratee = typeof iteratee == 'function' ? (arrays.pop(), iteratee) : undefined;
return unzipwith(arrays, iteratee);
});
/*------------------------------------------------------------------------*/
/**
* creates a `lodash` wrapper instance that wraps `value` with explicit method
* chain sequences enabled. the result of such sequences must be unwrapped
* with `_#value`.
*
* @static
* @memberof _
* @since 1.3.0
* @category seq
* @param {*} value the value to wrap.
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'pebbles', 'age': 1 }
* ];
*
* var youngest = _
* .chain(users)
* .sortby('age')
* .map(function(o) {
* return o.user + ' is ' + o.age;
* })
* .head()
* .value();
* // => 'pebbles is 1'
*/
function chain(value) {
var result = lodash(value);
result.__chain__ = true;
return result;
}
/**
* this method invokes `interceptor` and returns `value`. the interceptor
* is invoked with one argument; (value). the purpose of this method is to
* "tap into" a method chain sequence in order to modify intermediate results.
*
* @static
* @memberof _
* @since 0.1.0
* @category seq
* @param {*} value the value to provide to `interceptor`.
* @param {function} interceptor the function to invoke.
* @returns {*} returns `value`.
* @example
*
* _([1, 2, 3])
* .tap(function(array) {
* // mutate input array.
* array.pop();
* })
* .reverse()
* .value();
* // => [2, 1]
*/
function tap(value, interceptor) {
interceptor(value);
return value;
}
/**
* this method is like `_.tap` except that it returns the result of `interceptor`.
* the purpose of this method is to "pass thru" values replacing intermediate
* results in a method chain sequence.
*
* @static
* @memberof _
* @since 3.0.0
* @category seq
* @param {*} value the value to provide to `interceptor`.
* @param {function} interceptor the function to invoke.
* @returns {*} returns the result of `interceptor`.
* @example
*
* _(' abc ')
* .chain()
* .trim()
* .thru(function(value) {
* return [value];
* })
* .value();
* // => ['abc']
*/
function thru(value, interceptor) {
return interceptor(value);
}
/**
* this method is the wrapper version of `_.at`.
*
* @name at
* @memberof _
* @since 1.0.0
* @category seq
* @param {...(string|string[])} [paths] the property paths to pick.
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* var object = { 'a': [{ 'b': { 'c': 3 } }, 4] };
*
* _(object).at(['a[0].b.c', 'a[1]']).value();
* // => [3, 4]
*/
var wrapperat = flatrest(function(paths) {
var length = paths.length,
start = length ? paths[0] : 0,
value = this.__wrapped__,
interceptor = function(object) { return baseat(object, paths); };
if (length > 1 || this.__actions__.length ||
!(value instanceof lazywrapper) || !isindex(start)) {
return this.thru(interceptor);
}
value = value.slice(start, +start + (length ? 1 : 0));
value.__actions__.push({
'func': thru,
'args': [interceptor],
'thisarg': undefined
});
return new lodashwrapper(value, this.__chain__).thru(function(array) {
if (length && !array.length) {
array.push(undefined);
}
return array;
});
});
/**
* creates a `lodash` wrapper instance with explicit method chain sequences enabled.
*
* @name chain
* @memberof _
* @since 0.1.0
* @category seq
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 }
* ];
*
* // a sequence without explicit chaining.
* _(users).head();
* // => { 'user': 'barney', 'age': 36 }
*
* // a sequence with explicit chaining.
* _(users)
* .chain()
* .head()
* .pick('user')
* .value();
* // => { 'user': 'barney' }
*/
function wrapperchain() {
return chain(this);
}
/**
* executes the chain sequence and returns the wrapped result.
*
* @name commit
* @memberof _
* @since 3.2.0
* @category seq
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* var array = [1, 2];
* var wrapped = _(array).push(3);
*
* console.log(array);
* // => [1, 2]
*
* wrapped = wrapped.commit();
* console.log(array);
* // => [1, 2, 3]
*
* wrapped.last();
* // => 3
*
* console.log(array);
* // => [1, 2, 3]
*/
function wrappercommit() {
return new lodashwrapper(this.value(), this.__chain__);
}
/**
* gets the next value on a wrapped object following the
* [iterator protocol](https://mdn.io/iteration_protocols#iterator).
*
* @name next
* @memberof _
* @since 4.0.0
* @category seq
* @returns {object} returns the next iterator value.
* @example
*
* var wrapped = _([1, 2]);
*
* wrapped.next();
* // => { 'done': false, 'value': 1 }
*
* wrapped.next();
* // => { 'done': false, 'value': 2 }
*
* wrapped.next();
* // => { 'done': true, 'value': undefined }
*/
function wrappernext() {
if (this.__values__ === undefined) {
this.__values__ = toarray(this.value());
}
var done = this.__index__ >= this.__values__.length,
value = done ? undefined : this.__values__[this.__index__++];
return { 'done': done, 'value': value };
}
/**
* enables the wrapper to be iterable.
*
* @name symbol.iterator
* @memberof _
* @since 4.0.0
* @category seq
* @returns {object} returns the wrapper object.
* @example
*
* var wrapped = _([1, 2]);
*
* wrapped[symbol.iterator]() === wrapped;
* // => true
*
* array.from(wrapped);
* // => [1, 2]
*/
function wrappertoiterator() {
return this;
}
/**
* creates a clone of the chain sequence planting `value` as the wrapped value.
*
* @name plant
* @memberof _
* @since 3.2.0
* @category seq
* @param {*} value the value to plant.
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* function square(n) {
* return n * n;
* }
*
* var wrapped = _([1, 2]).map(square);
* var other = wrapped.plant([3, 4]);
*
* other.value();
* // => [9, 16]
*
* wrapped.value();
* // => [1, 4]
*/
function wrapperplant(value) {
var result,
parent = this;
while (parent instanceof baselodash) {
var clone = wrapperclone(parent);
clone.__index__ = 0;
clone.__values__ = undefined;
if (result) {
previous.__wrapped__ = clone;
} else {
result = clone;
}
var previous = clone;
parent = parent.__wrapped__;
}
previous.__wrapped__ = value;
return result;
}
/**
* this method is the wrapper version of `_.reverse`.
*
* **note:** this method mutates the wrapped array.
*
* @name reverse
* @memberof _
* @since 0.1.0
* @category seq
* @returns {object} returns the new `lodash` wrapper instance.
* @example
*
* var array = [1, 2, 3];
*
* _(array).reverse().value()
* // => [3, 2, 1]
*
* console.log(array);
* // => [3, 2, 1]
*/
function wrapperreverse() {
var value = this.__wrapped__;
if (value instanceof lazywrapper) {
var wrapped = value;
if (this.__actions__.length) {
wrapped = new lazywrapper(this);
}
wrapped = wrapped.reverse();
wrapped.__actions__.push({
'func': thru,
'args': [reverse],
'thisarg': undefined
});
return new lodashwrapper(wrapped, this.__chain__);
}
return this.thru(reverse);
}
/**
* executes the chain sequence to resolve the unwrapped value.
*
* @name value
* @memberof _
* @since 0.1.0
* @alias tojson, valueof
* @category seq
* @returns {*} returns the resolved unwrapped value.
* @example
*
* _([1, 2, 3]).value();
* // => [1, 2, 3]
*/
function wrappervalue() {
return basewrappervalue(this.__wrapped__, this.__actions__);
}
/*------------------------------------------------------------------------*/
/**
* creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. the corresponding value of
* each key is the number of times the key was returned by `iteratee`. the
* iteratee is invoked with one argument: (value).
*
* @static
* @memberof _
* @since 0.5.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the iteratee to transform keys.
* @returns {object} returns the composed aggregate object.
* @example
*
* _.countby([6.1, 4.2, 6.3], math.floor);
* // => { '4': 1, '6': 2 }
*
* // the `_.property` iteratee shorthand.
* _.countby(['one', 'two', 'three'], 'length');
* // => { '3': 2, '5': 1 }
*/
var countby = createaggregator(function(result, value, key) {
if (hasownproperty.call(result, key)) {
++result[key];
} else {
baseassignvalue(result, key, 1);
}
});
/**
* checks if `predicate` returns truthy for **all** elements of `collection`.
* iteration is stopped once `predicate` returns falsey. the predicate is
* invoked with three arguments: (value, index|key, collection).
*
* **note:** this method returns `true` for
* [empty collections](https://en.wikipedia.org/wiki/empty_set) because
* [everything is true](https://en.wikipedia.org/wiki/vacuous_truth) of
* elements of empty collections.
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {boolean} returns `true` if all elements pass the predicate check,
* else `false`.
* @example
*
* _.every([true, 1, null, 'yes'], boolean);
* // => false
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* // the `_.matches` iteratee shorthand.
* _.every(users, { 'user': 'barney', 'active': false });
* // => false
*
* // the `_.matchesproperty` iteratee shorthand.
* _.every(users, ['active', false]);
* // => true
*
* // the `_.property` iteratee shorthand.
* _.every(users, 'active');
* // => false
*/
function every(collection, predicate, guard) {
var func = isarray(collection) ? arrayevery : baseevery;
if (guard && isiterateecall(collection, predicate, guard)) {
predicate = undefined;
}
return func(collection, getiteratee(predicate, 3));
}
/**
* iterates over elements of `collection`, returning an array of all elements
* `predicate` returns truthy for. the predicate is invoked with three
* arguments: (value, index|key, collection).
*
* **note:** unlike `_.remove`, this method returns a new array.
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the new filtered array.
* @see _.reject
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false }
* ];
*
* _.filter(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // the `_.matches` iteratee shorthand.
* _.filter(users, { 'age': 36, 'active': true });
* // => objects for ['barney']
*
* // the `_.matchesproperty` iteratee shorthand.
* _.filter(users, ['active', false]);
* // => objects for ['fred']
*
* // the `_.property` iteratee shorthand.
* _.filter(users, 'active');
* // => objects for ['barney']
*/
function filter(collection, predicate) {
var func = isarray(collection) ? arrayfilter : basefilter;
return func(collection, getiteratee(predicate, 3));
}
/**
* iterates over elements of `collection`, returning the first element
* `predicate` returns truthy for. the predicate is invoked with three
* arguments: (value, index|key, collection).
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to inspect.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @param {number} [fromindex=0] the index to search from.
* @returns {*} returns the matched element, else `undefined`.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': true },
* { 'user': 'fred', 'age': 40, 'active': false },
* { 'user': 'pebbles', 'age': 1, 'active': true }
* ];
*
* _.find(users, function(o) { return o.age < 40; });
* // => object for 'barney'
*
* // the `_.matches` iteratee shorthand.
* _.find(users, { 'age': 1, 'active': true });
* // => object for 'pebbles'
*
* // the `_.matchesproperty` iteratee shorthand.
* _.find(users, ['active', false]);
* // => object for 'fred'
*
* // the `_.property` iteratee shorthand.
* _.find(users, 'active');
* // => object for 'barney'
*/
var find = createfind(findindex);
/**
* this method is like `_.find` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberof _
* @since 2.0.0
* @category collection
* @param {array|object} collection the collection to inspect.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @param {number} [fromindex=collection.length-1] the index to search from.
* @returns {*} returns the matched element, else `undefined`.
* @example
*
* _.findlast([1, 2, 3, 4], function(n) {
* return n % 2 == 1;
* });
* // => 3
*/
var findlast = createfind(findlastindex);
/**
* creates a flattened array of values by running each element in `collection`
* thru `iteratee` and flattening the mapped results. the iteratee is invoked
* with three arguments: (value, index|key, collection).
*
* @static
* @memberof _
* @since 4.0.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @returns {array} returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [n, n];
* }
*
* _.flatmap([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatmap(collection, iteratee) {
return baseflatten(map(collection, iteratee), 1);
}
/**
* this method is like `_.flatmap` except that it recursively flattens the
* mapped results.
*
* @static
* @memberof _
* @since 4.7.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @returns {array} returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [[[n, n]]];
* }
*
* _.flatmapdeep([1, 2], duplicate);
* // => [1, 1, 2, 2]
*/
function flatmapdeep(collection, iteratee) {
return baseflatten(map(collection, iteratee), infinity);
}
/**
* this method is like `_.flatmap` except that it recursively flattens the
* mapped results up to `depth` times.
*
* @static
* @memberof _
* @since 4.7.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @param {number} [depth=1] the maximum recursion depth.
* @returns {array} returns the new flattened array.
* @example
*
* function duplicate(n) {
* return [[[n, n]]];
* }
*
* _.flatmapdepth([1, 2], duplicate, 2);
* // => [[1, 1], [2, 2]]
*/
function flatmapdepth(collection, iteratee, depth) {
depth = depth === undefined ? 1 : tointeger(depth);
return baseflatten(map(collection, iteratee), depth);
}
/**
* iterates over elements of `collection` and invokes `iteratee` for each element.
* the iteratee is invoked with three arguments: (value, index|key, collection).
* iteratee functions may exit iteration early by explicitly returning `false`.
*
* **note:** as with other "collections" methods, objects with a "length"
* property are iterated like arrays. to avoid this behavior use `_.forin`
* or `_.forown` for object iteration.
*
* @static
* @memberof _
* @since 0.1.0
* @alias each
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @returns {array|object} returns `collection`.
* @see _.foreachright
* @example
*
* _.foreach([1, 2], function(value) {
* console.log(value);
* });
* // => logs `1` then `2`.
*
* _.foreach({ 'a': 1, 'b': 2 }, function(value, key) {
* console.log(key);
* });
* // => logs 'a' then 'b' (iteration order is not guaranteed).
*/
function foreach(collection, iteratee) {
var func = isarray(collection) ? arrayeach : baseeach;
return func(collection, getiteratee(iteratee, 3));
}
/**
* this method is like `_.foreach` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberof _
* @since 2.0.0
* @alias eachright
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @returns {array|object} returns `collection`.
* @see _.foreach
* @example
*
* _.foreachright([1, 2], function(value) {
* console.log(value);
* });
* // => logs `2` then `1`.
*/
function foreachright(collection, iteratee) {
var func = isarray(collection) ? arrayeachright : baseeachright;
return func(collection, getiteratee(iteratee, 3));
}
/**
* creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. the order of grouped values
* is determined by the order they occur in `collection`. the corresponding
* value of each key is an array of elements responsible for generating the
* key. the iteratee is invoked with one argument: (value).
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the iteratee to transform keys.
* @returns {object} returns the composed aggregate object.
* @example
*
* _.groupby([6.1, 4.2, 6.3], math.floor);
* // => { '4': [4.2], '6': [6.1, 6.3] }
*
* // the `_.property` iteratee shorthand.
* _.groupby(['one', 'two', 'three'], 'length');
* // => { '3': ['one', 'two'], '5': ['three'] }
*/
var groupby = createaggregator(function(result, value, key) {
if (hasownproperty.call(result, key)) {
result[key].push(value);
} else {
baseassignvalue(result, key, [value]);
}
});
/**
* checks if `value` is in `collection`. if `collection` is a string, it's
* checked for a substring of `value`, otherwise
* [`samevaluezero`](http://ecma-international.org/ecma-262/7.0/#sec-samevaluezero)
* is used for equality comparisons. if `fromindex` is negative, it's used as
* the offset from the end of `collection`.
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object|string} collection the collection to inspect.
* @param {*} value the value to search for.
* @param {number} [fromindex=0] the index to search from.
* @param- {object} [guard] enables use as an iteratee for methods like `_.reduce`.
* @returns {boolean} returns `true` if `value` is found, else `false`.
* @example
*
* _.includes([1, 2, 3], 1);
* // => true
*
* _.includes([1, 2, 3], 1, 2);
* // => false
*
* _.includes({ 'a': 1, 'b': 2 }, 1);
* // => true
*
* _.includes('abcd', 'bc');
* // => true
*/
function includes(collection, value, fromindex, guard) {
collection = isarraylike(collection) ? collection : values(collection);
fromindex = (fromindex && !guard) ? tointeger(fromindex) : 0;
var length = collection.length;
if (fromindex < 0) {
fromindex = nativemax(length + fromindex, 0);
}
return isstring(collection)
? (fromindex <= length && collection.indexof(value, fromindex) > -1)
: (!!length && baseindexof(collection, value, fromindex) > -1);
}
/**
* invokes the method at `path` of each element in `collection`, returning
* an array of the results of each invoked method. any additional arguments
* are provided to each invoked method. if `path` is a function, it's invoked
* for, and `this` bound to, each element in `collection`.
*
* @static
* @memberof _
* @since 4.0.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {array|function|string} path the path of the method to invoke or
* the function invoked per iteration.
* @param {...*} [args] the arguments to invoke each method with.
* @returns {array} returns the array of results.
* @example
*
* _.invokemap([[5, 1, 7], [3, 2, 1]], 'sort');
* // => [[1, 5, 7], [1, 2, 3]]
*
* _.invokemap([123, 456], string.prototype.split, '');
* // => [['1', '2', '3'], ['4', '5', '6']]
*/
var invokemap = baserest(function(collection, path, args) {
var index = -1,
isfunc = typeof path == 'function',
result = isarraylike(collection) ? array(collection.length) : [];
baseeach(collection, function(value) {
result[++index] = isfunc ? apply(path, value, args) : baseinvoke(value, path, args);
});
return result;
});
/**
* creates an object composed of keys generated from the results of running
* each element of `collection` thru `iteratee`. the corresponding value of
* each key is the last element responsible for generating the key. the
* iteratee is invoked with one argument: (value).
*
* @static
* @memberof _
* @since 4.0.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the iteratee to transform keys.
* @returns {object} returns the composed aggregate object.
* @example
*
* var array = [
* { 'dir': 'left', 'code': 97 },
* { 'dir': 'right', 'code': 100 }
* ];
*
* _.keyby(array, function(o) {
* return string.fromcharcode(o.code);
* });
* // => { 'a': { 'dir': 'left', 'code': 97 }, 'd': { 'dir': 'right', 'code': 100 } }
*
* _.keyby(array, 'dir');
* // => { 'left': { 'dir': 'left', 'code': 97 }, 'right': { 'dir': 'right', 'code': 100 } }
*/
var keyby = createaggregator(function(result, value, key) {
baseassignvalue(result, key, value);
});
/**
* creates an array of values by running each element in `collection` thru
* `iteratee`. the iteratee is invoked with three arguments:
* (value, index|key, collection).
*
* many lodash methods are guarded to work as iteratees for methods like
* `_.every`, `_.filter`, `_.map`, `_.mapvalues`, `_.reject`, and `_.some`.
*
* the guarded methods are:
* `ary`, `chunk`, `curry`, `curryright`, `drop`, `dropright`, `every`,
* `fill`, `invert`, `parseint`, `random`, `range`, `rangeright`, `repeat`,
* `samplesize`, `slice`, `some`, `sortby`, `split`, `take`, `takeright`,
* `template`, `trim`, `trimend`, `trimstart`, and `words`
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @returns {array} returns the new mapped array.
* @example
*
* function square(n) {
* return n * n;
* }
*
* _.map([4, 8], square);
* // => [16, 64]
*
* _.map({ 'a': 4, 'b': 8 }, square);
* // => [16, 64] (iteration order is not guaranteed)
*
* var users = [
* { 'user': 'barney' },
* { 'user': 'fred' }
* ];
*
* // the `_.property` iteratee shorthand.
* _.map(users, 'user');
* // => ['barney', 'fred']
*/
function map(collection, iteratee) {
var func = isarray(collection) ? arraymap : basemap;
return func(collection, getiteratee(iteratee, 3));
}
/**
* this method is like `_.sortby` except that it allows specifying the sort
* orders of the iteratees to sort by. if `orders` is unspecified, all values
* are sorted in ascending order. otherwise, specify an order of "desc" for
* descending or "asc" for ascending sort order of corresponding values.
*
* @static
* @memberof _
* @since 4.0.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {array[]|function[]|object[]|string[]} [iteratees=[_.identity]]
* the iteratees to sort by.
* @param {string[]} [orders] the sort orders of `iteratees`.
* @param- {object} [guard] enables use as an iteratee for methods like `_.reduce`.
* @returns {array} returns the new sorted array.
* @example
*
* var users = [
* { 'user': 'fred', 'age': 48 },
* { 'user': 'barney', 'age': 34 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 36 }
* ];
*
* // sort by `user` in ascending order and by `age` in descending order.
* _.orderby(users, ['user', 'age'], ['asc', 'desc']);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*/
function orderby(collection, iteratees, orders, guard) {
if (collection == null) {
return [];
}
if (!isarray(iteratees)) {
iteratees = iteratees == null ? [] : [iteratees];
}
orders = guard ? undefined : orders;
if (!isarray(orders)) {
orders = orders == null ? [] : [orders];
}
return baseorderby(collection, iteratees, orders);
}
/**
* creates an array of elements split into two groups, the first of which
* contains elements `predicate` returns truthy for, the second of which
* contains elements `predicate` returns falsey for. the predicate is
* invoked with one argument: (value).
*
* @static
* @memberof _
* @since 3.0.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the array of grouped elements.
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true },
* { 'user': 'pebbles', 'age': 1, 'active': false }
* ];
*
* _.partition(users, function(o) { return o.active; });
* // => objects for [['fred'], ['barney', 'pebbles']]
*
* // the `_.matches` iteratee shorthand.
* _.partition(users, { 'age': 1, 'active': false });
* // => objects for [['pebbles'], ['barney', 'fred']]
*
* // the `_.matchesproperty` iteratee shorthand.
* _.partition(users, ['active', false]);
* // => objects for [['barney', 'pebbles'], ['fred']]
*
* // the `_.property` iteratee shorthand.
* _.partition(users, 'active');
* // => objects for [['fred'], ['barney', 'pebbles']]
*/
var partition = createaggregator(function(result, value, key) {
result[key ? 0 : 1].push(value);
}, function() { return [[], []]; });
/**
* reduces `collection` to a value which is the accumulated result of running
* each element in `collection` thru `iteratee`, where each successive
* invocation is supplied the return value of the previous. if `accumulator`
* is not given, the first element of `collection` is used as the initial
* value. the iteratee is invoked with four arguments:
* (accumulator, value, index|key, collection).
*
* many lodash methods are guarded to work as iteratees for methods like
* `_.reduce`, `_.reduceright`, and `_.transform`.
*
* the guarded methods are:
* `assign`, `defaults`, `defaultsdeep`, `includes`, `merge`, `orderby`,
* and `sortby`
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @param {*} [accumulator] the initial value.
* @returns {*} returns the accumulated value.
* @see _.reduceright
* @example
*
* _.reduce([1, 2], function(sum, n) {
* return sum + n;
* }, 0);
* // => 3
*
* _.reduce({ 'a': 1, 'b': 2, 'c': 1 }, function(result, value, key) {
* (result[value] || (result[value] = [])).push(key);
* return result;
* }, {});
* // => { '1': ['a', 'c'], '2': ['b'] } (iteration order is not guaranteed)
*/
function reduce(collection, iteratee, accumulator) {
var func = isarray(collection) ? arrayreduce : basereduce,
initaccum = arguments.length < 3;
return func(collection, getiteratee(iteratee, 4), accumulator, initaccum, baseeach);
}
/**
* this method is like `_.reduce` except that it iterates over elements of
* `collection` from right to left.
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [iteratee=_.identity] the function invoked per iteration.
* @param {*} [accumulator] the initial value.
* @returns {*} returns the accumulated value.
* @see _.reduce
* @example
*
* var array = [[0, 1], [2, 3], [4, 5]];
*
* _.reduceright(array, function(flattened, other) {
* return flattened.concat(other);
* }, []);
* // => [4, 5, 2, 3, 0, 1]
*/
function reduceright(collection, iteratee, accumulator) {
var func = isarray(collection) ? arrayreduceright : basereduce,
initaccum = arguments.length < 3;
return func(collection, getiteratee(iteratee, 4), accumulator, initaccum, baseeachright);
}
/**
* the opposite of `_.filter`; this method returns the elements of `collection`
* that `predicate` does **not** return truthy for.
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @returns {array} returns the new filtered array.
* @see _.filter
* @example
*
* var users = [
* { 'user': 'barney', 'age': 36, 'active': false },
* { 'user': 'fred', 'age': 40, 'active': true }
* ];
*
* _.reject(users, function(o) { return !o.active; });
* // => objects for ['fred']
*
* // the `_.matches` iteratee shorthand.
* _.reject(users, { 'age': 40, 'active': true });
* // => objects for ['barney']
*
* // the `_.matchesproperty` iteratee shorthand.
* _.reject(users, ['active', false]);
* // => objects for ['fred']
*
* // the `_.property` iteratee shorthand.
* _.reject(users, 'active');
* // => objects for ['barney']
*/
function reject(collection, predicate) {
var func = isarray(collection) ? arrayfilter : basefilter;
return func(collection, negate(getiteratee(predicate, 3)));
}
/**
* gets a random element from `collection`.
*
* @static
* @memberof _
* @since 2.0.0
* @category collection
* @param {array|object} collection the collection to sample.
* @returns {*} returns the random element.
* @example
*
* _.sample([1, 2, 3, 4]);
* // => 2
*/
function sample(collection) {
var func = isarray(collection) ? arraysample : basesample;
return func(collection);
}
/**
* gets `n` random elements at unique keys from `collection` up to the
* size of `collection`.
*
* @static
* @memberof _
* @since 4.0.0
* @category collection
* @param {array|object} collection the collection to sample.
* @param {number} [n=1] the number of elements to sample.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {array} returns the random elements.
* @example
*
* _.samplesize([1, 2, 3], 2);
* // => [3, 1]
*
* _.samplesize([1, 2, 3], 4);
* // => [2, 3, 1]
*/
function samplesize(collection, n, guard) {
if ((guard ? isiterateecall(collection, n, guard) : n === undefined)) {
n = 1;
} else {
n = tointeger(n);
}
var func = isarray(collection) ? arraysamplesize : basesamplesize;
return func(collection, n);
}
/**
* creates an array of shuffled values, using a version of the
* [fisher-yates shuffle](https://en.wikipedia.org/wiki/fisher-yates_shuffle).
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to shuffle.
* @returns {array} returns the new shuffled array.
* @example
*
* _.shuffle([1, 2, 3, 4]);
* // => [4, 1, 3, 2]
*/
function shuffle(collection) {
var func = isarray(collection) ? arrayshuffle : baseshuffle;
return func(collection);
}
/**
* gets the size of `collection` by returning its length for array-like
* values or the number of own enumerable string keyed properties for objects.
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object|string} collection the collection to inspect.
* @returns {number} returns the collection size.
* @example
*
* _.size([1, 2, 3]);
* // => 3
*
* _.size({ 'a': 1, 'b': 2 });
* // => 2
*
* _.size('pebbles');
* // => 7
*/
function size(collection) {
if (collection == null) {
return 0;
}
if (isarraylike(collection)) {
return isstring(collection) ? stringsize(collection) : collection.length;
}
var tag = gettag(collection);
if (tag == maptag || tag == settag) {
return collection.size;
}
return basekeys(collection).length;
}
/**
* checks if `predicate` returns truthy for **any** element of `collection`.
* iteration is stopped once `predicate` returns truthy. the predicate is
* invoked with three arguments: (value, index|key, collection).
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {function} [predicate=_.identity] the function invoked per iteration.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {boolean} returns `true` if any element passes the predicate check,
* else `false`.
* @example
*
* _.some([null, 0, 'yes', false], boolean);
* // => true
*
* var users = [
* { 'user': 'barney', 'active': true },
* { 'user': 'fred', 'active': false }
* ];
*
* // the `_.matches` iteratee shorthand.
* _.some(users, { 'user': 'barney', 'active': false });
* // => false
*
* // the `_.matchesproperty` iteratee shorthand.
* _.some(users, ['active', false]);
* // => true
*
* // the `_.property` iteratee shorthand.
* _.some(users, 'active');
* // => true
*/
function some(collection, predicate, guard) {
var func = isarray(collection) ? arraysome : basesome;
if (guard && isiterateecall(collection, predicate, guard)) {
predicate = undefined;
}
return func(collection, getiteratee(predicate, 3));
}
/**
* creates an array of elements, sorted in ascending order by the results of
* running each element in a collection thru each iteratee. this method
* performs a stable sort, that is, it preserves the original sort order of
* equal elements. the iteratees are invoked with one argument: (value).
*
* @static
* @memberof _
* @since 0.1.0
* @category collection
* @param {array|object} collection the collection to iterate over.
* @param {...(function|function[])} [iteratees=[_.identity]]
* the iteratees to sort by.
* @returns {array} returns the new sorted array.
* @example
*
* var users = [
* { 'user': 'fred', 'age': 48 },
* { 'user': 'barney', 'age': 36 },
* { 'user': 'fred', 'age': 40 },
* { 'user': 'barney', 'age': 34 }
* ];
*
* _.sortby(users, [function(o) { return o.user; }]);
* // => objects for [['barney', 36], ['barney', 34], ['fred', 48], ['fred', 40]]
*
* _.sortby(users, ['user', 'age']);
* // => objects for [['barney', 34], ['barney', 36], ['fred', 40], ['fred', 48]]
*/
var sortby = baserest(function(collection, iteratees) {
if (collection == null) {
return [];
}
var length = iteratees.length;
if (length > 1 && isiterateecall(collection, iteratees[0], iteratees[1])) {
iteratees = [];
} else if (length > 2 && isiterateecall(iteratees[0], iteratees[1], iteratees[2])) {
iteratees = [iteratees[0]];
}
return baseorderby(collection, baseflatten(iteratees, 1), []);
});
/*------------------------------------------------------------------------*/
/**
* gets the timestamp of the number of milliseconds that have elapsed since
* the unix epoch (1 january 1970 00:00:00 utc).
*
* @static
* @memberof _
* @since 2.4.0
* @category date
* @returns {number} returns the timestamp.
* @example
*
* _.defer(function(stamp) {
* console.log(_.now() - stamp);
* }, _.now());
* // => logs the number of milliseconds it took for the deferred invocation.
*/
var now = ctxnow || function() {
return root.date.now();
};
/*------------------------------------------------------------------------*/
/**
* the opposite of `_.before`; this method creates a function that invokes
* `func` once it's called `n` or more times.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {number} n the number of calls before `func` is invoked.
* @param {function} func the function to restrict.
* @returns {function} returns the new restricted function.
* @example
*
* var saves = ['profile', 'settings'];
*
* var done = _.after(saves.length, function() {
* console.log('done saving!');
* });
*
* _.foreach(saves, function(type) {
* asyncsave({ 'type': type, 'complete': done });
* });
* // => logs 'done saving!' after the two async saves have completed.
*/
function after(n, func) {
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
n = tointeger(n);
return function() {
if (--n < 1) {
return func.apply(this, arguments);
}
};
}
/**
* creates a function that invokes `func`, with up to `n` arguments,
* ignoring any additional arguments.
*
* @static
* @memberof _
* @since 3.0.0
* @category function
* @param {function} func the function to cap arguments for.
* @param {number} [n=func.length] the arity cap.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {function} returns the new capped function.
* @example
*
* _.map(['6', '8', '10'], _.ary(parseint, 1));
* // => [6, 8, 10]
*/
function ary(func, n, guard) {
n = guard ? undefined : n;
n = (func && n == null) ? func.length : n;
return createwrap(func, wrap_ary_flag, undefined, undefined, undefined, undefined, n);
}
/**
* creates a function that invokes `func`, with the `this` binding and arguments
* of the created function, while it's called less than `n` times. subsequent
* calls to the created function return the result of the last `func` invocation.
*
* @static
* @memberof _
* @since 3.0.0
* @category function
* @param {number} n the number of calls at which `func` is no longer invoked.
* @param {function} func the function to restrict.
* @returns {function} returns the new restricted function.
* @example
*
* jquery(element).on('click', _.before(5, addcontacttolist));
* // => allows adding up to 4 contacts to the list.
*/
function before(n, func) {
var result;
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
n = tointeger(n);
return function() {
if (--n > 0) {
result = func.apply(this, arguments);
}
if (n <= 1) {
func = undefined;
}
return result;
};
}
/**
* creates a function that invokes `func` with the `this` binding of `thisarg`
* and `partials` prepended to the arguments it receives.
*
* the `_.bind.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for partially applied arguments.
*
* **note:** unlike native `function#bind`, this method doesn't set the "length"
* property of bound functions.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to bind.
* @param {*} thisarg the `this` binding of `func`.
* @param {...*} [partials] the arguments to be partially applied.
* @returns {function} returns the new bound function.
* @example
*
* function greet(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation;
* }
*
* var object = { 'user': 'fred' };
*
* var bound = _.bind(greet, object, 'hi');
* bound('!');
* // => 'hi fred!'
*
* // bound with placeholders.
* var bound = _.bind(greet, object, _, '!');
* bound('hi');
* // => 'hi fred!'
*/
var bind = baserest(function(func, thisarg, partials) {
var bitmask = wrap_bind_flag;
if (partials.length) {
var holders = replaceholders(partials, getholder(bind));
bitmask |= wrap_partial_flag;
}
return createwrap(func, bitmask, thisarg, partials, holders);
});
/**
* creates a function that invokes the method at `object[key]` with `partials`
* prepended to the arguments it receives.
*
* this method differs from `_.bind` by allowing bound functions to reference
* methods that may be redefined or don't yet exist. see
* [peter michaux's article](http://peter.michaux.ca/articles/lazy-function-definition-pattern)
* for more details.
*
* the `_.bindkey.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for partially applied arguments.
*
* @static
* @memberof _
* @since 0.10.0
* @category function
* @param {object} object the object to invoke the method on.
* @param {string} key the key of the method.
* @param {...*} [partials] the arguments to be partially applied.
* @returns {function} returns the new bound function.
* @example
*
* var object = {
* 'user': 'fred',
* 'greet': function(greeting, punctuation) {
* return greeting + ' ' + this.user + punctuation;
* }
* };
*
* var bound = _.bindkey(object, 'greet', 'hi');
* bound('!');
* // => 'hi fred!'
*
* object.greet = function(greeting, punctuation) {
* return greeting + 'ya ' + this.user + punctuation;
* };
*
* bound('!');
* // => 'hiya fred!'
*
* // bound with placeholders.
* var bound = _.bindkey(object, 'greet', _, '!');
* bound('hi');
* // => 'hiya fred!'
*/
var bindkey = baserest(function(object, key, partials) {
var bitmask = wrap_bind_flag | wrap_bind_key_flag;
if (partials.length) {
var holders = replaceholders(partials, getholder(bindkey));
bitmask |= wrap_partial_flag;
}
return createwrap(key, bitmask, object, partials, holders);
});
/**
* creates a function that accepts arguments of `func` and either invokes
* `func` returning its result, if at least `arity` number of arguments have
* been provided, or returns a function that accepts the remaining `func`
* arguments, and so on. the arity of `func` may be specified if `func.length`
* is not sufficient.
*
* the `_.curry.placeholder` value, which defaults to `_` in monolithic builds,
* may be used as a placeholder for provided arguments.
*
* **note:** this method doesn't set the "length" property of curried functions.
*
* @static
* @memberof _
* @since 2.0.0
* @category function
* @param {function} func the function to curry.
* @param {number} [arity=func.length] the arity of `func`.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {function} returns the new curried function.
* @example
*
* var abc = function(a, b, c) {
* return [a, b, c];
* };
*
* var curried = _.curry(abc);
*
* curried(1)(2)(3);
* // => [1, 2, 3]
*
* curried(1, 2)(3);
* // => [1, 2, 3]
*
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // curried with placeholders.
* curried(1)(_, 3)(2);
* // => [1, 2, 3]
*/
function curry(func, arity, guard) {
arity = guard ? undefined : arity;
var result = createwrap(func, wrap_curry_flag, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curry.placeholder;
return result;
}
/**
* this method is like `_.curry` except that arguments are applied to `func`
* in the manner of `_.partialright` instead of `_.partial`.
*
* the `_.curryright.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for provided arguments.
*
* **note:** this method doesn't set the "length" property of curried functions.
*
* @static
* @memberof _
* @since 3.0.0
* @category function
* @param {function} func the function to curry.
* @param {number} [arity=func.length] the arity of `func`.
* @param- {object} [guard] enables use as an iteratee for methods like `_.map`.
* @returns {function} returns the new curried function.
* @example
*
* var abc = function(a, b, c) {
* return [a, b, c];
* };
*
* var curried = _.curryright(abc);
*
* curried(3)(2)(1);
* // => [1, 2, 3]
*
* curried(2, 3)(1);
* // => [1, 2, 3]
*
* curried(1, 2, 3);
* // => [1, 2, 3]
*
* // curried with placeholders.
* curried(3)(1, _)(2);
* // => [1, 2, 3]
*/
function curryright(func, arity, guard) {
arity = guard ? undefined : arity;
var result = createwrap(func, wrap_curry_right_flag, undefined, undefined, undefined, undefined, undefined, arity);
result.placeholder = curryright.placeholder;
return result;
}
/**
* creates a debounced function that delays invoking `func` until after `wait`
* milliseconds have elapsed since the last time the debounced function was
* invoked. the debounced function comes with a `cancel` method to cancel
* delayed `func` invocations and a `flush` method to immediately invoke them.
* provide `options` to indicate whether `func` should be invoked on the
* leading and/or trailing edge of the `wait` timeout. the `func` is invoked
* with the last arguments provided to the debounced function. subsequent
* calls to the debounced function return the result of the last `func`
* invocation.
*
* **note:** if `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the debounced function
* is invoked more than once during the `wait` timeout.
*
* if `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `settimeout` with a timeout of `0`.
*
* see [david corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.debounce` and `_.throttle`.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to debounce.
* @param {number} [wait=0] the number of milliseconds to delay.
* @param {object} [options={}] the options object.
* @param {boolean} [options.leading=false]
* specify invoking on the leading edge of the timeout.
* @param {number} [options.maxwait]
* the maximum time `func` is allowed to be delayed before it's invoked.
* @param {boolean} [options.trailing=true]
* specify invoking on the trailing edge of the timeout.
* @returns {function} returns the new debounced function.
* @example
*
* // avoid costly calculations while the window size is in flux.
* jquery(window).on('resize', _.debounce(calculatelayout, 150));
*
* // invoke `sendmail` when clicked, debouncing subsequent calls.
* jquery(element).on('click', _.debounce(sendmail, 300, {
* 'leading': true,
* 'trailing': false
* }));
*
* // ensure `batchlog` is invoked once after 1 second of debounced calls.
* var debounced = _.debounce(batchlog, 250, { 'maxwait': 1000 });
* var source = new eventsource('/stream');
* jquery(source).on('message', debounced);
*
* // cancel the trailing debounced invocation.
* jquery(window).on('popstate', debounced.cancel);
*/
function debounce(func, wait, options) {
var lastargs,
lastthis,
maxwait,
result,
timerid,
lastcalltime,
lastinvoketime = 0,
leading = false,
maxing = false,
trailing = true;
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
wait = tonumber(wait) || 0;
if (isobject(options)) {
leading = !!options.leading;
maxing = 'maxwait' in options;
maxwait = maxing ? nativemax(tonumber(options.maxwait) || 0, wait) : maxwait;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
function invokefunc(time) {
var args = lastargs,
thisarg = lastthis;
lastargs = lastthis = undefined;
lastinvoketime = time;
result = func.apply(thisarg, args);
return result;
}
function leadingedge(time) {
// reset any `maxwait` timer.
lastinvoketime = time;
// start the timer for the trailing edge.
timerid = settimeout(timerexpired, wait);
// invoke the leading edge.
return leading ? invokefunc(time) : result;
}
function remainingwait(time) {
var timesincelastcall = time - lastcalltime,
timesincelastinvoke = time - lastinvoketime,
timewaiting = wait - timesincelastcall;
return maxing
? nativemin(timewaiting, maxwait - timesincelastinvoke)
: timewaiting;
}
function shouldinvoke(time) {
var timesincelastcall = time - lastcalltime,
timesincelastinvoke = time - lastinvoketime;
// either this is the first call, activity has stopped and we're at the
// trailing edge, the system time has gone backwards and we're treating
// it as the trailing edge, or we've hit the `maxwait` limit.
return (lastcalltime === undefined || (timesincelastcall >= wait) ||
(timesincelastcall < 0) || (maxing && timesincelastinvoke >= maxwait));
}
function timerexpired() {
var time = now();
if (shouldinvoke(time)) {
return trailingedge(time);
}
// restart the timer.
timerid = settimeout(timerexpired, remainingwait(time));
}
function trailingedge(time) {
timerid = undefined;
// only invoke if we have `lastargs` which means `func` has been
// debounced at least once.
if (trailing && lastargs) {
return invokefunc(time);
}
lastargs = lastthis = undefined;
return result;
}
function cancel() {
if (timerid !== undefined) {
cleartimeout(timerid);
}
lastinvoketime = 0;
lastargs = lastcalltime = lastthis = timerid = undefined;
}
function flush() {
return timerid === undefined ? result : trailingedge(now());
}
function debounced() {
var time = now(),
isinvoking = shouldinvoke(time);
lastargs = arguments;
lastthis = this;
lastcalltime = time;
if (isinvoking) {
if (timerid === undefined) {
return leadingedge(lastcalltime);
}
if (maxing) {
// handle invocations in a tight loop.
timerid = settimeout(timerexpired, wait);
return invokefunc(lastcalltime);
}
}
if (timerid === undefined) {
timerid = settimeout(timerexpired, wait);
}
return result;
}
debounced.cancel = cancel;
debounced.flush = flush;
return debounced;
}
/**
* defers invoking the `func` until the current call stack has cleared. any
* additional arguments are provided to `func` when it's invoked.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to defer.
* @param {...*} [args] the arguments to invoke `func` with.
* @returns {number} returns the timer id.
* @example
*
* _.defer(function(text) {
* console.log(text);
* }, 'deferred');
* // => logs 'deferred' after one millisecond.
*/
var defer = baserest(function(func, args) {
return basedelay(func, 1, args);
});
/**
* invokes `func` after `wait` milliseconds. any additional arguments are
* provided to `func` when it's invoked.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to delay.
* @param {number} wait the number of milliseconds to delay invocation.
* @param {...*} [args] the arguments to invoke `func` with.
* @returns {number} returns the timer id.
* @example
*
* _.delay(function(text) {
* console.log(text);
* }, 1000, 'later');
* // => logs 'later' after one second.
*/
var delay = baserest(function(func, wait, args) {
return basedelay(func, tonumber(wait) || 0, args);
});
/**
* creates a function that invokes `func` with arguments reversed.
*
* @static
* @memberof _
* @since 4.0.0
* @category function
* @param {function} func the function to flip arguments for.
* @returns {function} returns the new flipped function.
* @example
*
* var flipped = _.flip(function() {
* return _.toarray(arguments);
* });
*
* flipped('a', 'b', 'c', 'd');
* // => ['d', 'c', 'b', 'a']
*/
function flip(func) {
return createwrap(func, wrap_flip_flag);
}
/**
* creates a function that memoizes the result of `func`. if `resolver` is
* provided, it determines the cache key for storing the result based on the
* arguments provided to the memoized function. by default, the first argument
* provided to the memoized function is used as the map cache key. the `func`
* is invoked with the `this` binding of the memoized function.
*
* **note:** the cache is exposed as the `cache` property on the memoized
* function. its creation may be customized by replacing the `_.memoize.cache`
* constructor with one whose instances implement the
* [`map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object)
* method interface of `clear`, `delete`, `get`, `has`, and `set`.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to have its output memoized.
* @param {function} [resolver] the function to resolve the cache key.
* @returns {function} returns the new memoized function.
* @example
*
* var object = { 'a': 1, 'b': 2 };
* var other = { 'c': 3, 'd': 4 };
*
* var values = _.memoize(_.values);
* values(object);
* // => [1, 2]
*
* values(other);
* // => [3, 4]
*
* object.a = 2;
* values(object);
* // => [1, 2]
*
* // modify the result cache.
* values.cache.set(object, ['a', 'b']);
* values(object);
* // => ['a', 'b']
*
* // replace `_.memoize.cache`.
* _.memoize.cache = weakmap;
*/
function memoize(func, resolver) {
if (typeof func != 'function' || (resolver != null && typeof resolver != 'function')) {
throw new typeerror(func_error_text);
}
var memoized = function() {
var args = arguments,
key = resolver ? resolver.apply(this, args) : args[0],
cache = memoized.cache;
if (cache.has(key)) {
return cache.get(key);
}
var result = func.apply(this, args);
memoized.cache = cache.set(key, result) || cache;
return result;
};
memoized.cache = new (memoize.cache || mapcache);
return memoized;
}
// expose `mapcache`.
memoize.cache = mapcache;
/**
* creates a function that negates the result of the predicate `func`. the
* `func` predicate is invoked with the `this` binding and arguments of the
* created function.
*
* @static
* @memberof _
* @since 3.0.0
* @category function
* @param {function} predicate the predicate to negate.
* @returns {function} returns the new negated function.
* @example
*
* function iseven(n) {
* return n % 2 == 0;
* }
*
* _.filter([1, 2, 3, 4, 5, 6], _.negate(iseven));
* // => [1, 3, 5]
*/
function negate(predicate) {
if (typeof predicate != 'function') {
throw new typeerror(func_error_text);
}
return function() {
var args = arguments;
switch (args.length) {
case 0: return !predicate.call(this);
case 1: return !predicate.call(this, args[0]);
case 2: return !predicate.call(this, args[0], args[1]);
case 3: return !predicate.call(this, args[0], args[1], args[2]);
}
return !predicate.apply(this, args);
};
}
/**
* creates a function that is restricted to invoking `func` once. repeat calls
* to the function return the value of the first invocation. the `func` is
* invoked with the `this` binding and arguments of the created function.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to restrict.
* @returns {function} returns the new restricted function.
* @example
*
* var initialize = _.once(createapplication);
* initialize();
* initialize();
* // => `createapplication` is invoked once
*/
function once(func) {
return before(2, func);
}
/**
* creates a function that invokes `func` with its arguments transformed.
*
* @static
* @since 4.0.0
* @memberof _
* @category function
* @param {function} func the function to wrap.
* @param {...(function|function[])} [transforms=[_.identity]]
* the argument transforms.
* @returns {function} returns the new function.
* @example
*
* function doubled(n) {
* return n * 2;
* }
*
* function square(n) {
* return n * n;
* }
*
* var func = _.overargs(function(x, y) {
* return [x, y];
* }, [square, doubled]);
*
* func(9, 3);
* // => [81, 6]
*
* func(10, 5);
* // => [100, 10]
*/
var overargs = castrest(function(func, transforms) {
transforms = (transforms.length == 1 && isarray(transforms[0]))
? arraymap(transforms[0], baseunary(getiteratee()))
: arraymap(baseflatten(transforms, 1), baseunary(getiteratee()));
var funcslength = transforms.length;
return baserest(function(args) {
var index = -1,
length = nativemin(args.length, funcslength);
while (++index < length) {
args[index] = transforms[index].call(this, args[index]);
}
return apply(func, this, args);
});
});
/**
* creates a function that invokes `func` with `partials` prepended to the
* arguments it receives. this method is like `_.bind` except it does **not**
* alter the `this` binding.
*
* the `_.partial.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for partially applied arguments.
*
* **note:** this method doesn't set the "length" property of partially
* applied functions.
*
* @static
* @memberof _
* @since 0.2.0
* @category function
* @param {function} func the function to partially apply arguments to.
* @param {...*} [partials] the arguments to be partially applied.
* @returns {function} returns the new partially applied function.
* @example
*
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* var sayhelloto = _.partial(greet, 'hello');
* sayhelloto('fred');
* // => 'hello fred'
*
* // partially applied with placeholders.
* var greetfred = _.partial(greet, _, 'fred');
* greetfred('hi');
* // => 'hi fred'
*/
var partial = baserest(function(func, partials) {
var holders = replaceholders(partials, getholder(partial));
return createwrap(func, wrap_partial_flag, undefined, partials, holders);
});
/**
* this method is like `_.partial` except that partially applied arguments
* are appended to the arguments it receives.
*
* the `_.partialright.placeholder` value, which defaults to `_` in monolithic
* builds, may be used as a placeholder for partially applied arguments.
*
* **note:** this method doesn't set the "length" property of partially
* applied functions.
*
* @static
* @memberof _
* @since 1.0.0
* @category function
* @param {function} func the function to partially apply arguments to.
* @param {...*} [partials] the arguments to be partially applied.
* @returns {function} returns the new partially applied function.
* @example
*
* function greet(greeting, name) {
* return greeting + ' ' + name;
* }
*
* var greetfred = _.partialright(greet, 'fred');
* greetfred('hi');
* // => 'hi fred'
*
* // partially applied with placeholders.
* var sayhelloto = _.partialright(greet, 'hello', _);
* sayhelloto('fred');
* // => 'hello fred'
*/
var partialright = baserest(function(func, partials) {
var holders = replaceholders(partials, getholder(partialright));
return createwrap(func, wrap_partial_right_flag, undefined, partials, holders);
});
/**
* creates a function that invokes `func` with arguments arranged according
* to the specified `indexes` where the argument value at the first index is
* provided as the first argument, the argument value at the second index is
* provided as the second argument, and so on.
*
* @static
* @memberof _
* @since 3.0.0
* @category function
* @param {function} func the function to rearrange arguments for.
* @param {...(number|number[])} indexes the arranged argument indexes.
* @returns {function} returns the new function.
* @example
*
* var rearged = _.rearg(function(a, b, c) {
* return [a, b, c];
* }, [2, 0, 1]);
*
* rearged('b', 'c', 'a')
* // => ['a', 'b', 'c']
*/
var rearg = flatrest(function(func, indexes) {
return createwrap(func, wrap_rearg_flag, undefined, undefined, undefined, indexes);
});
/**
* creates a function that invokes `func` with the `this` binding of the
* created function and arguments from `start` and beyond provided as
* an array.
*
* **note:** this method is based on the
* [rest parameter](https://mdn.io/rest_parameters).
*
* @static
* @memberof _
* @since 4.0.0
* @category function
* @param {function} func the function to apply a rest parameter to.
* @param {number} [start=func.length-1] the start position of the rest parameter.
* @returns {function} returns the new function.
* @example
*
* var say = _.rest(function(what, names) {
* return what + ' ' + _.initial(names).join(', ') +
* (_.size(names) > 1 ? ', & ' : '') + _.last(names);
* });
*
* say('hello', 'fred', 'barney', 'pebbles');
* // => 'hello fred, barney, & pebbles'
*/
function rest(func, start) {
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
start = start === undefined ? start : tointeger(start);
return baserest(func, start);
}
/**
* creates a function that invokes `func` with the `this` binding of the
* create function and an array of arguments much like
* [`function#apply`](http://www.ecma-international.org/ecma-262/7.0/#sec-function.prototype.apply).
*
* **note:** this method is based on the
* [spread operator](https://mdn.io/spread_operator).
*
* @static
* @memberof _
* @since 3.2.0
* @category function
* @param {function} func the function to spread arguments over.
* @param {number} [start=0] the start position of the spread.
* @returns {function} returns the new function.
* @example
*
* var say = _.spread(function(who, what) {
* return who + ' says ' + what;
* });
*
* say(['fred', 'hello']);
* // => 'fred says hello'
*
* var numbers = promise.all([
* promise.resolve(40),
* promise.resolve(36)
* ]);
*
* numbers.then(_.spread(function(x, y) {
* return x + y;
* }));
* // => a promise of 76
*/
function spread(func, start) {
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
start = start == null ? 0 : nativemax(tointeger(start), 0);
return baserest(function(args) {
var array = args[start],
otherargs = castslice(args, 0, start);
if (array) {
arraypush(otherargs, array);
}
return apply(func, this, otherargs);
});
}
/**
* creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds. the throttled function comes with a `cancel`
* method to cancel delayed `func` invocations and a `flush` method to
* immediately invoke them. provide `options` to indicate whether `func`
* should be invoked on the leading and/or trailing edge of the `wait`
* timeout. the `func` is invoked with the last arguments provided to the
* throttled function. subsequent calls to the throttled function return the
* result of the last `func` invocation.
*
* **note:** if `leading` and `trailing` options are `true`, `func` is
* invoked on the trailing edge of the timeout only if the throttled function
* is invoked more than once during the `wait` timeout.
*
* if `wait` is `0` and `leading` is `false`, `func` invocation is deferred
* until to the next tick, similar to `settimeout` with a timeout of `0`.
*
* see [david corbacho's article](https://css-tricks.com/debouncing-throttling-explained-examples/)
* for details over the differences between `_.throttle` and `_.debounce`.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {function} func the function to throttle.
* @param {number} [wait=0] the number of milliseconds to throttle invocations to.
* @param {object} [options={}] the options object.
* @param {boolean} [options.leading=true]
* specify invoking on the leading edge of the timeout.
* @param {boolean} [options.trailing=true]
* specify invoking on the trailing edge of the timeout.
* @returns {function} returns the new throttled function.
* @example
*
* // avoid excessively updating the position while scrolling.
* jquery(window).on('scroll', _.throttle(updateposition, 100));
*
* // invoke `renewtoken` when the click event is fired, but not more than once every 5 minutes.
* var throttled = _.throttle(renewtoken, 300000, { 'trailing': false });
* jquery(element).on('click', throttled);
*
* // cancel the trailing throttled invocation.
* jquery(window).on('popstate', throttled.cancel);
*/
function throttle(func, wait, options) {
var leading = true,
trailing = true;
if (typeof func != 'function') {
throw new typeerror(func_error_text);
}
if (isobject(options)) {
leading = 'leading' in options ? !!options.leading : leading;
trailing = 'trailing' in options ? !!options.trailing : trailing;
}
return debounce(func, wait, {
'leading': leading,
'maxwait': wait,
'trailing': trailing
});
}
/**
* creates a function that accepts up to one argument, ignoring any
* additional arguments.
*
* @static
* @memberof _
* @since 4.0.0
* @category function
* @param {function} func the function to cap arguments for.
* @returns {function} returns the new capped function.
* @example
*
* _.map(['6', '8', '10'], _.unary(parseint));
* // => [6, 8, 10]
*/
function unary(func) {
return ary(func, 1);
}
/**
* creates a function that provides `value` to `wrapper` as its first
* argument. any additional arguments provided to the function are appended
* to those provided to the `wrapper`. the wrapper is invoked with the `this`
* binding of the created function.
*
* @static
* @memberof _
* @since 0.1.0
* @category function
* @param {*} value the value to wrap.
* @param {function} [wrapper=identity] the wrapper function.
* @returns {function} returns the new function.
* @example
*
* var p = _.wrap(_.escape, function(func, text) {
* return '