From c9b7762734dcfea5aac258f2d544546faac0ffe6 Mon Sep 17 00:00:00 2001 From: Andrea Scartabelli Date: Mon, 23 May 2016 14:40:03 +0200 Subject: [PATCH] version bump to 0.27.0 --- README.md | 6 +++++- dist/lamb.js | 6 +++--- dist/lamb.min.js | 4 ++-- dist/lamb.min.js.map | 2 +- package.json | 2 +- src/function.js | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index d820eb6..a8a4822 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ Lamb it's also delivered on a CDN, courtesy of [npmcdn](https://npmcdn.com/): The URL above will retrieve the latest version, but you can target a specific version too: ```html - + ``` You can [try it right now](https://tonicdev.com/npm/lamb) in your browser, too. @@ -87,6 +87,10 @@ You can refer to the [changelog](#changelog) to see if your code is affected. ## Changelog +- **v0.27.0 - *2016/05/23*** + - **API change**: renamed `insert` to `sortedInsert` + - Added `insert`, `insertAt`, `reduceWith` and `reduceRightWith` + - **v0.26.0 - *2016/05/16*** - **Fully compatible with versions down to 0.25.x** - Added `rename`, `renameKeys` and `renameWith` diff --git a/dist/lamb.js b/dist/lamb.js index d7b63a4..646be30 100644 --- a/dist/lamb.js +++ b/dist/lamb.js @@ -1,7 +1,7 @@ /** * @overview lamb - A lightweight, and docile, JavaScript library to help embracing functional programming. * @author Andrea Scartabelli - * @version 0.27.0-alpha.3 + * @version 0.27.0 * @module lamb * @license MIT * @preserve @@ -18,7 +18,7 @@ * @category Core * @type String */ - lamb._version = "0.27.0-alpha.3"; + lamb._version = "0.27.0"; // alias used as a placeholder argument for partial application var _ = lamb; @@ -3430,7 +3430,7 @@ /** * Builds a function that allows to map over the received arguments before applying them to the original one. * @example - * var sumArray = _.invoker("reduce", _.add); + * var sumArray = _.reduceWith(_.add); * var sum = _.compose(sumArray, _.list); * * sum(1, 2, 3, 4, 5) // => 15 diff --git a/dist/lamb.min.js b/dist/lamb.min.js index c64177f..1a9128e 100644 --- a/dist/lamb.min.js +++ b/dist/lamb.min.js @@ -1,10 +1,10 @@ /** * @overview lamb - A lightweight, and docile, JavaScript library to help embracing functional programming. * @author Andrea Scartabelli - * @version 0.27.0-alpha.3 + * @version 0.27.0 * @module lamb * @license MIT * @preserve */ -!function(n){"use strict";function r(n){return function(){return n}}function t(){var n=arguments;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}}function e(n){return n}function u(n){var r=Tr(arguments,1);return function(){for(var t,e=0,u=[],i=r.length,o=0;i>o;o++)t=r[o],u[o]=t===Ar?arguments[e++]:t;for(var c=arguments.length;c>e;e++)u.push(arguments[e]);return n.apply(this,u)}}function i(){var n=Tr(arguments);return function(){for(var r,t=n.length,e=0;t>e&&(r=Bn(n[e],arguments),E(r));e++);return r}}function o(){var n=Tr(arguments);return function(){var r=arguments;return n.every(function(n){return n.apply(null,r)})}}function c(){var n=Tr(arguments);return function(){var r=arguments;return n.some(function(n){return n.apply(null,r)})}}function f(n,r,t){return function(){var e=it(arguments);return e(n)?e(r):t?e(t):void 0}}function a(n,r){return 0===n&&0===r?1/n===1/r:v(n,r)}function l(n,r){return n>r}function p(n,r){return n>=r}function s(n,r){return r>n}function h(n,r){return r>=n}function v(n,r){return n!==n?r!==r:n===r}function d(n){return function(){return!n.apply(null,arguments)}}function g(n,r){return n+r}function y(n,r,t){return r>n?r:n>t?t:n}function m(n,r){return n/r}function b(n,r,t,e){for(var u=[n],i=0,o=r-1;o>i;i++)u.push(t.call(e,u[i],i,u));return u}function O(n,r){return n-r*Math.floor(n/r)}function k(n,r){return n*r}function x(n,r){return Math.floor(Math.random()*(r-n+1)+n)}function I(n,r,t){if(0===t||arguments.length<2)return[n];t||(t=1);var e=Math.max(Math.ceil((r-n)/t),0);return b(n,e,u(g,t))}function A(n,r){return n%r}function j(n,r){return n-r}function w(n){return null===n}function W(n){return function(r){return M(r)===n}}function E(n){return void 0===n}function M(n){return wr.toString.call(n).replace(/^\[\w+\s+|\]$/g,"")}function P(n,r){return T(n)&&T(r)&&y(n,-r,r-1)===n?0>n?n+r:n:void 0}function K(n,r){for(var t,e,u=n,i=-1,o=r.length;++ii;i++)if(u=n[i],r.call(t,u,i,n)){e=u;break}return e}function un(n,r,t){for(var e=-1,u=0,i=n.length;i>u;u++)if(r.call(t,n[u],u,n)){e=u;break}return e}function on(n,r){return u($r,Ar,n,r)}function cn(n){return X(n,[])}function fn(n,r,t){var e=Tr(n);return e.splice(r,0,t),e}function an(n,r){return u(fn,Ar,n,r)}function ln(){var n=Tr(arguments,1);return An(arguments[0]).filter(function(r){return n.every(Y(r))})}function pn(n,r,t){for(var e=!1,u=t>>>0,i=n.length;i>u;u++)if(v(r,n[u])){e=!0;break}return e}function sn(){return 1===arguments.length?[arguments[0]]:Array.apply(null,arguments)}function hn(n,r){return u(Kr,Ar,n,r)}function vn(n,r,t){for(var e,u=[[],[]],i=n.length,o=0;i>o;o++)e=n[o],u[r.call(t,e,o,n)?0:1].push(e);return u}function dn(n,r){return u(vn,Ar,n,r)}function gn(n,r){return Kr(n,Sr(r))}function yn(n){return hn(Sr(n))}function mn(n,r){var t=2===arguments.length?Rr:Gn(Rr);return u(t,Ar,n,r)}function bn(n,r){var t=2===arguments.length?Nr:Gn(Nr);return u(t,Ar,n,r)}function On(n){return Tr(n).reverse()}function kn(n){return jr.concat.apply([],n)}function xn(n,r){return function(t){return Tr(t,0,Q(t,n,r))}}function In(n){for(var r,t=[],e=Bn(Math.min,gn(n,"length"))>>>0,u=n.length,i=0;e>i;i++)for(t.push([]),r=0;u>r;r++)t[i][r]=n[r][i];return t}function An(n,r,t){"function"!=typeof r&&(r=e);for(var u,i=[],o=[],c=0,f=n.length;f>c;c++)u=r.call(t,n[c],c,n),pn(o,u)||(o.push(u),i.push(n[c]));return i}function jn(n,r){return function(t,e,u){return Nr(t,function(i,o,c){var f=e.call(u,o,c,t),a=n(f in i?i[f]:r,o);return i[f]=a,i},{})}}function wn(n,r){return u(nt,Ar,n,r)}function Wn(n,r){return u(rt,Ar,n,r)}function En(n,r){return u(tt,Ar,n,r)}function Mn(n,r){var t=0;return typeof n!=typeof r&&(n=String(n),r=String(r)),v(n,r)||(n>r||n!==n?t=1:(r>n||r!==r)&&(t=-1)),t}function Pn(n){var r=n.length;return function(t,e){for(var u,i,o=0,c=0;r>c;c++)if(i=n[c],o=i.compare(t.value,e.value),0!==o){u=n[c].isDescending;break}return 0===o&&(u=n[r-1].isDescending,o=t.index-e.index),u?-o:o}}function Kn(n,r,t,e,u){if(0===n.length)return 0;var i=e+u>>1,o=t({value:r,index:i},{value:n[i],index:i});return 1>=u-e?0>o?i:i+1:0>o?Kn(n,r,t,e,i):0===o?i+1:Kn(n,r,t,i,u)}function Nn(n){return n.length?n.map(Rn):[Tn()]}function Rn(n){return"function"==typeof Object(n).compare?n:Tn(n)}function Tn(n,r,t){return{isDescending:r===!0,compare:function(r,u){return"function"==typeof n&&n!==e&&(r=n(r),u=n(u)),(t||Mn)(r,u)}}}function Vn(n){for(var r=Nn(Tr(arguments,1)),t=[],e=[],u=n.length,i=0;u>i;i++)t.push({value:n[i],index:i});for(t.sort(Pn(r)),i=0;u>i;i++)e.push(t[i].value);return e}function Dn(n,r){var t=Nn(Tr(arguments,2)),e=n.concat(),u=Kn(n,r,Pn(t),0,n.length);return e.splice(u,0,r),e}function Fn(){var n=Tr(arguments);return function(r){return Vn.apply(null,[r].concat(n))}}function zn(n,r,t,e,u){return function(){var i=u.concat(e(arguments));return i.length>=r?n.apply(this,t?i.reverse():i):zn(n,r,t,e,i)}}function Sn(n,r,t,e){var u=e?Tr:function(n){return n.length?[n[0]]:[]};return r>>>0!==r&&(r=n.length),zn(n,r,t,u,[])}function Bn(n,r){return n.apply(n,Tr(r))}function Ln(n,r){return function(){return Bn(n,Tr(arguments,0,r))}}function Gn(n){return function(r,t){return n(r,t)}}function qn(n,r){return Sn(n,r,!1)}function Un(n,r){return Sn(n,r,!0)}function Zn(n,r){return Sn(n,r,!1,!0)}function $n(n,r){return Sn(n,r,!0,!0)}function _n(n,r){var t;return function(){var e=this,u=arguments,i=function(){t=null,n.apply(e,u)};clearTimeout(t),t=setTimeout(i,r)}}function Cn(n){return function(){var r=Tr(arguments).reverse();return n.apply(this,r)}}function Hn(n){return t(zr(n),sn)}function Jn(n){var r=Tr(arguments,1);return function(t){var e=Tr(arguments,1),u=t[n];return"Function"===M(u)?u.apply(t,r.concat(e)):void 0}}function Qn(n){return function(r){var t=Tr(arguments,1),e=n[r];return"Function"===M(e)?e.apply(n,t):void 0}}function Xn(n,r){return t(u(Bn,n),hn(r),sn)}function Yn(n){var r=Tr(arguments,1);return function(){for(var t=arguments.length,e=[],u=0;t>u;u++)e.push(r[u]?r[u](arguments[u]):arguments[u]);return n.apply(this,e)}}function nr(n,r){var t,e=0;return function(){var u=Date.now();return u-e>=r&&(e=u,t=n.apply(this,arguments)),t}}function rr(n){return function(r){return n(r)}}function tr(n,r){return-1===r.indexOf(n)&&(r.push(Object.freeze(n)),Object.getOwnPropertyNames(n).forEach(function(t){var e=n[t];"object"!=typeof e||w(e)||tr(e,r)})),n}function er(n){return[n,this[n]]}function ur(n){return Nr(Tr(arguments,1),function(r,t){return Pr(n(t),function(n){r[n]=t[n]}),r},{})}function ir(n){var r=[];for(var t in n)r.push(t);return r}function or(n,r,t,e){return function(i){var o=u(B,i,Ar,e);return n.apply(i,t.map(o))?[]:[r,t]}}function cr(n){var r={};return n.forEach(function(n){r[n[0]]=n[1]}),r}function fr(n,r){return r in n}function ar(n){return tr(n,[])}function lr(n,r){for(var t={},e=r.length,u=0,i=n.length;i>u;u++)t[n[u]]=e>u?r[u]:void 0;return t}function pr(n,r){var t={};return r.forEach(function(r){r in n&&(t[r]=n[r])}),t}function sr(n,r){return function(t){var e={};for(var u in t)n.call(r,t[u],u,t)&&(e[u]=t[u]);return e}}function hr(n,r){r=Object(r);var t={},e=ht(n);for(var u in r)~e.indexOf(u)&&(t[r[u]]=n[u]);for(var i,o=0,c=e.length;c>o;o++)i=e[o],i in r||i in t||(t[i]=n[i]);return t}function vr(n){return function(r){return hr(r,n(r))}}function dr(n,r){var t={};for(var e in n)-1===r.indexOf(e)&&(t[e]=n[e]);return t}function gr(n,r){return sr(d(n),r)}function yr(n,r){return r.reduce(function(r,t){var e=t(n);return e.length&&r.push(e),r},[])}function mr(n,r,t){return kr(r[0]||" ",Math.ceil(t-n.length))}function br(n,r,t){return mr(n,r,t)+n}function Or(n,r,t){return n+mr(n,r,t)}function kr(n,r){for(var t="",e=0;r>e;e++)t+=n;return t}function xr(n){return Wr.test.bind(n)}var Ir=Object.create(null);Ir._version="0.27.0-alpha.3";var Ar=Ir,jr=Array.prototype,wr=Object.prototype,Wr=RegExp.prototype,Er=Function.bind.bind(Function.call);Ir.always=r,Ir.compose=t,Ir.generic=Er,Ir.identity=e,Ir.partial=u;var Mr=Er(jr.filter),Pr=Er(jr.forEach),Kr=Er(jr.map),Nr=Er(jr.reduce),Rr=Er(jr.reduceRight),Tr=Er(jr.slice);Ir.filter=Mr,Ir.forEach=Pr,Ir.map=Kr,Ir.reduce=Nr,Ir.reduceRight=Rr,Ir.slice=Tr;var Vr=d(a);Ir.adapter=i,Ir.allOf=o,Ir.anyOf=c,Ir.condition=f,Ir.is=a,Ir.isGT=l,Ir.isGTE=p,Ir.isLT=s,Ir.isLTE=h,Ir.isNot=Vr,Ir.isSVZ=v,Ir.not=d,Ir.add=g,Ir.clamp=y,Ir.divide=m,Ir.generate=b,Ir.modulo=O,Ir.multiply=k,Ir.randomInt=x,Ir.range=I,Ir.remainder=A,Ir.subtract=j;var Dr=c(w,E);Ir.isNil=Dr,Ir.isNull=w,Ir.isType=W,Ir.isUndefined=E,Ir.type=M;var Fr=Er(wr.propertyIsEnumerable),zr=Sn(z,2,!0),Sr=Sn(F,2,!0),Br=zr(0),Lr=zr(-1),Gr=Ln(V,3),qr=u(V,Ar,Ar,null);Ir.getAt=zr,Ir.getIn=F,Ir.getIndex=z,Ir.getKey=Sr,Ir.getPath=S,Ir.getPathIn=B,Ir.head=Br,Ir.last=Lr,Ir.setAt=L,Ir.setIn=G,Ir.setIndex=Gr,Ir.setKey=q,Ir.setPath=U,Ir.setPathIn=Z,Ir.updateAt=$,Ir.updateIn=_,Ir.updateIndex=qr,Ir.updateKey=C,Ir.updatePath=H,Ir.updatePathIn=J;var Ur=Gn(Tr),Zr=Sn(Ur,2,!0),$r=t(kn,Kr),_r=u(Tr,Ar,0,-1),Cr=u(Tr,Ar,1,void 0),Hr=u(Tr,Ar,0,Ar),Jr=Sn(Hr,2,!0),Qr=t(An,on(rr(Tr)),sn),Xr=t(In,sn),Yr=hn(Gn(sn));Ir.contains=Y,Ir.difference=nn,Ir.drop=Ur,Ir.dropN=Zr,Ir.dropWhile=rn,Ir.filterWith=tn,Ir.find=en,Ir.findIndex=un,Ir.flatMap=$r,Ir.flatMapWith=on,Ir.flatten=cn,Ir.init=_r,Ir.insert=fn,Ir.insertAt=an,Ir.intersection=ln,Ir.isIn=pn,Ir.list=sn,Ir.mapWith=hn,Ir.partition=vn,Ir.partitionWith=dn,Ir.pluck=gn,Ir.pluckKey=yn,Ir.reduceRightWith=mn,Ir.reduceWith=bn,Ir.reverse=On,Ir.shallowFlatten=kn,Ir.tail=Cr,Ir.take=Hr,Ir.takeN=Jr,Ir.takeWhile=xn,Ir.transpose=In,Ir.union=Qr,Ir.uniques=An,Ir.zip=Xr,Ir.zipWithIndex=Yr;var nt=jn(u(g,1),0),rt=jn(Jn("concat"),[]),tt=jn(Hn(1));Ir.count=nt,Ir.countBy=wn,Ir.group=rt,Ir.groupBy=Wn,Ir.index=tt,Ir.indexBy=En;var et=u(Tn,Ar,!1,Ar),ut=u(Tn,Ar,!0,Ar);Ir.sort=Vn,Ir.sortedInsert=Dn,Ir.sorter=et,Ir.sorterDesc=ut,Ir.sortWith=Fn;var it=Sn(Bn,2,!0),ot=Cn(t),ct=Gn(Cn(u));Ir.apply=Bn,Ir.applyArgs=it,Ir.aritize=Ln,Ir.binary=Gn,Ir.curry=qn,Ir.curryRight=Un,Ir.curryable=Zn,Ir.curryableRight=$n,Ir.debounce=_n,Ir.flip=Cn,Ir.getArgAt=Hn,Ir.invoker=Jn,Ir.invokerOn=Qn,Ir.mapArgs=Xn,Ir.pipe=ot,Ir.tapArgs=Yn,Ir.throttle=nr,Ir.unary=rr,Ir.wrap=ct;var ft=Sn(function(n,r){return n(r).map(er,r)}),at=t(Object.keys,Object),lt=Sn(function(n,r){return n(r).reduce(function(n,t){return n[0].push(t),n[1].push(r[t]),n},[[],[]])}),pt=Sn(function(n,r){return(Dr(r)?Object.keys:n)(r)}),st=Sn(function(n,r){return n(r).map(u(F,r))}),ht=pt(ir),vt=Sn(fr,2,!0),dt=function(n,r){return t(u(a,r),Sr(n))},gt=Er(wr.hasOwnProperty),yt=Sn(gt,2,!0),mt=pt(at),bt=u(ur,ir),Ot=u(ur,at),kt=ft(mt),xt=st(mt),It=ft(ht),At=Sn(hr,2,!0),jt=lt(ht),wt=lt(mt),Wt=Sn(yr,2,!0),Et=st(ht);Ir.checker=or,Ir.enumerables=ht,Ir.fromPairs=cr,Ir.has=fr,Ir.hasKey=vt,Ir.hasKeyValue=dt,Ir.hasOwn=gt,Ir.hasOwnKey=yt,Ir.immutable=ar,Ir.keys=mt,Ir.make=lr,Ir.merge=bt,Ir.mergeOwn=Ot,Ir.ownPairs=kt,Ir.ownValues=xt,Ir.pairs=It,Ir.pick=pr,Ir.pickIf=sr,Ir.rename=hr,Ir.renameKeys=At,Ir.renameWith=vr,Ir.skip=dr,Ir.skipIf=gr,Ir.tear=jt,Ir.tearOwn=wt,Ir.validate=yr,Ir.validateWith=Wt,Ir.values=Et,Ir.padLeft=br,Ir.padRight=Or,Ir.repeat=kr,Ir.testWith=xr,"object"==typeof exports?module.exports=Ir:"function"==typeof define&&define.amd?define(function(){return Ir}):n.lamb=Ir}(this); +!function(n){"use strict";function r(n){return function(){return n}}function t(){var n=arguments;return function(){for(var r=arguments,t=n.length;t--;)r=[n[t].apply(this,r)];return r[0]}}function e(n){return n}function u(n){var r=Tr(arguments,1);return function(){for(var t,e=0,u=[],i=r.length,o=0;i>o;o++)t=r[o],u[o]=t===Ar?arguments[e++]:t;for(var c=arguments.length;c>e;e++)u.push(arguments[e]);return n.apply(this,u)}}function i(){var n=Tr(arguments);return function(){for(var r,t=n.length,e=0;t>e&&(r=Bn(n[e],arguments),E(r));e++);return r}}function o(){var n=Tr(arguments);return function(){var r=arguments;return n.every(function(n){return n.apply(null,r)})}}function c(){var n=Tr(arguments);return function(){var r=arguments;return n.some(function(n){return n.apply(null,r)})}}function f(n,r,t){return function(){var e=it(arguments);return e(n)?e(r):t?e(t):void 0}}function a(n,r){return 0===n&&0===r?1/n===1/r:v(n,r)}function l(n,r){return n>r}function p(n,r){return n>=r}function s(n,r){return r>n}function h(n,r){return r>=n}function v(n,r){return n!==n?r!==r:n===r}function d(n){return function(){return!n.apply(null,arguments)}}function g(n,r){return n+r}function y(n,r,t){return r>n?r:n>t?t:n}function m(n,r){return n/r}function b(n,r,t,e){for(var u=[n],i=0,o=r-1;o>i;i++)u.push(t.call(e,u[i],i,u));return u}function O(n,r){return n-r*Math.floor(n/r)}function k(n,r){return n*r}function x(n,r){return Math.floor(Math.random()*(r-n+1)+n)}function I(n,r,t){if(0===t||arguments.length<2)return[n];t||(t=1);var e=Math.max(Math.ceil((r-n)/t),0);return b(n,e,u(g,t))}function A(n,r){return n%r}function j(n,r){return n-r}function w(n){return null===n}function W(n){return function(r){return M(r)===n}}function E(n){return void 0===n}function M(n){return wr.toString.call(n).replace(/^\[\w+\s+|\]$/g,"")}function P(n,r){return T(n)&&T(r)&&y(n,-r,r-1)===n?0>n?n+r:n:void 0}function K(n,r){for(var t,e,u=n,i=-1,o=r.length;++ii;i++)if(u=n[i],r.call(t,u,i,n)){e=u;break}return e}function un(n,r,t){for(var e=-1,u=0,i=n.length;i>u;u++)if(r.call(t,n[u],u,n)){e=u;break}return e}function on(n,r){return u($r,Ar,n,r)}function cn(n){return X(n,[])}function fn(n,r,t){var e=Tr(n);return e.splice(r,0,t),e}function an(n,r){return u(fn,Ar,n,r)}function ln(){var n=Tr(arguments,1);return An(arguments[0]).filter(function(r){return n.every(Y(r))})}function pn(n,r,t){for(var e=!1,u=t>>>0,i=n.length;i>u;u++)if(v(r,n[u])){e=!0;break}return e}function sn(){return 1===arguments.length?[arguments[0]]:Array.apply(null,arguments)}function hn(n,r){return u(Kr,Ar,n,r)}function vn(n,r,t){for(var e,u=[[],[]],i=n.length,o=0;i>o;o++)e=n[o],u[r.call(t,e,o,n)?0:1].push(e);return u}function dn(n,r){return u(vn,Ar,n,r)}function gn(n,r){return Kr(n,Sr(r))}function yn(n){return hn(Sr(n))}function mn(n,r){var t=2===arguments.length?Rr:Gn(Rr);return u(t,Ar,n,r)}function bn(n,r){var t=2===arguments.length?Nr:Gn(Nr);return u(t,Ar,n,r)}function On(n){return Tr(n).reverse()}function kn(n){return jr.concat.apply([],n)}function xn(n,r){return function(t){return Tr(t,0,Q(t,n,r))}}function In(n){for(var r,t=[],e=Bn(Math.min,gn(n,"length"))>>>0,u=n.length,i=0;e>i;i++)for(t.push([]),r=0;u>r;r++)t[i][r]=n[r][i];return t}function An(n,r,t){"function"!=typeof r&&(r=e);for(var u,i=[],o=[],c=0,f=n.length;f>c;c++)u=r.call(t,n[c],c,n),pn(o,u)||(o.push(u),i.push(n[c]));return i}function jn(n,r){return function(t,e,u){return Nr(t,function(i,o,c){var f=e.call(u,o,c,t),a=n(f in i?i[f]:r,o);return i[f]=a,i},{})}}function wn(n,r){return u(nt,Ar,n,r)}function Wn(n,r){return u(rt,Ar,n,r)}function En(n,r){return u(tt,Ar,n,r)}function Mn(n,r){var t=0;return typeof n!=typeof r&&(n=String(n),r=String(r)),v(n,r)||(n>r||n!==n?t=1:(r>n||r!==r)&&(t=-1)),t}function Pn(n){var r=n.length;return function(t,e){for(var u,i,o=0,c=0;r>c;c++)if(i=n[c],o=i.compare(t.value,e.value),0!==o){u=n[c].isDescending;break}return 0===o&&(u=n[r-1].isDescending,o=t.index-e.index),u?-o:o}}function Kn(n,r,t,e,u){if(0===n.length)return 0;var i=e+u>>1,o=t({value:r,index:i},{value:n[i],index:i});return 1>=u-e?0>o?i:i+1:0>o?Kn(n,r,t,e,i):0===o?i+1:Kn(n,r,t,i,u)}function Nn(n){return n.length?n.map(Rn):[Tn()]}function Rn(n){return"function"==typeof Object(n).compare?n:Tn(n)}function Tn(n,r,t){return{isDescending:r===!0,compare:function(r,u){return"function"==typeof n&&n!==e&&(r=n(r),u=n(u)),(t||Mn)(r,u)}}}function Vn(n){for(var r=Nn(Tr(arguments,1)),t=[],e=[],u=n.length,i=0;u>i;i++)t.push({value:n[i],index:i});for(t.sort(Pn(r)),i=0;u>i;i++)e.push(t[i].value);return e}function Dn(n,r){var t=Nn(Tr(arguments,2)),e=n.concat(),u=Kn(n,r,Pn(t),0,n.length);return e.splice(u,0,r),e}function Fn(){var n=Tr(arguments);return function(r){return Vn.apply(null,[r].concat(n))}}function zn(n,r,t,e,u){return function(){var i=u.concat(e(arguments));return i.length>=r?n.apply(this,t?i.reverse():i):zn(n,r,t,e,i)}}function Sn(n,r,t,e){var u=e?Tr:function(n){return n.length?[n[0]]:[]};return r>>>0!==r&&(r=n.length),zn(n,r,t,u,[])}function Bn(n,r){return n.apply(n,Tr(r))}function Ln(n,r){return function(){return Bn(n,Tr(arguments,0,r))}}function Gn(n){return function(r,t){return n(r,t)}}function qn(n,r){return Sn(n,r,!1)}function Un(n,r){return Sn(n,r,!0)}function Zn(n,r){return Sn(n,r,!1,!0)}function $n(n,r){return Sn(n,r,!0,!0)}function _n(n,r){var t;return function(){var e=this,u=arguments,i=function(){t=null,n.apply(e,u)};clearTimeout(t),t=setTimeout(i,r)}}function Cn(n){return function(){var r=Tr(arguments).reverse();return n.apply(this,r)}}function Hn(n){return t(zr(n),sn)}function Jn(n){var r=Tr(arguments,1);return function(t){var e=Tr(arguments,1),u=t[n];return"Function"===M(u)?u.apply(t,r.concat(e)):void 0}}function Qn(n){return function(r){var t=Tr(arguments,1),e=n[r];return"Function"===M(e)?e.apply(n,t):void 0}}function Xn(n,r){return t(u(Bn,n),hn(r),sn)}function Yn(n){var r=Tr(arguments,1);return function(){for(var t=arguments.length,e=[],u=0;t>u;u++)e.push(r[u]?r[u](arguments[u]):arguments[u]);return n.apply(this,e)}}function nr(n,r){var t,e=0;return function(){var u=Date.now();return u-e>=r&&(e=u,t=n.apply(this,arguments)),t}}function rr(n){return function(r){return n(r)}}function tr(n,r){return-1===r.indexOf(n)&&(r.push(Object.freeze(n)),Object.getOwnPropertyNames(n).forEach(function(t){var e=n[t];"object"!=typeof e||w(e)||tr(e,r)})),n}function er(n){return[n,this[n]]}function ur(n){return Nr(Tr(arguments,1),function(r,t){return Pr(n(t),function(n){r[n]=t[n]}),r},{})}function ir(n){var r=[];for(var t in n)r.push(t);return r}function or(n,r,t,e){return function(i){var o=u(B,i,Ar,e);return n.apply(i,t.map(o))?[]:[r,t]}}function cr(n){var r={};return n.forEach(function(n){r[n[0]]=n[1]}),r}function fr(n,r){return r in n}function ar(n){return tr(n,[])}function lr(n,r){for(var t={},e=r.length,u=0,i=n.length;i>u;u++)t[n[u]]=e>u?r[u]:void 0;return t}function pr(n,r){var t={};return r.forEach(function(r){r in n&&(t[r]=n[r])}),t}function sr(n,r){return function(t){var e={};for(var u in t)n.call(r,t[u],u,t)&&(e[u]=t[u]);return e}}function hr(n,r){r=Object(r);var t={},e=ht(n);for(var u in r)~e.indexOf(u)&&(t[r[u]]=n[u]);for(var i,o=0,c=e.length;c>o;o++)i=e[o],i in r||i in t||(t[i]=n[i]);return t}function vr(n){return function(r){return hr(r,n(r))}}function dr(n,r){var t={};for(var e in n)-1===r.indexOf(e)&&(t[e]=n[e]);return t}function gr(n,r){return sr(d(n),r)}function yr(n,r){return r.reduce(function(r,t){var e=t(n);return e.length&&r.push(e),r},[])}function mr(n,r,t){return kr(r[0]||" ",Math.ceil(t-n.length))}function br(n,r,t){return mr(n,r,t)+n}function Or(n,r,t){return n+mr(n,r,t)}function kr(n,r){for(var t="",e=0;r>e;e++)t+=n;return t}function xr(n){return Wr.test.bind(n)}var Ir=Object.create(null);Ir._version="0.27.0";var Ar=Ir,jr=Array.prototype,wr=Object.prototype,Wr=RegExp.prototype,Er=Function.bind.bind(Function.call);Ir.always=r,Ir.compose=t,Ir.generic=Er,Ir.identity=e,Ir.partial=u;var Mr=Er(jr.filter),Pr=Er(jr.forEach),Kr=Er(jr.map),Nr=Er(jr.reduce),Rr=Er(jr.reduceRight),Tr=Er(jr.slice);Ir.filter=Mr,Ir.forEach=Pr,Ir.map=Kr,Ir.reduce=Nr,Ir.reduceRight=Rr,Ir.slice=Tr;var Vr=d(a);Ir.adapter=i,Ir.allOf=o,Ir.anyOf=c,Ir.condition=f,Ir.is=a,Ir.isGT=l,Ir.isGTE=p,Ir.isLT=s,Ir.isLTE=h,Ir.isNot=Vr,Ir.isSVZ=v,Ir.not=d,Ir.add=g,Ir.clamp=y,Ir.divide=m,Ir.generate=b,Ir.modulo=O,Ir.multiply=k,Ir.randomInt=x,Ir.range=I,Ir.remainder=A,Ir.subtract=j;var Dr=c(w,E);Ir.isNil=Dr,Ir.isNull=w,Ir.isType=W,Ir.isUndefined=E,Ir.type=M;var Fr=Er(wr.propertyIsEnumerable),zr=Sn(z,2,!0),Sr=Sn(F,2,!0),Br=zr(0),Lr=zr(-1),Gr=Ln(V,3),qr=u(V,Ar,Ar,null);Ir.getAt=zr,Ir.getIn=F,Ir.getIndex=z,Ir.getKey=Sr,Ir.getPath=S,Ir.getPathIn=B,Ir.head=Br,Ir.last=Lr,Ir.setAt=L,Ir.setIn=G,Ir.setIndex=Gr,Ir.setKey=q,Ir.setPath=U,Ir.setPathIn=Z,Ir.updateAt=$,Ir.updateIn=_,Ir.updateIndex=qr,Ir.updateKey=C,Ir.updatePath=H,Ir.updatePathIn=J;var Ur=Gn(Tr),Zr=Sn(Ur,2,!0),$r=t(kn,Kr),_r=u(Tr,Ar,0,-1),Cr=u(Tr,Ar,1,void 0),Hr=u(Tr,Ar,0,Ar),Jr=Sn(Hr,2,!0),Qr=t(An,on(rr(Tr)),sn),Xr=t(In,sn),Yr=hn(Gn(sn));Ir.contains=Y,Ir.difference=nn,Ir.drop=Ur,Ir.dropN=Zr,Ir.dropWhile=rn,Ir.filterWith=tn,Ir.find=en,Ir.findIndex=un,Ir.flatMap=$r,Ir.flatMapWith=on,Ir.flatten=cn,Ir.init=_r,Ir.insert=fn,Ir.insertAt=an,Ir.intersection=ln,Ir.isIn=pn,Ir.list=sn,Ir.mapWith=hn,Ir.partition=vn,Ir.partitionWith=dn,Ir.pluck=gn,Ir.pluckKey=yn,Ir.reduceRightWith=mn,Ir.reduceWith=bn,Ir.reverse=On,Ir.shallowFlatten=kn,Ir.tail=Cr,Ir.take=Hr,Ir.takeN=Jr,Ir.takeWhile=xn,Ir.transpose=In,Ir.union=Qr,Ir.uniques=An,Ir.zip=Xr,Ir.zipWithIndex=Yr;var nt=jn(u(g,1),0),rt=jn(Jn("concat"),[]),tt=jn(Hn(1));Ir.count=nt,Ir.countBy=wn,Ir.group=rt,Ir.groupBy=Wn,Ir.index=tt,Ir.indexBy=En;var et=u(Tn,Ar,!1,Ar),ut=u(Tn,Ar,!0,Ar);Ir.sort=Vn,Ir.sortedInsert=Dn,Ir.sorter=et,Ir.sorterDesc=ut,Ir.sortWith=Fn;var it=Sn(Bn,2,!0),ot=Cn(t),ct=Gn(Cn(u));Ir.apply=Bn,Ir.applyArgs=it,Ir.aritize=Ln,Ir.binary=Gn,Ir.curry=qn,Ir.curryRight=Un,Ir.curryable=Zn,Ir.curryableRight=$n,Ir.debounce=_n,Ir.flip=Cn,Ir.getArgAt=Hn,Ir.invoker=Jn,Ir.invokerOn=Qn,Ir.mapArgs=Xn,Ir.pipe=ot,Ir.tapArgs=Yn,Ir.throttle=nr,Ir.unary=rr,Ir.wrap=ct;var ft=Sn(function(n,r){return n(r).map(er,r)}),at=t(Object.keys,Object),lt=Sn(function(n,r){return n(r).reduce(function(n,t){return n[0].push(t),n[1].push(r[t]),n},[[],[]])}),pt=Sn(function(n,r){return(Dr(r)?Object.keys:n)(r)}),st=Sn(function(n,r){return n(r).map(u(F,r))}),ht=pt(ir),vt=Sn(fr,2,!0),dt=function(n,r){return t(u(a,r),Sr(n))},gt=Er(wr.hasOwnProperty),yt=Sn(gt,2,!0),mt=pt(at),bt=u(ur,ir),Ot=u(ur,at),kt=ft(mt),xt=st(mt),It=ft(ht),At=Sn(hr,2,!0),jt=lt(ht),wt=lt(mt),Wt=Sn(yr,2,!0),Et=st(ht);Ir.checker=or,Ir.enumerables=ht,Ir.fromPairs=cr,Ir.has=fr,Ir.hasKey=vt,Ir.hasKeyValue=dt,Ir.hasOwn=gt,Ir.hasOwnKey=yt,Ir.immutable=ar,Ir.keys=mt,Ir.make=lr,Ir.merge=bt,Ir.mergeOwn=Ot,Ir.ownPairs=kt,Ir.ownValues=xt,Ir.pairs=It,Ir.pick=pr,Ir.pickIf=sr,Ir.rename=hr,Ir.renameKeys=At,Ir.renameWith=vr,Ir.skip=dr,Ir.skipIf=gr,Ir.tear=jt,Ir.tearOwn=wt,Ir.validate=yr,Ir.validateWith=Wt,Ir.values=Et,Ir.padLeft=br,Ir.padRight=Or,Ir.repeat=kr,Ir.testWith=xr,"object"==typeof exports?module.exports=Ir:"function"==typeof define&&define.amd?define(function(){return Ir}):n.lamb=Ir}(this); //# sourceMappingURL=lamb.min.js.map diff --git a/dist/lamb.min.js.map b/dist/lamb.min.js.map index 476086a..258056d 100644 --- a/dist/lamb.min.js.map +++ b/dist/lamb.min.js.map @@ -1 +1 @@ -{"version":3,"sources":["lamb.js"],"names":["host","always","value","compose","functions","arguments","args","len","length","apply","this","identity","partial","fn","slice","boundArg","lastArgumentIdx","newArgs","argsLen","i","_","push","adapter","result","isUndefined","allOf","predicates","every","predicate","anyOf","some","condition","trueFn","falseFn","applyArgsTo","applyArgs","is","a","b","isSVZ","isGT","isGTE","isLT","isLTE","not","add","clamp","n","min","max","divide","generate","start","iteratee","iterateeContext","limit","call","modulo","Math","floor","multiply","randomInt","random","range","step","ceil","remainder","subtract","isNull","isType","typeName","type","_objectProto","toString","replace","_getNaturalIndex","index","_isInteger","_getPathInfo","obj","parts","currentKey","idx","target","_isIndex","_isEnumerable","isValid","key","Array","isArray","parseInt","Object","_isOwnEnumerable","_safeEnumerables","indexOf","_setIndex","arrayLike","updater","_setPathIn","v","setIn","getIn","getIndex","getPath","path","separator","getPathIn","split","reduce","tapArgs","Number","setAt","source","_merge","make","setKey","setPath","setPathIn","updateAt","updateIn","updateKey","updatePath","updatePathIn","pathInfo","_findSliceEndIndex","predicateContext","_flatten","array","output","forEach","contains","fromIndex","isIn","difference","rest","shallowFlatten","isInRest","filter","dropWhile","filterWith","find","element","findIndex","flatMapWith","flatMap","flatten","insert","splice","insertAt","intersection","uniques","item","list","mapWith","map","partition","el","partitionWith","pluck","getKey","pluckKey","reduceRightWith","accumulator","initialValue","reduceRight","binary","reduceWith","reverse","_arrayProto","concat","takeWhile","transpose","j","minLen","seen","_groupWith","makeValue","startValue","countBy","count","groupBy","group","indexBy","_comparer","String","_compareWith","criteria","isDescSort","criterion","compare","isDescending","_getInsertionIndex","comparer","end","pivot","_makeCriteria","sorters","_makeCriterion","_sorter","reader","sort","data","sortedInsert","sortWith","_currier","arity","isRightCurry","slicer","argsHolder","_curry","isAutoCurry","aritize","curry","curryRight","curryable","curryableRight","debounce","timespan","timeoutID","context","debounced","clearTimeout","setTimeout","flip","getArgAt","getAt","invoker","methodName","boundArgs","method","invokerOn","mapArgs","mapper","tappers","throttle","lastCall","now","Date","unary","_immutable","freeze","getOwnPropertyNames","_keyToPair","getKeys","keys","checker","message","keyPaths","pathSeparator","getValues","fromPairs","pairsList","pair","has","immutable","values","valuesLen","pick","whitelist","pickIf","rename","keysMap","oldKeys","enumerables","prop","renameWith","skip","blacklist","skipIf","validate","checkers","errors","_getPadding","char","repeat","padLeft","padRight","testWith","pattern","_reProto","test","bind","lamb","create","_version","prototype","RegExp","generic","Function","isNot","isNil","propertyIsEnumerable","head","last","setIndex","updateIndex","drop","dropN","init","tail","take","takeN","union","zip","zipWithIndex","sorter","sorterDesc","pipe","wrap","_pairsFrom","_safeKeys","_tearFrom","_unsafeKeyListFrom","_valuesFrom","hasKey","hasKeyValue","hasOwn","hasOwnProperty","hasOwnKey","merge","mergeOwn","ownPairs","ownValues","pairs","renameKeys","tear","tearOwn","validateWith","exports","module","define","amd"],"mappings":";;;;;;;;CAQC,SAAUA,GACP,YA4CA,SAASC,GAAQC,GACb,MAAO,YACH,MAAOA,IA4Bf,QAASC,KACL,GAAIC,GAAYC,SAEhB,OAAO,YAIH,IAHA,GAAIC,GAAOD,UACPE,EAAMH,EAAUI,OAEbD,KACHD,GAAQF,EAAUG,GAAKE,MAAMC,KAAMJ,GAGvC,OAAOA,GAAK,IAsCpB,QAASK,GAAUT,GACf,MAAOA,GAkBX,QAASU,GAASC,GACd,GAAIP,GAAOQ,GAAMT,UAAW,EAE5B,OAAO,YAKH,IAAK,GAAWU,GAJZC,EAAkB,EAClBC,KACAC,EAAUZ,EAAKE,OAEVW,EAAI,EAAiBD,EAAJC,EAAaA,IACnCJ,EAAWT,EAAKa,GAChBF,EAAQE,GAAKJ,IAAaK,GAAIf,UAAUW,KAAqBD,CAGjE,KAAK,GAAIR,GAAMF,UAAUG,OAA0BD,EAAlBS,EAAuBA,IACpDC,EAAQI,KAAKhB,UAAUW,GAG3B,OAAOH,GAAGJ,MAAMC,KAAMO,IAmK9B,QAASK,KACL,GAAIlB,GAAYU,GAAMT,UAEtB,OAAO,YAIH,IAAK,GAFDkB,GADAhB,EAAMH,EAAUI,OAGXW,EAAI,EAAOZ,EAAJY,IACZI,EAASd,GAAML,EAAUe,GAAId,WAExBmB,EAAYD,IAHIJ,KAQzB,MAAOI,IAsBf,QAASE,KACL,GAAIC,GAAaZ,GAAMT,UAEvB,OAAO,YACH,GAAIC,GAAOD,SAEX,OAAOqB,GAAWC,MAAM,SAAUC,GAC9B,MAAOA,GAAUnB,M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AAKsC,SAAWA,GAChBtC,GAAKuC,SAAWA,GAChBvC,GAAKwC,UAAYA,GACjBxC,GAAKyC,MAAQA,GACbzC,GAAKzB,KAAOA,GACZyB,GAAKvB,OAASA,GACduB,GAAKtB,OAASA,GACdsB,GAAK0C,WAAaA,GAClB1C,GAAKjB,WAAaA,GAClBiB,GAAKhB,KAAOA,GACZgB,GAAKd,OAASA,GACdc,GAAK2C,KAAOA,GACZ3C,GAAK4C,QAAUA,GACf5C,GAAKb,SAAWA,GAChBa,GAAK6C,aAAeA,GACpB7C,GAAK3B,OAASA,GA6Fd2B,GAAKP,QAAUA,GACfO,GAAKN,SAAWA,GAChBM,GAAKR,OAASA,GACdQ,GAAKL,SAAWA,GAGO,gBAAZmD,SACPC,OAAOD,QAAU9C,GACQ,kBAAXgD,SAAyBA,OAAOC,IAC9CD,OAAO,WAAa,MAAOhD,MAE3B1R,EAAK0R,KAAOA,IAElBhR","file":"lamb.min.js","sourcesContent":["/**\n * @overview lamb - A lightweight, and docile, JavaScript library to help embracing functional programming.\n * @author Andrea Scartabelli \n * @version 0.27.0-alpha.3\n * @module lamb\n * @license MIT\n * @preserve\n */\n!function (host) {\n \"use strict\";\n\n var lamb = Object.create(null);\n\n /**\n * The current module version.\n * @memberof module:lamb\n * @private\n * @category Core\n * @type String\n */\n lamb._version = \"0.27.0-alpha.3\";\n\n // alias used as a placeholder argument for partial application\n var _ = lamb;\n\n // some prototype shortcuts for internal use\n var _arrayProto = Array.prototype;\n var _objectProto = Object.prototype;\n var _reProto = RegExp.prototype;\n\n /**\n * Builds a function that returns a constant value.\n * It's actually the simplest form of the K combinator or Kestrel.\n * @example\n * var truth = _.always(true);\n *\n * truth() // => true\n * truth(false) // => true\n * truth(1, 2) // => true\n *\n * // the value being returned is actually the\n * // very same value passed to the function\n * var foo = {bar: \"baz\"};\n * var alwaysFoo = _.always(foo);\n *\n * alwaysFoo() === foo // => true\n *\n * @memberof module:lamb\n * @category Core\n * @see [SKI combinator calculus]{@link https://en.wikipedia.org/wiki/SKI_combinator_calculus}\n * @param {*} value\n * @returns {Function}\n */\n function always (value) {\n return function () {\n return value;\n };\n }\n\n /**\n * Returns a function that is the composition of the functions given as parameters.\n * Each function consumes the result of the function that follows.\n * @example\n * var sayHi = function (name) { return \"Hi, \" + name; };\n * var capitalize = function (s) {\n * return s[0].toUpperCase() + s.substr(1).toLowerCase();\n * };\n * var fixNameAndSayHi = _.compose(sayHi, capitalize);\n *\n * sayHi(\"bOb\") // => \"Hi, bOb\"\n * fixNameAndSayHi(\"bOb\") // \"Hi, Bob\"\n *\n * var getName = _.getKey(\"name\");\n * var users = [{name: \"fred\"}, {name: \"bOb\"}];\n * var sayHiToUser = _.compose(fixNameAndSayHi, getName);\n *\n * users.map(sayHiToUser) // [\"Hi, Fred\", \"Hi, Bob\"]\n *\n * @memberof module:lamb\n * @category Function\n * @param {...Function} fn\n * @returns {Function}\n */\n function compose () {\n var functions = arguments;\n\n return function () {\n var args = arguments;\n var len = functions.length;\n\n while (len--) {\n args = [functions[len].apply(this, args)];\n }\n\n return args[0];\n };\n }\n\n /**\n * Creates generic functions out of methods.\n * @memberof module:lamb\n * @category Core\n * @author A very little change on a great idea by [Irakli Gozalishvili]{@link https://github.com/Gozala/}. Thanks for this *beautiful* one-liner (never liked your \"unbind\" naming choice, though).\n * @function\n * @example\n * // Lamb's \"filter\" is actually implemented like this\n * var filter = _.generic(Array.prototype.filter);\n * var isLowerCase = function (s) { return s.toLowerCase() === s; };\n *\n * filter([\"Foo\", \"bar\", \"baZ\"], isLowerCase) // => [\"bar\"]\n *\n * // the function will work with any array-like object\n * filter(\"fooBAR\", isLowerCase) // => [\"f\", \"o\", \"o\"]\n *\n * @param {Function} method\n * @returns {Function}\n */\n var generic = Function.bind.bind(Function.call);\n\n /**\n * The I combinator. Any value passed to the function is simply returned as it is.\n * @example\n * var foo = {bar: \"baz\"};\n *\n * _.identity(foo) === foo // true\n *\n * @memberof module:lamb\n * @category Core\n * @see [SKI combinator calculus]{@link https://en.wikipedia.org/wiki/SKI_combinator_calculus}\n * @param {*} value\n * @returns {*} The value passed as parameter.\n */\n function identity (value) {\n return value;\n }\n\n /**\n * Builds a partially applied function. The lamb object itself can be used as a placeholder argument:\n * it's useful to alias it as _ or __.\n * @example\n * var weights = [\"2 Kg\", \"10 Kg\", \"1 Kg\", \"7 Kg\"];\n * var parseInt10 = _.partial(parseInt, _, 10);\n *\n * weights.map(parseInt10) // => [2, 10, 1, 7]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {...*} args\n * @returns {Function}\n */\n function partial (fn) {\n var args = slice(arguments, 1);\n\n return function () {\n var lastArgumentIdx = 0;\n var newArgs = [];\n var argsLen = args.length;\n\n for (var i = 0, boundArg; i < argsLen; i++) {\n boundArg = args[i];\n newArgs[i] = boundArg === _ ? arguments[lastArgumentIdx++] : boundArg;\n }\n\n for (var len = arguments.length; lastArgumentIdx < len; lastArgumentIdx++) {\n newArgs.push(arguments[lastArgumentIdx]);\n }\n\n return fn.apply(this, newArgs);\n };\n }\n\n lamb.always = always;\n lamb.compose = compose;\n lamb.generic = generic;\n lamb.identity = identity;\n lamb.partial = partial;\n\n\n /**\n * Builds an array comprised of all values of the array-like object passing the predicate test.
\n * It's a generic version of [Array.prototype.filter]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter}.\n * @example\n * var isLowerCase = function (s) { return s.toLowerCase() === s; };\n *\n * _.filter([\"Foo\", \"bar\", \"baZ\"], isLowerCase) // => [\"bar\"]\n *\n * // the function will work with any array-like object\n * _.filter(\"fooBAR\", isLowerCase) // => [\"f\", \"o\", \"o\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.filterWith|filterWith}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Array}\n */\n var filter = generic(_arrayProto.filter);\n\n /**\n * Executes the provided iteratee for each element of the given array-like object.
\n * It's a generic version of [Array.prototype.forEach]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach}.\n * @example Adding a CSS class to all elements of a NodeList in a browser environment\n * var addClass = function (className) {\n * return function (element) {\n * element.classList.add(className);\n * };\n * };\n * var paragraphs = document.querySelectorAll(\"#some-container p\");\n *\n * _.forEach(paragraphs, addClass(\"main\"));\n * // each \"p\" element in the container will have the \"main\" class now\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n */\n var forEach = generic(_arrayProto.forEach);\n\n /**\n * Creates an array from the results of the provided iteratee.
\n * It's a generic version of [Array.prototype.map]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map}.\n * @example\n * function getSquareRoots () {\n * return _.map(arguments, Math.sqrt);\n * }\n *\n * getSquareRoots(4, 9, 16) // => [2, 3, 4]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.mapWith|mapWith}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n var map = generic(_arrayProto.map);\n\n /**\n * Reduces (or folds) the values of an array-like object, starting from the first, to a new value using the provided accumulator function.
\n * It's a generic version of [Array.prototype.reduce]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce}.\n * @example\n * _.reduce([1, 2, 3, 4], _.add) // => 10\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.reduceRight|reduceRight}\n * @see {@link module:lamb.reduceWith|reduceWith}, {@link module:lamb.reduceRightWith|reduceRightWith}\n * @param {ArrayLike} arrayLike\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {*}\n */\n var reduce = generic(_arrayProto.reduce);\n\n /**\n * Same as {@link module:lamb.reduce|reduce}, but starts the fold operation from the last element instead.
\n * It's a generic version of [Array.prototype.reduceRight]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight}.\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.reduce|reduce}\n * @see {@link module:lamb.reduceWith|reduceWith}, {@link module:lamb.reduceRightWith|reduceRightWith}\n * @param {ArrayLike} arrayLike\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {*}\n */\n var reduceRight = generic(_arrayProto.reduceRight);\n\n /**\n * Builds an array by extracting a portion of an array-like object.
\n * It's a generic version of [Array.prototype.slice]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice}.\n * @example\n * _.slice([\"foo\", \"bar\", \"baz\"], 0, 2) // => [\"foo\", \"bar\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {ArrayLike} arrayLike - Any array like object.\n * @param {Number} [start=0] - Zero-based index at which to begin extraction.\n * @param {Number} [end=arrayLike.length] - Zero-based index at which to end extraction. Extracts up to but not including end.\n * @returns {Array}\n */\n var slice = generic(_arrayProto.slice);\n\n lamb.filter = filter;\n lamb.forEach = forEach;\n lamb.map = map;\n lamb.reduce = reduce;\n lamb.reduceRight = reduceRight;\n lamb.slice = slice;\n\n\n /**\n * Accepts a series of functions and builds a function that applies the received arguments to each one and\n * returns the first non-undefined value.
\n * Meant to work in sinergy with {@link module:lamb.condition|condition} and {@link module:lamb.invoker|invoker},\n * can be useful as a strategy pattern for functions, to mimic conditional logic and also to build polymorphic functions.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var filterString = _.compose(_.invoker(\"join\", \"\"), _.filter);\n * var filterAdapter = _.adapter(\n * _.invoker(\"filter\"),\n * _.condition(_.isType(\"String\"), filterString)\n * );\n *\n * filterAdapter([1, 2, 3, 4, 5, 6], isEven)) // => [2, 4, 6]\n * filterAdapter(\"123456\", isEven)) // => \"246\"\n * filterAdapter({}, isEven)) // => undefined\n *\n * // obviously it's composable\n * var filterWithDefault = _.adapter(filterAdapter, _.always(\"Not implemented\"));\n *\n * filterWithDefault([1, 2, 3, 4, 5, 6], isEven)) // => [2, 4, 6]\n * filterWithDefault(\"123456\", isEven)) // => \"246\"\n * filterWithDefault({}, isEven)) // => \"Not implemented\"\n *\n * @memberof module:lamb\n * @category Logic\n * @param {...Function} fn\n * @returns {Function}\n */\n function adapter () {\n var functions = slice(arguments);\n\n return function () {\n var len = functions.length;\n var result;\n\n for (var i = 0; i < len; i++) {\n result = apply(functions[i], arguments);\n\n if (!isUndefined(result)) {\n break;\n }\n }\n\n return result;\n };\n }\n\n /**\n * Builds a predicate that returns true if all the given predicates are satisfied.\n * The arguments passed to the resulting function are applied to every predicate unless one of them returns false.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var isPositive = function (n) { return n > 0; };\n * var isPositiveEven = _.allOf(isEven, isPositive);\n *\n * isPositiveEven(-2) // => false\n * isPositiveEven(11) // => false\n * isPositiveEven(6) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see {@link module:lamb.anyOf|anyOf}\n * @param {...Function} predicate\n * @returns {Function}\n */\n function allOf () {\n var predicates = slice(arguments);\n\n return function () {\n var args = arguments;\n\n return predicates.every(function (predicate) {\n return predicate.apply(null, args);\n });\n };\n }\n\n /**\n * Builds a predicate that returns true if at least one of the given predicates is satisfied.\n * The arguments passed to the resulting function are applied to every predicate until one of them returns true.\n * @example\n * // Lamb's \"isNil\" is actually implemented like this\n * var isNil = _.anyOf(_.isNull, _.isUndefined);\n *\n * isNil(NaN) // => false\n * isNil({}) // => false\n * isNil(null) // => true\n * isNil(void 0) // => true\n * isNil() // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see {@link module:lamb.allOf|allOf}\n * @param {...Function} predicate\n * @returns {Function}\n */\n function anyOf () {\n var predicates = slice(arguments);\n\n return function () {\n var args = arguments;\n\n return predicates.some(function (predicate) {\n return predicate.apply(null, args);\n });\n };\n }\n\n /**\n * Builds a function that will apply the received arguments to trueFn, if the predicate is satisfied with\n * the same arguments, or to falseFn otherwise.
\n * If falseFn isn't provided and the predicate isn't satisfied the function will return undefined.
\n * Although you can use other conditions as trueFn or falseFn, it's probably better to\n * use {@link module:lamb.adapter|adapter} to build more complex behaviours.\n * @example\n * var isEven = function (n) { return n % 2 === 0};\n * var halve = function (n) { return n / 2; };\n * var halveIfEven = _.condition(isEven, halve, _.identity);\n *\n * halveIfEven(5) // => 5\n * halveIfEven(6) // => 3\n *\n * @memberof module:lamb\n * @category Logic\n * @see {@link module:lamb.invoker|invoker}\n * @param {Function} predicate\n * @param {Function} trueFn\n * @param {Function} [falseFn]\n * @returns {Function}\n */\n function condition (predicate, trueFn, falseFn) {\n return function () {\n var applyArgsTo = applyArgs(arguments);\n return applyArgsTo(predicate) ? applyArgsTo(trueFn) : falseFn ? applyArgsTo(falseFn) : void 0;\n };\n }\n\n /**\n * Verifies that the two supplied values are the same value using the \"SameValue\" comparison.
\n * Note that this doesn't behave as the strict equality operator, but rather as a shim of ES6's\n * [Object.is]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is}.\n * Differences are that 0 and -0 aren't the same value and, finally, NaN is equal to itself.
\n * See also {@link module:lamb.isSVZ|isSVZ} which performs the check using the \"SameValueZero\" comparison.\n * @example\n * var testObject = {};\n *\n * _.is({}, testObject) // => false\n * _.is(testObject, testObject) // => true\n * _.is(\"foo\", \"foo\") // => true\n * _.is(0, -0) // => false\n * _.is(0 / 0, NaN) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see [SameValue comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue}\n * @see [SameValueZero comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero}\n * @param {*} a\n * @param {*} b\n * @returns {Boolean}\n */\n function is (a, b) {\n return a === 0 && b === 0 ? 1 / a === 1 / b : isSVZ(a, b);\n }\n\n /**\n * Verifies that the first given value is greater than the second.\n * @example\n * var pastDate = new Date(2010, 2, 12);\n * var today = new Date();\n *\n * _.isGT(today, pastDate) // true\n * _.isGT(pastDate, today) // false\n * _.isGT(3, 4) // false\n * _.isGT(3, 3) // false\n * _.isGT(3, 2) // true\n * _.isGT(0, -0) // false\n * _.isGT(-0, 0) // false\n * _.isGT(\"a\", \"A\") // true\n * _.isGT(\"b\", \"a\") // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isGT (a, b) {\n return a > b;\n }\n\n /**\n * Verifies that the first given value is greater than or equal to the second.\n * Regarding equality, beware that this is simply a wrapper for the native operator, so -0 === 0.\n * @example\n * _.isGTE(3, 4) // false\n * _.isGTE(3, 3) // true\n * _.isGTE(3, 2) // true\n * _.isGTE(0, -0) // true\n * _.isGTE(-0, 0) // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isGTE (a, b) {\n return a >= b;\n }\n\n /**\n * Verifies that the first given value is less than the second.\n * @example\n * var pastDate = new Date(2010, 2, 12);\n * var today = new Date();\n *\n * _.isLT(today, pastDate) // false\n * _.isLT(pastDate, today) // true\n * _.isLT(3, 4) // true\n * _.isLT(3, 3) // false\n * _.isLT(3, 2) // false\n * _.isLT(0, -0) // false\n * _.isLT(-0, 0) // false\n * _.isLT(\"a\", \"A\") // false\n * _.isLT(\"a\", \"b\") // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isLT (a, b) {\n return a < b;\n }\n\n /**\n * Verifies that the first given value is less than or equal to the second.\n * Regarding equality, beware that this is simply a wrapper for the native operator, so -0 === 0.\n * @example\n * _.isLTE(3, 4) // true\n * _.isLTE(3, 3) // true\n * _.isLTE(3, 2) // false\n * _.isLTE(0, -0) // true\n * _.isLTE(-0, 0) // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isLTE (a, b) {\n return a <= b;\n }\n\n /**\n * A simple negation of {@link module:lamb.is|is}, exposed for convenience.\n * @example\n * _.isNot(\"foo\", \"foo\") // => false\n * _.isNot(0, -0) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @function\n * @param {*} valueA\n * @param {*} valueB\n * @returns {Boolean}\n */\n var isNot = not(is);\n\n /**\n * Verifies that the two supplied values are the same value using the \"SameValueZero\" comparison.
\n * With this comparison NaN is equal to itself, but 0 and -0 are\n * considered the same value too.
\n * See also {@link module:lamb.is|is} to perform a \"SameValue\" comparison.\n * @example\n * var testObject = {};\n *\n * _.isSVZ({}, testObject) // => false\n * _.isSVZ(testObject, testObject) // => true\n * _.isSVZ(\"foo\", \"foo\") // => true\n * _.isSVZ(0, -0) // => true\n * _.isSVZ(0 / 0, NaN) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see [SameValue comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue}\n * @see [SameValueZero comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero}\n * @param {*} a\n * @param {*} b\n * @returns {Boolean}\n */\n function isSVZ (a, b) {\n return a !== a ? b !== b : a === b;\n }\n\n /**\n * Returns a predicate that negates the given one.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var isOdd = _.not(isEven);\n *\n * isOdd(5) // => true\n * isOdd(4) // => false\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Function} predicate\n * @returns {Function}\n */\n function not (predicate) {\n return function () {\n return !predicate.apply(null, arguments);\n };\n }\n\n lamb.adapter = adapter;\n lamb.allOf = allOf;\n lamb.anyOf = anyOf;\n lamb.condition = condition;\n lamb.is = is;\n lamb.isGT = isGT;\n lamb.isGTE = isGTE;\n lamb.isLT = isLT;\n lamb.isLTE = isLTE;\n lamb.isNot = isNot;\n lamb.isSVZ = isSVZ;\n lamb.not = not;\n\n\n /**\n * Adds two numbers.\n * @example\n * _.add(4, 5) // => 9\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function add (a, b) {\n return a + b;\n }\n\n /**\n * \"Clamps\" a number within the given limits.\n * @example\n * _.clamp(-5, 0, 10) // => 0\n * _.clamp(5, 0, 10) // => 5\n * _.clamp(15, 0, 10) // => 10\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} n\n * @param {Number} min\n * @param {Number} max\n * @returns {Number}\n */\n function clamp (n, min, max) {\n return n < min ? min : n > max ? max : n;\n }\n\n /**\n * Divides two numbers.\n * @example\n * _.divide(5, 2) // => 2.5\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function divide (a, b) {\n return a / b;\n }\n\n /**\n * Generates a sequence of values of the desired length with the provided iteratee.\n * The values being iterated, and received by the iteratee, are the results generated so far.\n * @example\n * var fibonacci = function (n, idx, results) {\n * return n + (results[idx - 1] || 0);\n * };\n *\n * _.generate(1, 10, fibonacci) // => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n *\n * @memberof module:lamb\n * @category Math\n * @param {*} start - The starting value\n * @param {Number} len - The desired length for the sequence\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n function generate (start, len, iteratee, iterateeContext) {\n var result = [start];\n\n for (var i = 0, limit = len - 1; i < limit; i++) {\n result.push(iteratee.call(iterateeContext, result[i], i, result));\n }\n\n return result;\n }\n\n /**\n * Performs the modulo operation and should not be confused with the {@link module:lamb.remainder|remainder}.\n * The function performs a floored division to calculate the result and not a truncated one, hence the sign of\n * the dividend is not kept, unlike the {@link module:lamb.remainder|remainder}.\n * @example\n * _.modulo(5, 3) // => 2\n * _.remainder(5, 3) // => 2\n *\n * _.modulo(-5, 3) // => 1\n * _.remainder(-5, 3) // => -2\n *\n * @memberof module:lamb\n * @category Math\n * @see {@link http://en.wikipedia.org/wiki/Modulo_operation}\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function modulo (a, b) {\n return a - (b * Math.floor(a / b));\n }\n\n /**\n * Multiplies two numbers.\n * @example\n * _.multiply(5, 3) // => 15\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function multiply (a, b) {\n return a * b;\n }\n\n /**\n * Generates a random integer between two given integers, both included.\n * Note that no safety measure is taken if the provided arguments aren't integers, so\n * you may end up with unexpected (not really) results.\n * For example randomInt(0.1, 1.2) could be 2.\n * @example\n *\n * _.randomInt(1, 10) // => an integer >=1 && <= 10\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} min\n * @param {Number} max\n * @returns {Number}\n */\n function randomInt (min, max) {\n return Math.floor(Math.random() * (max - min + 1) + min);\n }\n\n /**\n * Generates an arithmetic progression of numbers starting from start up to,\n * but not including, limit, using the given step.\n * @example\n * _.range(2, 10) // => [2, 3, 4, 5, 6, 7, 8, 9]\n * _.range(2, 10, 0) // => [2]\n * _.range(1, -10, -2) // => [1, -1, -3, -5, -7, -9]\n * _.range(1, -10, 2) // => [1]\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} start\n * @param {Number} limit\n * @param {Number} [step=1]\n * @returns {Number[]}\n */\n function range (start, limit, step) {\n if (step === 0 || arguments.length < 2) {\n return [start];\n }\n\n if (!step) {\n step = 1;\n }\n\n var len = Math.max(Math.ceil((limit - start) / step), 0);\n return generate(start, len, partial(add, step));\n }\n\n /**\n * Gets the remainder of the division of two numbers.\n * Not to be confused with the {@link module:lamb.modulo|modulo} as the remainder\n * keeps the sign of the dividend and may lead to some unexpected results.\n * @example\n * // example of wrong usage of the remainder\n * // (in this case the modulo operation should be used)\n * var isOdd = function (n) { return _.remainder(n, 2) === 1; };\n * isOdd(-3) // => false as -3 % 2 === -1\n *\n * @memberof module:lamb\n * @category Math\n * @see {@link http://en.wikipedia.org/wiki/Modulo_operation}\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function remainder (a, b) {\n return a % b;\n }\n\n /**\n * Subtracts two numbers.\n * @example\n * _.subtract(5, 3) // => 2\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function subtract (a, b) {\n return a - b;\n }\n\n lamb.add = add;\n lamb.clamp = clamp;\n lamb.divide = divide;\n lamb.generate = generate;\n lamb.modulo = modulo;\n lamb.multiply = multiply;\n lamb.randomInt = randomInt;\n lamb.range = range;\n lamb.remainder = remainder;\n lamb.subtract = subtract;\n\n\n /**\n * Verifies if a value is null or undefined.\n * @example\n * _.isNil(NaN) // => false\n * _.isNil({}) // => false\n * _.isNil(null) // => true\n * _.isNil(void 0) // => true\n * _.isNil() // => true\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isNull|isNull} and {@link module:lamb.isNull|isUndefined} for individual checks.\n * @function\n * @param {*} value\n * @returns {Boolean}\n */\n var isNil = anyOf(isNull, isUndefined);\n\n /**\n * Verifies if a value is null.\n * @example\n * _.isNull(null) // => true\n * _.isNull(void 0) // => false\n * _.isNull(false) // => false\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isNil|isNil} if you want to check for undefined too.\n * @param {*} value\n * @returns {Boolean}\n */\n function isNull (value) {\n return value === null;\n }\n\n /**\n * Builds a predicate that expects a value to check against the specified type.\n * @example\n * var isString = _.isType(\"String\");\n *\n * isString(\"Hello\") // => true\n * isString(new String(\"Hi\")) // => true\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.type|type}\n * @param {String} typeTag\n * @returns {Function}\n */\n function isType (typeName) {\n return function (value) {\n return type(value) === typeName;\n };\n }\n\n /**\n * Verifies if a value is undefined.\n * @example\n * _.isUndefined(null) // => false\n * _.isUndefined(void 0) // => true\n * _.isUndefined(false) // => false\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isNil|isNil} if you want to check for null too.\n * @param {*} value\n * @returns {Boolean}\n */\n function isUndefined (value) {\n // using void because undefined could be theoretically shadowed\n return value === void 0;\n }\n\n /**\n * Retrieves the \"type tag\" from the given value.\n * @example\n * var x = 5;\n * var y = new Number(5);\n *\n * typeof x // => \"number\"\n * typeof y // => \"object\"\n * _.type(x) // => \"Number\"\n * _.type(y) // => \"Number\"\n *\n * _.type(Object.prototype.toString) // => \"Function\"\n * _.type(/a/) // => \"RegExp\"\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isType|isType}\n * @param {*} value\n * @returns {String}\n */\n function type (value) {\n return _objectProto.toString.call(value).replace(/^\\[\\w+\\s+|\\]$/g, \"\");\n }\n\n lamb.isNil = isNil;\n lamb.isNull = isNull;\n lamb.isType = isType;\n lamb.isUndefined = isUndefined;\n lamb.type = type;\n\n\n function _getNaturalIndex (index, len) {\n if (_isInteger(index) && _isInteger(len)) {\n return clamp(index, -len, len - 1) === index ? index < 0 ? index + len : index : void 0;\n }\n }\n\n function _getPathInfo (obj, parts) {\n var target = obj;\n var i = -1;\n var len = parts.length;\n var currentKey;\n var idx;\n\n while (++i < len) {\n currentKey = parts[i];\n\n if (_isIndex(target, currentKey)) {\n idx = _getNaturalIndex(+currentKey, target.length);\n\n if (isUndefined(idx)) {\n break;\n }\n\n target = target[idx];\n } else {\n if (!_isEnumerable(target, currentKey)) {\n break;\n }\n\n target = target[currentKey];\n }\n }\n\n return i === len ? {isValid: true, target: target} : {isValid: false, target: void 0};\n }\n\n function _isIndex (target, key) {\n return Array.isArray(target) && parseInt(key, 10) == key;\n }\n\n function _isEnumerable (obj, key) {\n return key in Object(obj) && (_isOwnEnumerable(obj, key) || ~_safeEnumerables(obj).indexOf(key));\n }\n\n function _isInteger (n) {\n return Math.floor(n) === n;\n }\n\n var _isOwnEnumerable = generic(_objectProto.propertyIsEnumerable);\n\n function _setIndex (arrayLike, index, value, updater) {\n var result = slice(arrayLike);\n var idx = _getNaturalIndex(index, result.length);\n\n if (!isUndefined(idx)) {\n result[idx] = updater ? updater(arrayLike[idx]) : value;\n }\n\n return result;\n }\n\n function _setPathIn (obj, parts, value) {\n var key = parts[0];\n var v = parts.length === 1 ? value : _setPathIn(\n _getPathInfo(obj, [key]).target,\n parts.slice(1),\n value\n );\n\n return _isIndex(obj, key) ? _setIndex(obj, +key, v) : setIn(obj, key, v);\n }\n\n /**\n * A curried version of {@link module:lamb.getIndex|getIndex} that uses the provided index\n * to build a function expecting the array-like object holding the element we want to retrieve.\n * @example\n * var getFifthElement = _.getAt(4);\n *\n * getFifthElement([1, 2, 3, 4, 5]) // => 5\n * getFifthElement(\"foo bar\") // => \"b\"\n * getFifthElement([]) // => undefined\n * getFifthElement(\"foo\") // => undefined\n *\n * @example Using negative indexes\n * _.getAt(-2)([1, 2, 3]) // => 2\n * _.getAt(-3)(\"foo\") // => \"f\"\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.getIndex|getIndex}\n * @see {@link module:lamb.head|head} and {@link module:lamb.last|last} for common use cases shortcuts.\n * @param {Number} index\n * @returns {Function}\n */\n var getAt = _curry(getIndex, 2, true);\n\n /**\n * Returns the value of the object property with the given key.\n * @example\n * var user = {name: \"John\"};\n *\n * _.getIn(user, \"name\") // => \"John\";\n * _.getIn(user, \"surname\") // => undefined\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.getKey|getKey}\n * @see {@link module:lamb.getPath|getPath}, {@link module:lamb.getPathIn|getPathIn}\n * @param {Object} obj\n * @param {String} key\n * @returns {*}\n */\n function getIn (obj, key) {\n return obj[key];\n }\n\n /**\n * Retrieves the element at the given index in an array-like object.
\n * Like {@link module:lamb.slice|slice} the index can be negative.
\n * If the index isn't supplied, or if its value isn't an integer within the array-like bounds,\n * the function will return undefined.
\n * getIndex will throw an exception when receives null or\n * undefined in place of an array-like object, but returns undefined\n * for any other value.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.getIndex(arr, 1) // => 2\n * _.getIndex(arr, -1) // => 5\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.getAt|getAt}\n * @see {@link module:lamb.head|head} and {@link module:lamb.last|last} for common use cases shortcuts.\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @returns {*}\n */\n function getIndex (arrayLike, index) {\n var idx = _getNaturalIndex(index, arrayLike.length);\n return isUndefined(idx) ? idx : arrayLike[idx];\n }\n\n /**\n * A curried version of {@link module:lamb.getIn|getIn}.
\n * Receives a property name and builds a function expecting the object from which we want to retrieve the property.\n * @example\n * var user1 = {name: \"john\"};\n * var user2 = {name: \"jane\"};\n * var getName = _.getKey(\"name\");\n *\n * getName(user1) // => \"john\"\n * getName(user2) // => \"jane\"\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.getIn|getIn}\n * @see {@link module:lamb.getPath|getPath}, {@link module:lamb.getPathIn|getPathIn}\n * @param {String} key\n * @returns {Function}\n */\n var getKey = _curry(getIn, 2, true);\n\n /**\n * Builds a partial application of {@link module:lamb.getPathIn|getPathIn} with the given\n * path and separator, expecting the object to act upon.
\n * @example\n * var user = {\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * \"user.name\": \"jdoe\",\n * password: \"abc123\"\n * }\n * };\n *\n * var getPwd = _.getPath(\"login.password\");\n * var getUsername = _.getPath(\"login/user.name\", \"/\");\n *\n * getPwd(user) // => \"abc123\";\n * getUsername(user) // => \"jdoe\"\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.getPathIn|getPathIn}\n * @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getKey|getKey}\n * @param {String} path\n * @param {String} [separator=\".\"]\n * @returns {Function}\n */\n function getPath (path, separator) {\n return partial(getPathIn, _, path, separator);\n }\n\n /**\n * Gets a nested property value from an object using the given path.
\n * The path is a string with property names separated by dots by default, but\n * it can be customised with the optional third parameter.
\n * You can use integers in the path, even negative ones, to refer to array-like\n * object indexes, but the priority will be given to existing object keys:\n * the last example explains this particular case.\n * @example\n * var user = {\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * \"user.name\": \"jdoe\",\n * password: \"abc123\"\n * },\n * scores: [\n * {id: 1, value: 10},\n * {id: 2, value: 20},\n * {id: 3, value: 30}\n * ]\n * };\n *\n * _.getPathIn(user, \"name\") // => \"John\"\n * _.getPathIn(user, \"login.password\") // => \"abc123\";\n * _.getPathIn(user, \"login/user.name\", \"/\") // => \"jdoe\"\n * _.getPathIn(user, \"name.foo\") // => undefined\n * _.getPathIn(user, \"name.foo.bar\") // => undefined\n *\n * @example Accessing array-like objects indexes:\n * _.getPathIn(user, \"login.password.1\") // => \"b\"\n * _.getPathIn(user, \"scores.0\") // => {id: 1, value: 10}\n * _.getPathIn(user, \"scores.-1.value\") // => 30\n *\n * @example Priority will be given to existing object keys over indexes:\n * _.getPathIn(user, \"scores.-1\") // => {id: 3, value: 30}\n *\n * // let's do something funny\n * user.scores[\"-1\"] = \"foo bar\";\n *\n * _.getPathIn(user, \"scores.-1\") // => \"foo bar\";\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.getPath|getPath}\n * @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getKey|getKey}\n * @param {Object|ArrayLike} obj\n * @param {String} path\n * @param {String} [separator=\".\"]\n * @returns {*}\n */\n function getPathIn (obj, path, separator) {\n return path.split(separator || \".\").reduce(\n adapter(tapArgs(getIn, Object), tapArgs(getIndex, Object, Number)),\n obj\n );\n }\n\n /**\n * Retrieves the first element of an array-like object.
\n * Just a common use case of {@link module:lamb.getAt|getAt} exposed for convenience.\n * @example\n * _.head([1, 2, 3]) // => 1\n * _.head(\"hello\") // => \"h\"\n * _.head([]) // => undefined\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.last|last}\n * @see {@link module:lamb.getIndex|getIndex}, {@link module:lamb.getAt|getAt}\n * @param {ArrayLike} arrayLike\n * @returns {*}\n */\n var head = getAt(0);\n\n /**\n * Retrieves the last element of an array-like object.
\n * Just a common use case of {@link module:lamb.getAt|getAt} exposed for convenience.\n * @example\n * _.last([1, 2, 3]) // => 3\n * _.last(\"hello\") // => \"o\"\n * _.last([]) // => undefined\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.head|head}\n * @see {@link module:lamb.getIndex|getIndex}, {@link module:lamb.getAt|getAt}\n * @param {ArrayLike} arrayLike\n * @returns {*}\n */\n var last = getAt(-1);\n\n /**\n * Builds a function that creates a copy of an array-like object with the given\n * index changed to the desired value.
\n * If the index is not an integer or if it's out of bounds, the function\n * will return a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.setAt(2, 99)(arr) // => [1, 2, 99, 4, 5]\n * arr // => [1, 2, 3, 4, 5]\n *\n * _.setAt(10, 99)(arr) // => [1, 2, 3, 4, 5] (not a reference to `arr`)\n *\n * @example Using negative indexes\n * _.setAt(-1, 99)(arr) // => [1, 2, 3, 4, 99]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.setIndex|setIndex}\n * @param {Number} index\n * @param {*} value\n * @returns {Function}\n */\n function setAt (index, value) {\n return function (arrayLike) {\n return _setIndex(arrayLike, index, value);\n };\n }\n\n /**\n * Sets the specified key to the given value in a copy of the provided object.
\n * All the enumerable keys of the source object will be simply copied to an empty\n * object without breaking references.
\n * If the specified key is not part of the source object, it will be added to the\n * result.
\n * The main purpose of the function is to work on simple plain objects used as\n * data structures, such as JSON objects, and makes no effort to play nice with\n * objects created from an OOP perspective (it's not worth it).
\n * For example the prototype of the result will be Object's regardless\n * of the source's one.\n * @example\n * var user = {name: \"John\", surname: \"Doe\", age: 30};\n *\n * _.setIn(user, \"name\", \"Jane\") // => {name: \"Jane\", surname: \"Doe\", age: 30}\n * _.setIn(user, \"gender\", \"male\") // => {name: \"John\", surname: \"Doe\", age: 30, gender: \"male\"}\n *\n * // `user` still is {name: \"John\", surname: \"Doe\", age: 30}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setKey|setKey}\n * @see {@link module:lamb.setPath|setPath}, {@link module:lamb.setPathIn|setPathIn}\n * @param {Object} source\n * @param {String} key\n * @param {*} value\n * @returns {Object}\n */\n function setIn (source, key, value) {\n return _merge(_safeEnumerables, source, make([key], [value]));\n }\n\n /**\n * Creates a copy of an array-like object with the given index changed to\n * the desired value.
\n * If the index is not an integer or if it's out of bounds, the function\n * will return a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [1, 2, 3];\n *\n * _.setIndex(arr, 1, 99) // => [1, 99, 3]\n * _.setIndex(arr, -1, 99) // => [1, 2, 99]\n * _.setIndex(arr, 10, 99) // => [1, 2, 3] (not a reference to `arr`)\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.setAt|setAt}\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @param {*} value\n * @returns {*}\n */\n var setIndex = aritize(_setIndex, 3);\n\n /**\n * Builds a partial application of {@link module:lamb.setIn|setIn} with the provided\n * key and value.
\n * The resulting function expects the object to act upon.
\n * Please refer to {@link module:lamb.setIn|setIn}'s description for explanations about\n * how the copy of the source object is made.\n * @example\n * var user = {name: \"John\", surname: \"Doe\", age: 30};\n * var setAgeTo40 = _.setKey(\"age\", 40);\n *\n * setAgeTo40(user) // => {name: \"john\", surname: \"doe\", age: 40}\n *\n * // `user` still is {name: \"John\", surname: \"Doe\", age: 30}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setIn|setIn}\n * @see {@link module:lamb.setPath|setPath}, {@link module:lamb.setPathIn|setPathIn}\n * @param {String} key\n * @param {*} value\n * @returns {Function}\n */\n function setKey (key, value) {\n return partial(setIn, _, key, value);\n }\n\n /**\n * Builds a partial application of {@link module:lamb.setPathIn|setPathIn} expecting the\n * object to act upon.
\n * See {@link module:lamb.setPathIn|setPathIn} for more details and examples.\n * @example\n * var user = {id: 1, status: {active: false}};\n * var activate = _.setPath(\"status.active\", true);\n *\n * activate(user) // => {id: 1, status: {active: true}}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setPathIn|setPathIn}\n * @see {@link module:lamb.setIn|setIn}, {@link module:lamb.setKey|setKey}\n * @param {String} path\n * @param {*} value\n * @param {String} [separator=\".\"]\n * @returns {Function}\n */\n function setPath (path, value, separator) {\n return partial(setPathIn, _, path, value, separator);\n }\n\n /**\n * Allows to change a nested value in a copy of the provided object.
\n * The function will delegate the \"set action\" to {@link module:lamb.setIn|setIn} or\n * {@link module:lamb.setAt|setAt} depending on the value encountered in the path,\n * so please refer to the documentation of those functions for specifics about the\n * implementation.
\n * Note anyway that the distinction will be between Arrays, delegated\n * to {@link module:lamb.setAt|setAt}, and everything else (including array-like objects),\n * which will be delegated to {@link module:lamb.setIn|setIn}.
\n * As a result of that, array-like objects will be converted to objects having numbers as keys\n * and paths targeting non-object values will be converted to empty objects.
\n * Non-enumerable properties encountered in the path will be considered as non-existent properties.
\n * Like {@link module:lamb.getPathIn|getPathIn} or {@link module:lamb.getPath|getPath} you can\n * use custom path separators.\n * @example\n * var user = {id: 1, status: {active : false, scores: [2, 4, 6]}};\n *\n * _.setPathIn(user, \"status.active\", true) // => {id: 1, status: {active : true, scores: [2, 4, 6]}}\n *\n * @example Targeting arrays\n * _.setPathIn(user, \"status.scores.0\", 8) // => {id: 1, status: {active : false, scores: [8, 4, 6]}}\n *\n * // you can use negative indexes as well\n * _.setPathIn(user, \"status.scores.-1\", 8) // => {id: 1, status: {active : false, scores: [2, 4, 8]}}\n *\n * @example Arrays can also be part of the path and not necessarily its target\n * var user = {id: 1, scores: [\n * {value: 2, year: \"2000\"},\n * {value: 4, year: \"2001\"},\n * {value: 6, year: \"2002\"}\n * ]};\n *\n * var newUser = _.setPathIn(user, \"scores.0.value\", 8);\n * // \"newUser\" holds:\n * // {id: 1, scores: [\n * // {value: 8, year: \"2000\"},\n * // {value: 4, year: \"2001\"},\n * // {value: 6, year: \"2002\"}\n * // ]}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setPath|setPath}\n * @see {@link module:lamb.setIn|setIn}, {@link module:lamb.setKey|setKey}\n * @param {Object|Array} source\n * @param {String} path\n * @param {*} value\n * @param {String} [separator=\".\"]\n * @returns {Object|Array}\n */\n function setPathIn (source, path, value, separator) {\n return _setPathIn(source, path.split(separator || \".\"), value);\n }\n\n /**\n * Builds a function that creates a copy of an array-like object with the given index\n * changed by applying the provided function to its value.
\n * If the index is not an integer or if it's out of bounds, the function will return\n * a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [\"a\", \"b\", \"c\"];\n * var toUpperCase = _.invoker(\"toUpperCase\");\n *\n * _.updateAt(1, toUpperCase)(arr) // => [\"a\", \"B\", \"c\"]\n * _.updateAt(-1, toUpperCase)(arr) // => [\"a\", \"b\", \"C\"]\n * _.updateAt(10, toUpperCase)(arr) // => [\"a\", \"b\", \"c\"] (not a reference to `arr`)\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.updateIndex|updateIndex}\n * @param {Number} index\n * @param {Function} updater\n * @returns {Function}\n */\n function updateAt (index, updater) {\n return function (arrayLike) {\n return _setIndex(arrayLike, index, null, updater);\n };\n }\n\n /**\n * Creates a copy of the given object having the desired key value updated by applying\n * the provided function to it.
\n * This function is meant for updating existing enumerable properties, and for those it\n * will delegate the \"set action\" to {@link module:lamb.setIn|setIn}; a copy of the\n * source is returned otherwise.\n * @example\n * var user = {name: \"John\", visits: 2};\n * var toUpperCase = _.invoker(\"toUpperCase\");\n *\n * _.updateIn(user, \"name\", toUpperCase) // => {name: \"JOHN\", visits: 2}\n * _.updateIn(user, \"surname\", toUpperCase) // => {name: \"John\", visits: 2}\n *\n * @example Non-enumerable properties will be treated as non-existent:\n * var user = Object.create({name: \"John\"}, {visits: {value: 2}});\n * var increment = _.partial(_.add, 1);\n *\n * _.updateIn(user, \"visits\", increment) // => {name: \"John\", visits: 2}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updateKey|updateKey}\n * @see {@link module:lamb.updatePath|updatePath}, {@link module:lamb.updatePathIn|updatePathIn}\n * @param {Object} source\n * @param {String} key\n * @param {Function} updater\n * @returns {Object}\n */\n function updateIn (source, key, updater) {\n return _isEnumerable(source, key) ? setIn(source, key, updater(source[key])) : _merge(_safeEnumerables, source);\n }\n\n /**\n * Creates a copy of an array-like object with the given index changed by applying the\n * provided function to its value.
\n * If the index is not an integer or if it's out of bounds, the function will return\n * a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [\"a\", \"b\", \"c\"];\n * var toUpperCase = _.invoker(\"toUpperCase\");\n *\n * _.updateIndex(arr, 1, toUpperCase) // => [\"a\", \"B\", \"c\"]\n * _.updateIndex(arr, -1, toUpperCase) // => [\"a\", \"b\", \"C\"]\n * _.updateIndex(arr, 10, toUpperCase) // => [\"a\", \"b\", \"c\"] (not a reference to `arr`)\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.updateAt|updateAt}\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @param {Function} updater\n * @returns {Array}\n */\n var updateIndex = partial(_setIndex, _, _, null);\n\n /**\n * Builds a partial application of {@link module:lamb.updateIn|updateIn} with the provided\n * key and updater, expecting the object to act upon.\n * @example\n * var user = {name: \"John\", visits: 2};\n * var increment = _.partial(_.add, 1);\n * var incrementVisits = _.updateKey(\"visits\", increment);\n *\n * incrementVisits(user) // => {name: \"John\", visits: 3}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updateIn|updateIn}\n * @see {@link module:lamb.updatePath|updatePath}, {@link module:lamb.updatePathIn|updatePathIn}\n * @param {String} key\n * @param {Function} updater\n * @returns {Function}\n */\n function updateKey (key, updater) {\n return partial(updateIn, _, key, updater);\n }\n\n /**\n * Builds a partial application of {@link module:lamb.updateIn|updateIn} expecting the object to act upon.\n * @example\n * var user = {id: 1, status: {scores: [2, 4, 6], visits: 0}};\n * var increment = _.partial(_.add, 1);\n * var incrementScores = _.updatePath(\"status.scores\", _.mapWith(increment))\n *\n * incrementScores(user) // => {id: 1, status: {scores: [3, 5, 7], visits: 0}}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updatePathIn|updatePathIn}\n * @see {@link module:lamb.updateIn|updateIn}, {@link module:lamb.updateKey|updateKey}\n * @param {String} path\n * @param {Function} updater\n * @param {String} [separator=\".\"]\n * @returns {Function}\n */\n function updatePath (path, updater, separator) {\n return partial(updatePathIn, _, path, updater, separator);\n }\n\n /**\n * Allows to change a nested value in a copy of the given object by applying the provided\n * function to it.
\n * This function is meant for updating existing enumerable properties, and for those it\n * will delegate the \"set action\" to {@link module:lamb.setPathIn|setPathIn}; a copy of the\n * source is returned otherwise.
\n * Like the other \"path\" functions, negative indexes can be used to access array elements.\n * @example\n * var user = {id: 1, status: {scores: [2, 4, 6], visits: 0}};\n * var increment = _.partial(_.add, 1);\n *\n * _.updatePathIn(user, \"status.visits\", increment) // => {id: 1, status: {scores: [2, 4, 6]}, visits: 1}\n *\n * @example Targeting arrays\n * _.updatePathIn(user, \"status.scores.0\", increment) // => {id: 1, status: {scores: [3, 4, 6], visits: 0}}\n *\n * // you can use negative indexes as well\n * _.updatePathIn(user, \"status.scores.-1\", increment) // => {id: 1, status: {scores: [2, 4, 7], visits: 0}}\n *\n * @example Arrays can also be part of the path and not necessarily its target\n * var user = {id: 1, scores: [\n * {value: 2, year: \"2000\"},\n * {value: 4, year: \"2001\"},\n * {value: 6, year: \"2002\"}\n * ]};\n *\n * var newUser = _.updatePathIn(user, \"scores.0.value\", increment);\n * // \"newUser\" holds:\n * // {id: 1, scores: [\n * // {value: 3, year: \"2000\"},\n * // {value: 4, year: \"2001\"},\n * // {value: 6, year: \"2002\"}\n * // ]}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updatePath|updatePath}\n * @see {@link module:lamb.updateIn|updateIn}, {@link module:lamb.updateKey|updateKey}\n * @param {Object|Array} source\n * @param {String} path\n * @param {Function} updater\n * @param {String} [separator=\".\"]\n * @returns {Object|Array}\n */\n function updatePathIn (source, path, updater, separator) {\n var parts = path.split(separator || \".\");\n var pathInfo = _getPathInfo(source, parts);\n\n if (pathInfo.isValid) {\n return _setPathIn(source, parts, updater(pathInfo.target));\n } else {\n return Array.isArray(source) ? slice(source) : _merge(_safeEnumerables, source);\n }\n }\n\n lamb.getAt = getAt;\n lamb.getIn = getIn;\n lamb.getIndex = getIndex;\n lamb.getKey = getKey;\n lamb.getPath = getPath;\n lamb.getPathIn = getPathIn;\n lamb.head = head;\n lamb.last = last;\n lamb.setAt = setAt;\n lamb.setIn = setIn;\n lamb.setIndex = setIndex;\n lamb.setKey = setKey;\n lamb.setPath = setPath;\n lamb.setPathIn = setPathIn;\n lamb.updateAt = updateAt;\n lamb.updateIn = updateIn;\n lamb.updateIndex = updateIndex;\n lamb.updateKey = updateKey;\n lamb.updatePath = updatePath;\n lamb.updatePathIn = updatePathIn;\n\n\n function _findSliceEndIndex (arrayLike, predicate, predicateContext) {\n var idx = -1;\n var len = arrayLike.length;\n\n while (++idx < len && predicate.call(predicateContext, arrayLike[idx], idx, arrayLike));\n\n return idx;\n }\n\n function _flatten (array, output) {\n array.forEach(function (value) {\n if (Array.isArray(value)) {\n _flatten(value, output);\n } else {\n output.push(value);\n }\n });\n\n return output;\n }\n\n /**\n * Builds a predicate to check if an array-like object contains the given value.
\n * Please note that the equality test is made with {@link module:lamb.isSVZ|isSVZ}; so you can\n * check for NaN, but 0 and -0 are the same value.
\n * See also {@link module:lamb.isIn|isIn} for an uncurried version.\n * @example\n * var containsNaN = _.contains(NaN, 0);\n *\n * containsNaN([0, 1, 2, 3, NaN]) // => true\n *\n * @memberof module:lamb\n * @category Array\n * @param {*} value\n * @param {Number} [fromIndex=0] The position at which to begin searching for the given value.\n * @returns {Function}\n */\n function contains (value, fromIndex) {\n return function (arrayLike) {\n return isIn(arrayLike, value, fromIndex);\n };\n }\n\n /**\n * Returns an array of items present only in the first of the given arrays.
\n * Note that since version 0.13.0 this function uses the [\"SameValueZero\" comparison]{@link module:lamb.isSVZ|isSVZ}.\n * @example\n * var a1 = [1, 2, 3, 4];\n * var a2 = [2, 4, 5];\n * var a3 = [4, 5, 3, 1];\n *\n * _.difference(a1, a2) // => [1, 3]\n * _.difference(a1, a2, a3) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @param {Array} array\n * @param {...Array} other\n * @returns {Array}\n */\n function difference (array) {\n var rest = shallowFlatten(slice(arguments, 1));\n var isInRest = partial(isIn, rest, _, 0);\n return array.filter(not(isInRest));\n }\n\n /**\n * Builds an array without the first n elements of the given array or array-like object.\n * Note that, being this only a shortcut for a specific use case of {@link module:lamb.slice|slice},\n * n can be a negative number.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.drop(arr, 2) // => [3, 4, 5]\n * _.drop(arr, -1) // => [5]\n * _.drop(arr, -10) // => [1, 2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {ArrayLike} arrayLike\n * @param {Number} n\n * @returns {Array}\n */\n var drop = binary(slice);\n\n /**\n * A curried version of {@link module:lamb.drop|drop} that expects the number of elements\n * to drop to build a function waiting for the list to take the elements from.\n * See the note and examples for {@link module:lamb.drop|drop} about passing a negative n.\n * @example\n * var drop2 = _.dropN(2);\n *\n * drop2([1, 2, 3, 4, 5]) // => [3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.drop|drop}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {Number} n\n * @returns {Function}\n */\n var dropN = _curry(drop, 2, true);\n\n /**\n * Builds a function that drops the first n elements satisfying a predicate from an array or array-like object.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var dropWhileIsEven = _.dropWhile(isEven);\n *\n * dropWhileIsEven([2, 4, 6, 8]) // => []\n * dropWhileIsEven([2, 4, 7, 8]) // => [7, 8]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.takeWhile|takeWhile}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function dropWhile (predicate, predicateContext) {\n return function (arrayLike) {\n return slice(arrayLike, _findSliceEndIndex(arrayLike, predicate, predicateContext));\n };\n }\n\n /**\n * Returns a partial application of {@link module:lamb.filter|filter} that uses the given predicate and\n * the optional context to build a function expecting the array-like object to act upon.\n * @example\n * var isLowerCase = function (s) { return s.toLowerCase() === s; };\n * var getLowerCaseEntries = _.filterWith(isLowerCase);\n *\n * getLowerCaseEntries([\"Foo\", \"bar\", \"baZ\"]) // => [\"bar\"]\n *\n * // array-like objects can be used as well\n * getLowerCaseEntries(\"fooBAR\") // => [\"f\", \"o\", \"o\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.filter|filter}\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function filterWith (predicate, predicateContext) {\n return partial(filter, _, predicate, predicateContext);\n }\n\n /**\n * Searches for an element satisfying the predicate in the given array-like object and returns it if\n * the search is successful. Returns undefined otherwise.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 40}\n * ];\n *\n * _.find(persons, _.hasKeyValue(\"age\", 40)) // => {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40}\n * _.find(persons, _.hasKeyValue(\"age\", 41)) // => undefined\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {*}\n */\n function find (arrayLike, predicate, predicateContext) {\n var result;\n\n for (var i = 0, len = arrayLike.length, element; i < len; i++) {\n element = arrayLike[i];\n\n if (predicate.call(predicateContext, element, i, arrayLike)) {\n result = element;\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Searches for an element satisfying the predicate in the given array-like object and returns its\n * index if the search is successful. Returns -1 otherwise.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 40}\n * ];\n *\n * _.findIndex(persons, _.hasKeyValue(\"age\", 40)) // => 1\n * _.findIndex(persons, _.hasKeyValue(\"age\", 41)) // => -1\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Number}\n */\n function findIndex (arrayLike, predicate, predicateContext) {\n var result = -1;\n\n for (var i = 0, len = arrayLike.length; i < len; i++) {\n if (predicate.call(predicateContext, arrayLike[i], i, arrayLike)) {\n result = i;\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Similar to {@link module:lamb.map|map}, but if the mapping function returns an array this will\n * be concatenated, rather than pushed, to the final result.\n * @example showing the difference with map\n * var words = [\"foo\", \"bar\"];\n * var toCharArray = function (s) { return s.split(\"\"); };\n *\n * _.map(words, toCharArray) // => [[\"f\", \"o\", \"o\"], [\"b\", \"a\", \"r\"]]\n * _.flatMap(words, toCharArray) // => [\"f\", \"o\", \"o\", \"b\", \"a\", \"r\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.flatMapWith|flatMapWith}\n * @param {Array} array\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n var flatMap = compose(shallowFlatten, map);\n\n /**\n * Builds a partial application of {@link module:lamb.flatMap|flatMap} using the given iteratee\n * and the optional context. The resulting function expects the array to act upon.\n * @example\n * var toCharArray = function (s) { return s.split(\"\"); };\n * var wordsToCharArray = _.flatMapWith(toCharArray);\n *\n * wordsToCharArray([\"foo\", \"bar\"]) // => [\"f\", \"o\", \"o\", \"b\", \"a\", \"r\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.flatMap|flatMap}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function flatMapWith (iteratee, iterateeContext) {\n return partial(flatMap, _, iteratee, iterateeContext);\n }\n\n /**\n * Flattens an array.\n * @example showing the difference with shallowFlatten\n * var arr = [1, 2, [3, 4, [5, 6]], 7, 8];\n *\n * _.flatten(arr) // => [1, 2, 3, 4, 5, 6, 7, 8]\n * _.shallowFlatten(arr) // => [1, 2, 3, 4, [5, 6], 7, 8]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.shallowFlatten|shallowFlatten}\n * @param {Array} array\n * @returns {Array}\n */\n function flatten (array) {\n return _flatten(array, []);\n }\n\n /**\n * Returns a copy of the given array-like object without the last element.\n * @example\n * _.init([1, 2, 3, 4]) // => [1, 2, 3]\n * _.init([1]) // => []\n * _.init([]) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.tail|tail}\n * @see {@link module:lamb.head|head}, {@link module:lamb.last|last}\n * @param {ArrayLike} arrayLike\n * @returns {Array}\n */\n var init = partial(slice, _, 0, -1);\n\n /**\n * Inserts the provided element in a copy of an array-like object at the\n * specified index.
\n * If the index is greater than the length of the array-like, the element\n * will be appended at the end.
\n * Negative indexes are allowed; when a negative index is out of bounds\n * the element will be inserted at the start of the resulting array.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.insert(arr, 3, 99) // => [1, 2, 3, 99, 4, 5]\n * _.insert(arr, -2, 99) // => [1, 2, 3, 99, 4, 5]\n * _.insert(arr, 10, 99) // => [1, 2, 3, 4, 5, 99]\n * _.insert(arr, -10, 99) // => [99, 1, 2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.insertAt|insertAt}\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @param {*} element\n * @returns {Array}\n */\n function insert (arrayLike, index, element) {\n var result = slice(arrayLike);\n result.splice(index, 0, element);\n return result;\n }\n\n /**\n * Builds a partial application of {@link module:lamb.insert|insert}\n * expecting the array-like object to act upon.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.insertAt(3, 99)(arr) // => [1, 2, 3, 99, 4, 5]\n * _.insertAt(-2, 99)(arr) // => [1, 2, 3, 99, 4, 5]\n * _.insertAt(10, 99)(arr) // => [1, 2, 3, 4, 5, 99]\n * _.insertAt(-10, 99)(arr) // => [99, 1, 2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.insert|insert}\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @param {Number} index\n * @param {*} element\n * @returns {Function}\n */\n function insertAt (index, element) {\n return partial(insert, _, index, element);\n }\n\n /**\n * Returns an array of every item present in all given arrays.
\n * Note that since version 0.13.0 this function uses the [\"SameValueZero\" comparison]{@link module:lamb.isSVZ|isSVZ}.\n * @example\n * var a1 = [1, 2, 3, 4];\n * var a2 = [2, 5, 4, 6];\n * var a3 = [5, 6, 7];\n *\n * _.intersection(a1, a2) // => [2, 4]\n * _.intersection(a1, a3) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @param {...Array} array\n * @return {Array}\n */\n function intersection () {\n var rest = slice(arguments, 1);\n return uniques(arguments[0]).filter(function (item) {\n return rest.every(contains(item));\n });\n }\n\n /**\n * Checks if an array-like object contains the given value.
\n * Please note that the equality test is made with {@link module:lamb.isSVZ|isSVZ}; so you can\n * check for NaN, but 0 and -0 are the same value.
\n * See also {@link module:lamb.contains|contains} for a curried version building a predicate.\n * @example\n * var numbers = [0, 1, 2, 3, NaN];\n *\n * _.isIn(numbers, 1) // => true\n * _.isIn(numbers, 0) // => true\n * _.isIn(numbers, -0) // => true\n * _.isIn(numbers, NaN) // => true\n * _.isIn(numbers, 2, 3) // => false\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {*} value\n * @param {Number} [fromIndex=0] The position at which to begin searching for the given value.\n * @returns {Boolean}\n */\n function isIn (arrayLike, value, fromIndex) {\n var result = false;\n\n for (var i = fromIndex >>> 0, len = arrayLike.length; i < len; i++) {\n if (isSVZ(value, arrayLike[i])) {\n result = true;\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Generates an array with the values passed as arguments.\n * @example\n * _.list(1, 2, 3) // => [1, 2, 3]\n *\n * @memberof module:lamb\n * @category Array\n * @param {...*} value\n * @returns {Array}\n */\n function list () {\n return arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);\n }\n\n /**\n * Builds a partial application of {@link module:lamb.map|map} using the given iteratee and the optional context.\n * The resulting function expects the array-like object to act upon.\n * @example\n * var square = function (n) { return n * n; };\n * var getSquares = _.mapWith(square);\n *\n * getSquares([1, 2, 3, 4, 5]) // => [1, 4, 9, 16, 25]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.map|map}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {function}\n */\n function mapWith (iteratee, iterateeContext) {\n return partial(map, _, iteratee, iterateeContext);\n }\n\n /**\n * Splits an array-like object in two lists: the first with the elements satisfying the given predicate,\n * the others with the remaining elements.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n *\n * _.partition(numbers, isEven) // => [[2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.partitionWith|partitionWith}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Array, Array<*>>}\n */\n function partition (arrayLike, predicate, predicateContext) {\n var result = [[], []];\n var len = arrayLike.length;\n\n for (var i = 0, el; i < len; i++) {\n el = arrayLike[i];\n result[predicate.call(predicateContext, el, i, arrayLike) ? 0 : 1].push(el);\n }\n\n return result;\n }\n\n /**\n * Builds a partial application of {@link module:lamb.partition|partition} using the given predicate and the optional context.\n * The resulting function expects the array-like object to act upon.\n * @example\n * var users = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"active\": false},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"active\": true},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"active\": true},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"active\": false}\n * ];\n * var isActive = _.hasKeyValue(\"active\", true);\n * var splitByActiveStatus = _.partitionWith(isActive);\n *\n * splitByActiveStatus(users) // =>\n * // [[\n * // {\"name\": \"John\", \"surname\": \"Doe\", \"active\": true},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\", \"active\": true}\n * // ], [\n * // {\"name\": \"Jane\", \"surname\": \"Doe\", \"active\": false},\n * // {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"active\": false}\n * // ]]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.partition|partition}\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function partitionWith (predicate, predicateContext) {\n return partial(partition, _, predicate, predicateContext);\n }\n\n /**\n * \"Plucks\" the values of the specified key from a list of objects.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 15}\n * ];\n *\n * _.pluck(persons, \"age\") // => [12, 40, 18, 15]\n *\n * var lists = [\n * [1, 2],\n * [3, 4, 5],\n * [6]\n * ];\n *\n * _.pluck(lists, \"length\") // => [2, 3, 1]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.pluckKey|pluckKey}\n * @param {ArrayLike} arrayLike\n * @param {String} key\n * @returns {Array}\n */\n function pluck (arrayLike, key) {\n return map(arrayLike, getKey(key));\n }\n\n /**\n * A curried version of {@link module:lamb.pluck|pluck} expecting the key to retrieve to\n * build a function waiting for the array-like object to act upon.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 15}\n * ];\n * var getAges = _.pluckKey(\"age\");\n *\n * getAges(persons) // => [12, 40, 18, 15]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.pluck|pluck}\n * @function\n * @param {String} key\n * @returns {Function}\n */\n function pluckKey (key) {\n return mapWith(getKey(key));\n }\n\n /**\n * A partial application of {@link module:lamb.reduce|reduceRight} that uses the\n * provided accumulator and the optional initialValue to\n * build a function expecting the array-like object to act upon.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.reduceRightWith(_.add)(arr) // => 15\n * _.reduceRightWith(_.subtract)(arr) // => -5\n * _.reduceRightWith(_.subtract, 0)(arr) // => -15\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.reduceWith|reduceWith}\n * @see {@link module:lamb.reduce|reduce}, {@link module:lamb.reduce|reduceRight}\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {Function}\n */\n function reduceRightWith (accumulator, initialValue) {\n var fn = arguments.length === 2 ? reduceRight : binary(reduceRight);\n return partial(fn, _, accumulator, initialValue);\n }\n\n /**\n * A partial application of {@link module:lamb.reduce|reduce} that uses the\n * provided accumulator and the optional initialValue to\n * build a function expecting the array-like object to act upon.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.reduceWith(_.add)(arr) // => 15\n * _.reduceWith(_.subtract)(arr) // => -13\n * _.reduceWith(_.subtract, 0)(arr) // => -15\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.reduceRightWith|reduceRightWith}\n * @see {@link module:lamb.reduce|reduce}, {@link module:lamb.reduce|reduceRight}\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {Function}\n */\n function reduceWith (accumulator, initialValue) {\n var fn = arguments.length === 2 ? reduce : binary(reduce);\n return partial(fn, _, accumulator, initialValue);\n }\n\n /**\n * Reverses a copy of the given array-like object.\n * @example\n * var arr = [1, 2, 3];\n *\n * _.reverse(arr) // => [3, 2, 1];\n *\n * // `arr` still is [1, 2, 3]\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @returns {Array}\n */\n function reverse (arrayLike) {\n return slice(arrayLike).reverse();\n }\n\n /**\n * Flattens the \"first level\" of an array.\n * @example showing the difference with flatten\n * var arr = [1, 2, [3, 4, [5, 6]], 7, 8];\n *\n * _.flatten(arr) // => [1, 2, 3, 4, 5, 6, 7, 8]\n * _.shallowFlatten(arr) // => [1, 2, 3, 4, [5, 6], 7, 8]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.flatten|flatten}\n * @param {Array} array\n * @returns {Array}\n */\n function shallowFlatten (array) {\n return _arrayProto.concat.apply([], array);\n }\n\n /**\n * Returns a copy of the given array-like object without the first element.\n * @example\n * _.tail([1, 2, 3, 4]) // => [2, 3, 4]\n * _.tail([1]) // => []\n * _.tail([]) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.init|init}\n * @see {@link module:lamb.head|head}, {@link module:lamb.last|last}\n * @param {ArrayLike} arrayLike\n * @returns {Array}\n */\n var tail = partial(slice, _, 1, void 0);\n\n /**\n * Retrieves the first n elements from an array or array-like object.\n * Note that, being this a partial application of {@link module:lamb.slice|slice},\n * n can be a negative number.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.take(arr, 3) // => [1, 2, 3]\n * _.take(arr, -1) // => [1, 2, 3, 4]\n * _.take(arr, -10) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {ArrayLike} arrayLike\n * @param {Number} n\n * @returns {Array}\n */\n var take = partial(slice, _, 0, _);\n\n /**\n * A curried version of {@link module:lamb.take|take} that expects the number of elements\n * to retrieve to build a function waiting for the list to take the elements from.\n * See the note and examples for {@link module:lamb.take|take} about passing a negative n.\n * @example\n * var take2 = _.takeN(2);\n *\n * take2([1, 2, 3, 4, 5]) // => [1, 2]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.take|take}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {Number} n\n * @returns {Function}\n */\n var takeN = _curry(take, 2, true);\n\n /**\n * Builds a function that takes the first n elements satisfying a predicate from an array or array-like object.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var takeWhileIsEven = _.takeWhile(isEven);\n *\n * takeWhileIsEven([1, 2, 4, 6, 8]) // => []\n * takeWhileIsEven([2, 4, 7, 8]) // => [2, 4]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.dropWhile|dropWhile}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @param {ListIteratorCallback} predicate\n * @param {Object} predicateContext\n * @returns {Function}\n */\n function takeWhile (predicate, predicateContext) {\n return function (arrayLike) {\n return slice(arrayLike, 0, _findSliceEndIndex(arrayLike, predicate, predicateContext));\n };\n }\n\n /**\n * Transposes a matrix. Can also be used to reverse a {@link module:lamb.zip|zip} operation.
\n * Just like {@link module:lamb.zip|zip}, the received array-like objects will be truncated to the\n * shortest length.\n * @example transposing a matrix\n * _.transpose([\n * [1, 2, 3],\n * [4, 5, 6],\n * [7, 8, 9]\n * ]) // =>\n * // [\n * // [1, 4, 7],\n * // [2, 5, 8],\n * // [3, 6, 9]\n * // ]\n *\n * @example showing the relationship with zip\n * var zipped = _.zip([\"a\", \"b\", \"c\"], [1, 2, 3]); // => [[\"a\", 1], [\"b\", 2], [\"c\", 3]]\n *\n * _.transpose(zipped) // => [[\"a\", \"b\", \"c\"], [1, 2, 3]]\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike>} arrayLike\n * @returns {Array>}\n */\n function transpose (arrayLike) {\n var result = [];\n var minLen = apply(Math.min, pluck(arrayLike, \"length\")) >>> 0;\n var len = arrayLike.length;\n\n for (var i = 0, j; i < minLen; i++) {\n result.push([]);\n\n for (j = 0; j < len; j++) {\n result[i][j] = arrayLike[j][i];\n }\n }\n\n return result;\n }\n\n /**\n * Returns a list of every unique element present in the given array-like objects.\n * @example\n * _.union([1, 2, 3, 2], [3, 4], [1, 5]) // => [1, 2, 3, 4, 5]\n * _.union(\"abc\", \"bcd\", \"cde\") // => [\"a\", \"b\", \"c\", \"d\", \"e\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {...ArrayLike} arrayLike\n * @returns {Array}\n */\n var union = compose(uniques, flatMapWith(unary(slice)), list);\n\n /**\n * Returns an array comprised of the unique elements of the given array-like object.
\n * Can work with lists of complex objects if supplied with an iteratee.
\n * Note that since version 0.13.0 this function uses the [\"SameValueZero\" comparison]{@link module:lamb.isSVZ|isSVZ}.\n * @example with simple values\n * _.uniques([1, 2, 2, 3, 4, 3, 5, 1]) // => [1, 2, 3, 4, 5]\n *\n * @example with complex values\n * var data = [\n * {id: \"1\"},\n * {id: \"4\"},\n * {id: \"5\"},\n * {id: \"1\"},\n * {id: \"5\"},\n * ];\n *\n * _.uniques(data, _.getKey(\"id\")) // => [{id: \"1\"}, {id: \"4\"}, {\"id\": 5}]\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} [iteratee] Defaults to the [identity function]{@link module:lamb.identity}.\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n function uniques (arrayLike, iteratee, iterateeContext) {\n if (typeof iteratee !== \"function\") {\n iteratee = identity;\n }\n\n var result = [];\n var seen = [];\n var value;\n\n for (var i = 0, len = arrayLike.length; i < len; i++) {\n value = iteratee.call(iterateeContext, arrayLike[i], i, arrayLike);\n\n if (!isIn(seen, value)) {\n seen.push(value);\n result.push(arrayLike[i]);\n }\n }\n\n return result;\n }\n\n /**\n * Builds a list of arrays out of the given array-like objects by pairing items with the same index.
\n * The received array-like objects will be truncated to the shortest length.
\n * See also {@link module:lamb.zipWithIndex|zipWithIndex} and {@link module:lamb.transpose|transpose} for the reverse operation.\n * @example\n * _.zip(\n * [\"a\", \"b\", \"c\"],\n * [1, 2, 3],\n * [true, false, true]\n * ) // => [[\"a\", 1, true], [\"b\", 2, false], [\"c\", 3, true]]\n *\n * _.zip([1, 2, 3, 4], [5, 6, 7]) // => [[1, 5], [2, 6], [3, 7]]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {...ArrayLike} arrayLike\n * @returns {Array>}\n */\n var zip = compose(transpose, list);\n\n /**\n * \"{@link module:lamb.zip|Zips}\" an array-like object by pairing its values with their index.\n * @example\n * _.zipWithIndex([\"a\", \"b\", \"c\"]) // => [[\"a\", 0], [\"b\", 1], [\"c\", 2]]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {ArrayLike} arrayLike\n * @returns {Array>}\n */\n var zipWithIndex = mapWith(binary(list));\n\n lamb.contains = contains;\n lamb.difference = difference;\n lamb.drop = drop;\n lamb.dropN = dropN;\n lamb.dropWhile = dropWhile;\n lamb.filterWith = filterWith;\n lamb.find = find;\n lamb.findIndex = findIndex;\n lamb.flatMap = flatMap;\n lamb.flatMapWith = flatMapWith;\n lamb.flatten = flatten;\n lamb.init = init;\n lamb.insert = insert;\n lamb.insertAt = insertAt;\n lamb.intersection = intersection;\n lamb.isIn = isIn;\n lamb.list = list;\n lamb.mapWith = mapWith;\n lamb.partition = partition;\n lamb.partitionWith = partitionWith;\n lamb.pluck = pluck;\n lamb.pluckKey = pluckKey;\n lamb.reduceRightWith = reduceRightWith;\n lamb.reduceWith = reduceWith;\n lamb.reverse = reverse;\n lamb.shallowFlatten = shallowFlatten;\n lamb.tail = tail;\n lamb.take = take;\n lamb.takeN = takeN;\n lamb.takeWhile = takeWhile;\n lamb.transpose = transpose;\n lamb.union = union;\n lamb.uniques = uniques;\n lamb.zip = zip;\n lamb.zipWithIndex = zipWithIndex;\n\n\n function _groupWith (makeValue, startValue) {\n return function (arrayLike, iteratee, iterateeContext) {\n return reduce(arrayLike, function (result, element, idx) {\n var key = iteratee.call(iterateeContext, element, idx, arrayLike);\n var value = makeValue(key in result ? result[key] : startValue , element);\n\n result[key] = value;\n\n return result;\n }, {});\n };\n }\n\n /**\n * Transforms an array-like object in a lookup table with the keys generated by the provided\n * iteratee, having as values the count of matches for the key.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"age\": 12},\n * {\"name\": \"John\", \"age\": 40},\n * {\"name\": \"Mario\", \"age\": 17},\n * {\"name\": \"Paolo\", \"age\": 15}\n * ];\n * var getAgeStatus = function (person) { return person.age >= 18 ? \"adult\" : \"minor\"; };\n *\n * _.count(persons, getAgeStatus) // => {\"adult\": 1, \"minor\": 3}\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Object}\n */\n var count = _groupWith(partial(add, 1), 0);\n\n /**\n * Using the provided iteratee, and its optional context, builds a partial application of\n * {@link module:lamb.count|count} expecting the array-like object to act upon.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"city\": \"New York\"},\n * {\"name\": \"John\", \"city\": \"New York\"},\n * {\"name\": \"Mario\", \"city\": \"Rome\"},\n * {\"name\": \"Paolo\"}\n * ];\n * var getCityOrUnknown = _.adapter(_.getKey(\"city\"), _.always(\"Unknown\"));\n * var countByCity = _.countBy(getCityOrUnknown);\n *\n * countByCity(persons) // => {\"New York\": 2, \"Rome\": 1, \"Unknown\": 1}\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.count|count}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function countBy (iteratee, iterateeContext) {\n return partial(count, _, iteratee, iterateeContext);\n }\n\n /**\n * Transforms an array-like object into a lookup table using the provided iteratee as a grouping\n * criterion to generate keys and values.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"city\": \"New York\"},\n * {\"name\": \"John\", \"city\": \"New York\"},\n * {\"name\": \"Mario\", \"city\": \"Rome\"},\n * {\"name\": \"Paolo\"}\n * ];\n * var getCity = _.getKey(\"city\");\n * var personsByCity = _.group(persons, getCity);\n *\n * // \"personsByCity\" holds:\n * // {\n * // \"New York\": [\n * // {\"name\": \"Jane\", \"city\": \"New York\"},\n * // {\"name\": \"John\", \"city\": \"New York\"}\n * // ],\n * // \"Rome\": [\n * // {\"name\": \"Mario\", \"city\": \"Rome\"}\n * // ],\n * // \"undefined\": [\n * // {\"name\": \"Paolo\"}\n * // ]\n * // }\n *\n * @example Adding a custom value for missing keys\n *\n * var getCityOrUnknown = _.adapter(getCity, _.always(\"Unknown\"));\n *\n * var personsByCity = _.group(persons, getCityOrUnknown);\n *\n * // \"personsByCity\" holds:\n * // {\n * // \"New York\": [\n * // {\"name\": \"Jane\", \"city\": \"New York\"},\n * // {\"name\": \"John\", \"city\": \"New York\"}\n * // ],\n * // \"Rome\": [\n * // {\"name\": \"Mario\", \"city\": \"Rome\"}\n * // ],\n * // \"Unknown\": [\n * // {\"name\": \"Paolo\"}\n * // ]\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.groupBy|groupBy}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Object}\n */\n var group = _groupWith(invoker(\"concat\"), []);\n\n /**\n * Using the provided iteratee, and its optional context, builds a partial application\n * of {@link module:lamb.group|group} expecting the array-like object to act upon.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"age\": 12},\n * {\"name\": \"John\", \"age\": 40},\n * {\"name\": \"Mario\", \"age\": 18},\n * {\"name\": \"Paolo\", \"age\": 15}\n * ];\n *\n * var getAgeStatus = function (person) { return person.age > 20 ? \"over 20\" : \"under 20\"; };\n * var groupByAgeStatus = _.groupBy(getAgeStatus);\n *\n * var personsByAgeStatus = groupByAgeStatus(persons);\n *\n * // \"personsByAgeStatus\" holds:\n * // {\n * // \"under 20\": [\n * // {\"name\": \"Jane\", \"age\": 12},\n * // {\"name\": \"Mario\", \"age\": 18},\n * // {\"name\": \"Paolo\", \"age\": 15}\n * // ],\n * // \"over 20\": [\n * // {\"name\": \"John\", \"age\": 40}\n * // ]\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.group|group}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function groupBy (iteratee, iterateeContext) {\n return partial(group, _, iteratee, iterateeContext);\n }\n\n /**\n * Similar to {@link module:lamb.group|group}, but the generated lookup table will have\n * only one element of the original array-like object for each value.
\n * Should be used only when you're sure that your iteratee won't produce\n * duplicate keys, otherwise only the last evaluated element will be in the result.\n * @example\n * var users = [\n * {id: 1, name: \"John\"},\n * {id: 2, name: \"Jane\"},\n * {id: 3, name: \"Mario\"},\n * {id: 4, name: \"John\"}\n * ];\n *\n * var indexedUsers = _.index(users, _.getKey(\"id\"));\n *\n * // \"indexedUsers\" holds:\n * // {\n * // \"1\": {id: 1, name: \"John\"},\n * // \"2\": {id: 2, name: \"Jane\"},\n * // \"3\": {id: 3, name: \"Mario\"},\n * // \"4\": {id: 4, name: \"John\"}\n * // }\n *\n * @example Result of an iteratee producing a duplicate key:\n * var users = [\n * {id: 1, name: \"John\"},\n * {id: 2, name: \"Jane\"},\n * {id: 3, name: \"Mario\"},\n * {id: 4, name: \"John\"}\n * ];\n *\n * var indexedUsers = _.index(users, _.getKey(\"name\"));\n *\n * // \"indexedUsers\" holds:\n * // {\n * // \"John\": {\"id\": 4, \"name\": \"John\"},\n * // \"Jane\": {\"id\": 2, \"name\": \"Jane\"},\n * // \"Mario\": {\"id\": 3, \"name\": \"Mario\"}\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.indexBy|indexBy}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Object}\n */\n var index = _groupWith(getArgAt(1));\n\n /**\n * Using the provided iteratee, and its optional context, builds a partial application\n * of {@link module:lamb.index|index} expecting the array-like object to act upon.\n * @example\n * var users = [\n * {id: 1, name: \"John\"},\n * {id: 2, name: \"Jane\"},\n * {id: 3, name: \"Mario\"}\n * ];\n * var indexByID = _.indexBy(_.getKey(\"id\"));\n *\n * var indexedUsers = indexByID(users);\n *\n * // \"indexedUsers\" holds:\n * // {\n * // \"1\": {id: 1, name: \"John\"},\n * // \"2\": {id: 2, name: \"Jane\"},\n * // \"3\": {id: 3, name: \"Mario\"}\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.index|index}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function indexBy (iteratee, iterateeContext) {\n return partial(index, _, iteratee, iterateeContext);\n }\n\n lamb.count = count;\n lamb.countBy = countBy;\n lamb.group = group;\n lamb.groupBy = groupBy;\n lamb.index = index;\n lamb.indexBy = indexBy;\n\n\n function _comparer (a, b) {\n var result = 0;\n\n if (typeof a !== typeof b) {\n a = String(a);\n b = String(b);\n }\n\n if (!isSVZ(a, b)) {\n if (a > b || a !== a) {\n result = 1;\n } else if (a < b || b !== b) {\n result = -1;\n }\n }\n\n return result;\n }\n\n function _compareWith (criteria) {\n var len = criteria.length;\n\n return function (a, b) {\n var result = 0;\n var isDescSort;\n var criterion;\n\n for (var i = 0; i < len; i++) {\n criterion = criteria[i];\n result = criterion.compare(a.value, b.value);\n\n if (result !== 0) {\n isDescSort = criteria[i].isDescending;\n break;\n }\n }\n\n if (result === 0) {\n isDescSort = criteria[len - 1].isDescending;\n result = a.index - b.index;\n }\n\n return isDescSort ? -result : result;\n };\n }\n\n function _getInsertionIndex (array, element, comparer, start, end) {\n if (array.length === 0) {\n return 0;\n }\n\n var pivot = (start + end) >> 1;\n var result = comparer({\n value: element,\n index: pivot\n }, {\n value: array[pivot],\n index: pivot\n });\n\n if (end - start <= 1) {\n return result < 0 ? pivot : pivot + 1;\n } else if (result < 0) {\n return _getInsertionIndex(array, element, comparer, start, pivot);\n } else if (result === 0) {\n return pivot + 1;\n } else {\n return _getInsertionIndex(array, element, comparer, pivot, end);\n }\n }\n\n function _makeCriteria (sorters) {\n return sorters.length ? sorters.map(_makeCriterion) : [_sorter()];\n }\n\n function _makeCriterion (criterion) {\n return typeof Object(criterion).compare === \"function\" ? criterion : _sorter(criterion);\n }\n\n function _sorter (reader, isDescending, comparer) {\n return {\n isDescending: isDescending === true,\n compare: function (a, b) {\n if (typeof reader === \"function\" && reader !== identity) {\n a = reader(a);\n b = reader(b);\n }\n\n return (comparer || _comparer)(a, b);\n }\n };\n }\n\n /**\n * Returns a [stably]{@link https://en.wikipedia.org/wiki/Sorting_algorithm#Stability} sorted copy of an\n * array-like object using the given criteria.
\n * Sorting criteria are built using Lamb's {@link module:lamb.sorter|sorter} function, but you can also\n * pass simple \"reader\" functions and default ascending sorters will be built for you.
\n * A \"reader\" is a function that evaluates the array element and supplies the value to be used in the comparison.
\n * Please note that if the arguments received by the default comparer aren't of the same type, they will be compared as strings.\n *\n * @example Stable sort:\n * var persons = [\n * {\"name\": \"John\", \"surname\" :\"Doe\"},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\"},\n * {\"name\": \"John\", \"surname\" :\"Moe\"},\n * {\"name\": \"Jane\", \"surname\": \"Foe\"}\n * ];\n *\n * var personsByName = _.sort(persons, _.getKey(\"name\"));\n *\n * // personsByName holds:\n * // [\n * // {\"name\": \"Jane\", \"surname\": \"Foe\"},\n * // {\"name\": \"John\", \"surname\" :\"Doe\"},\n * // {\"name\": \"John\", \"surname\" :\"Moe\"},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * // ]\n *\n * @example Stable multi-sort:\n * var personsByNameAscSurnameDesc = _.sort(\n * persons,\n * _.getKey(\"name\"),\n * _.sorterDesc(_.getKey(\"surname\"))\n * );\n *\n * // personsByNameAscSurnameDesc holds:\n * // [\n * // {\"name\": \"Jane\", \"surname\": \"Foe\"},\n * // {\"name\": \"John\", \"surname\" :\"Moe\"},\n * // {\"name\": \"John\", \"surname\" :\"Doe\"},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * // ]\n *\n * @example Using custom comparers:\n * var localeSorter = new Intl.Collator(\"it\");\n * var chars = [\"a\", \"è\", \"à\", \"é\", \"c\", \"b\", \"e\"];\n *\n * _.sort(chars, localeSorter) // => [\"a\", \"à\", \"b\", \"c\", \"e\", \"é\", \"è\"]\n *\n * var localeSorterDesc = _.sorterDesc(_.identity, localeSorter.compare);\n *\n * _.sort(chars, localeSorterDesc) // => [\"è\", \"é\", \"e\", \"c\", \"b\", \"à\", \"a\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}\n * @param {ArrayLike} arrayLike\n * @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}]\n * @returns {Array}\n */\n function sort (arrayLike) {\n var criteria = _makeCriteria(slice(arguments, 1));\n var data = [];\n var result = [];\n var len = arrayLike.length;\n\n for (var i = 0; i < len; i++) {\n data.push({\n value: arrayLike[i],\n index: i\n });\n }\n\n data.sort(_compareWith(criteria));\n\n for (i = 0; i < len; i++) {\n result.push(data[i].value);\n }\n\n return result;\n }\n\n /**\n * Inserts an element in a copy of a sorted array respecting the sort order.\n * @example with simple values\n * _.sortedInsert([], 1) // => [1]\n * _.sortedInsert([2, 4, 6], 5) // => [2, 4, 5, 6]\n * _.sortedInsert([4, 2, 1], 3, _.sorterDesc()) // => [4, 3, 2, 1]\n *\n * @example with complex values\n * var persons = [\n * {\"name\": \"jane\", \"surname\": \"doe\"},\n * {\"name\": \"John\", \"surname\": \"Doe\"},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * ];\n *\n * var getLowerCaseName = _.compose(\n * _.invoker(\"toLowerCase\"),\n * _.getKey(\"name\")\n * );\n *\n * var result = _.sortedInsert(\n * persons,\n * {\"name\": \"marco\", \"surname\": \"Rossi\"},\n * getLowerCaseName\n * );\n *\n * // `result` holds:\n * // [\n * // {\"name\": \"jane\", \"surname\": \"doe\"},\n * // {\"name\": \"John\", \"surname\": \"Doe\"},\n * // {\"name\": \"marco\", \"surname\": \"Rossi\"},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * // ]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}\n * @see {@link module:lamb.insert|insert}, {@link module:lamb.insertAt|insertAt} to insert the element at a specific index\n * @param {Array} array\n * @param {*} element\n * @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}] - The sorting criteria used to sort the array.\n * @returns {Array}\n */\n function sortedInsert (array, element) {\n var criteria = _makeCriteria(slice(arguments, 2));\n var result = array.concat();\n var idx = _getInsertionIndex(array, element, _compareWith(criteria), 0, array.length);\n\n result.splice(idx, 0, element);\n return result;\n }\n\n /**\n * Creates an ascending sort criterion with the provided reader and comparer.
\n * See {@link module:lamb.sort|sort} for various examples.\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorterDesc|sorterDesc}\n * @param {Function} [reader={@link module:lamb.identity|identity}] A function meant to generate a simple value from a complex one. The function should evaluate the array element and supply the value to be passed to the comparer.\n * @param {Function} [comparer] An optional custom comparer function.\n * @returns {Sorter}\n */\n var sorter = partial(_sorter, _, false, _);\n\n /**\n * Creates a descending sort criterion with the provided reader and comparer.
\n * See {@link module:lamb.sort|sort} for various examples.\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorter|sorter}\n * @param {Function} [reader={@link module:lamb.identity|identity}] A function meant to generate a simple value from a complex one. The function should evaluate the array element and supply the value to be passed to the comparer.\n * @param {Function} [comparer] An optional custom comparer function.\n * @returns {Sorter}\n */\n var sorterDesc = partial(_sorter, _, true, _);\n\n /**\n * Builds a partial application of {@link module:lamb.sort|sort} using the provided criteria. The returned\n * function expects the array-like object to sort.\n * As usual, sorting criteria are built using Lamb's {@link module:lamb.sorter|sorter} function, but you can also\n * pass simple \"reader\" functions and default ascending sorters will be built.
\n * A \"reader\" is a function that evaluates the array element and supplies the value to be used in the comparison.
\n * See {@link module:lamb.sort|sort} for more examples.\n *\n * @example\n * var sortAsNumbers = _.sortWith(parseFloat);\n * var weights = [\"2 Kg\", \"10 Kg\", \"1 Kg\", \"7 Kg\"];\n *\n * sortAsNumbers(weights) // => [\"1 Kg\", \"2 Kg\", \"7 Kg\", \"10 Kg\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.sort|sort}\n * @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}\n * @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}]\n * @returns {Function}\n */\n function sortWith () {\n var sorters = slice(arguments);\n\n return function (arrayLike) {\n return sort.apply(null, [arrayLike].concat(sorters));\n };\n }\n\n lamb.sort = sort;\n lamb.sortedInsert = sortedInsert;\n lamb.sorter = sorter;\n lamb.sorterDesc = sorterDesc;\n lamb.sortWith = sortWith;\n\n\n function _currier (fn, arity, isRightCurry, slicer, argsHolder) {\n return function () {\n var args = argsHolder.concat(slicer(arguments));\n\n if (args.length >= arity) {\n return fn.apply(this, isRightCurry ? args.reverse() : args);\n } else {\n return _currier(fn, arity, isRightCurry, slicer, args);\n }\n };\n }\n\n function _curry (fn, arity, isRightCurry, isAutoCurry) {\n var slicer = isAutoCurry ? slice : function (a) {\n return a.length ? [a[0]] : [];\n };\n\n if ((arity >>> 0) !== arity) {\n arity = fn.length;\n }\n\n return _currier(fn, arity, isRightCurry, slicer, []);\n }\n\n /**\n * Applies the passed function to the given argument list.\n * @example\n * _.apply(_.add, [3, 4]) // => 7\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {ArrayLike} args\n * @returns {*}\n */\n function apply (fn, args) {\n return fn.apply(fn, slice(args));\n }\n\n /**\n * A curried version of {@link module:lamb.apply|apply}. Expects an array-like object to use as arguments\n * and builds a function waiting for the target of the application.\n * @example\n * var data = [3, 4];\n * var applyDataTo = _.applyArgs(data);\n *\n * applyDataTo(_.add) // => 7\n * applyDataTo(_.multiply) // => 12\n *\n * @memberof module:lamb\n * @category Function\n * @function\n * @param {ArrayLike} args\n * @returns {Function}\n */\n var applyArgs = _curry(apply, 2, true);\n\n /**\n * Builds a function that passes only the specified amount of arguments to the given function.
\n * See also {@link module:lamb.binary|binary} and {@link module:lamb.unary|unary} for common use\n * cases shortcuts.\n * @example\n * var data = [\"1-2\", \"13-5\", \"6-23\"];\n * var getDashIndex = _.invoker(\"indexOf\", \"-\");\n *\n * data.map(getDashIndex) // => [1, 2, -1]\n * data.map(_.aritize(getDashIndex, 1)) // = > [1, 2, 1]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} arity\n * @returns {Function}\n */\n function aritize (fn, arity) {\n return function () {\n return apply(fn, slice(arguments, 0, arity));\n };\n }\n\n /**\n * Builds a function that passes only two arguments to the given function.
\n * It's simply a shortcut for a common use case of {@link module:lamb.aritize|aritize},\n * exposed for convenience.
\n * See also {@link module:lamb.unary|unary}.\n * @example\n * _.list(1, 2, 3, 4, 5) // => [1, 2, 3, 4, 5]\n * _.binary(_.list)(1, 2, 3, 4, 5) // => [1, 2]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @returns {Function}\n */\n function binary (fn) {\n return function (a, b) {\n return fn(a, b);\n };\n }\n\n /**\n * Transforms the evaluation of the given function in the evaluation of a sequence of functions\n * expecting only one argument. Each function of the sequence is a partial application of the\n * original one, which will be applied when the specified (or derived) arity is consumed.
\n * Currying will start from the leftmost argument: use {@link module:lamb.curryRight|curryRight}\n * for right currying.
\n * See also {@link module:lamb.curryable|curryable}, {@link module:lamb.curryableRight|curryableRight}\n * and {@link module:lamb.partial|partial}.\n * @example\n * var multiplyBy = _.curry(_.multiply);\n * var multiplyBy10 = multiplyBy(10);\n *\n * multiplyBy10(5) // => 50\n * multiplyBy10()(5) // => 50\n * multiplyBy10()()(2) // => 20\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curry (fn, arity) {\n return _curry(fn, arity, false);\n }\n\n /**\n * Same as {@link module:lamb.curry|curry}, but currying starts from the rightmost argument.\n * @example\n * var divideBy = _.curryRight(_.divide);\n * var halve = divideBy(2);\n * halve(3) // => 1.5\n * halve(3, 7) // => 1.5\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curryRight (fn, arity) {\n return _curry(fn, arity, true);\n }\n\n /**\n * Builds an auto-curried function. The resulting function can be called multiple times with\n * any number of arguments, and the original function will be applied only when the specified\n * (or derived) arity is consumed.
\n * Currying will start from the leftmost argument: use {@link module:lamb.curryableRight|curryableRight}\n * for right currying.
\n * Note that you can pass undefined values as arguments explicitly, if you are so inclined, but empty\n * calls doesn't consume the arity.
\n * See also {@link module:lamb.curry|curry}, {@link module:lamb.curryRight|curryRight} and\n * {@link module:lamb.partial|partial}.\n * @example\n * var collectFourElements = _.curryable(_.list, 4);\n *\n * collectFourElements(2)(3)(4)(5) // => [2, 3, 4, 5]\n * collectFourElements(2)(3, 4)(5) // => [2, 3, 4, 5]\n * collectFourElements(2, 3, 4, 5) // => [2, 3, 4, 5]\n * collectFourElements()(2)()(3, 4, 5) // => [2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curryable (fn, arity) {\n return _curry(fn, arity, false, true);\n }\n\n /**\n * Same as {@link module:lamb.curryable|curryable}, but currying starts from the rightmost argument.\n * @example\n * var collectFourElements = _.curryableRight(_.list, 4);\n *\n * collectFourElements(2)(3)(4)(5) // => [5, 4, 3, 2]\n * collectFourElements(2)(3, 4)(5) // => [5, 4, 3, 2]\n * collectFourElements(2, 3, 4, 5) // => [5, 4, 3, 2]\n * collectFourElements()(2)()(3, 4, 5) // => [5, 4, 3, 2]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curryableRight (fn, arity) {\n return _curry(fn, arity, true, true);\n }\n\n /**\n * Returns a function that will execute the given function only if it stops being called for the specified timespan.
\n * See also {@link module:lamb.throttle|throttle} for a different behaviour where the first call happens immediately.\n * @example A common use case of debounce in a browser environment\n * var updateLayout = function () {\n * // some heavy DOM operations here\n * };\n *\n * window.addEventListener(\"resize\", _.debounce(updateLayout, 200), false);\n *\n * // The resize event is fired repeteadly until the user stops resizing the\n * // window, while the `updateLayout` function is called only once: 200 ms\n * // after he stopped.\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} timespan - Expressed in milliseconds\n * @returns {Function}\n */\n function debounce (fn, timespan) {\n var timeoutID;\n\n return function () {\n var context = this;\n var args = arguments;\n var debounced = function () {\n timeoutID = null;\n fn.apply(context, args);\n };\n\n clearTimeout(timeoutID);\n timeoutID = setTimeout(debounced, timespan);\n };\n }\n\n /**\n * Returns a function that applies its arguments to the original function in reverse order.\n * @example\n * _.list(1, 2, 3) // => [1, 2, 3]\n * _.flip(_.list)(1, 2, 3) // => [3, 2, 1]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @returns {Function}\n */\n function flip (fn) {\n return function () {\n var args = slice(arguments).reverse();\n return fn.apply(this, args);\n };\n }\n\n /**\n * Builds a function that returns the argument received at the given index.
\n * As with {@link module:lamb.getAt|getAt} negative indexes are allowed.
\n * The resulting function will return undefined if no arguments are\n * passed or if the index is out of bounds.\n * @example\n * var getFirstArg = getArgAt(0);\n * var getLastArg = getArgAt(-1);\n *\n * getFirstArg(1, 2, 3) // => 1\n * getLastArg(1, 2, 3) // => 3\n *\n * getArgAt()(1, 2, 3) // => undefined\n * getArgAt(6)(1, 2, 3) // => undefined\n * getArgAt(1)() // => undefined\n *\n * @memberof module:lamb\n * @category Function\n * @param {Number} index\n * @returns {Function}\n */\n function getArgAt (index) {\n return compose(getAt(index), list);\n }\n\n /**\n * Builds a function that will invoke the given method name on any received object and return\n * the result. If no method with such name is found the function will return undefined.\n * Along with the method name it's possible to supply some arguments that will be bound to the method call.
\n * Further arguments can also be passed when the function is actually called, and they will be concatenated\n * to the bound ones.
\n * If different objects share a method name it's possible to build polymorphic functions as you can see in\n * the example below.
\n * {@link module:lamb.condition|Condition} can be used to wrap invoker to avoid this behaviour\n * by adding a predicate, while {@link module:lamb.adapter|adapter} can build more complex polymorphic functions\n * without the need of homonymy.
\n * Returning undefined or checking for such value is meant to favor composition and interoperability\n * between the aforementioned functions: for a more standard behaviour see also {@link module:lamb.generic|generic}.\n * See also {@link module:lamb.invokerOn|invokerOn}.\n * @example Basic polymorphism with invoker\n * var polySlice = _.invoker(\"slice\");\n *\n * polySlice([1, 2, 3, 4, 5], 1, 3) // => [2, 3]\n * polySlice(\"Hello world\", 1, 3) // => \"el\"\n *\n * @example With bound arguments\n * var substrFrom2 = _.invoker(\"substr\", 2);\n * substrFrom2(\"Hello world\") // => \"llo world\"\n * substrFrom2(\"Hello world\", 5) // => \"llo w\"\n *\n * @memberof module:lamb\n * @category Function\n * @param {String} methodName\n * @param {...*} [boundArg]\n * @returns {Function}\n */\n function invoker (methodName) {\n var boundArgs = slice(arguments, 1);\n\n return function (target) {\n var args = slice(arguments, 1);\n var method = target[methodName];\n return type(method) === \"Function\" ? method.apply(target, boundArgs.concat(args)) : void 0;\n };\n }\n\n /**\n * Accepts an object and builds a function expecting a method name, and optionally arguments, to call on such object.\n * Like {@link module:lamb.invoker|invoker}, if no method with the given name is found the function will return undefined.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var arr = [1, 2, 3, 4, 5];\n * var invokerOnArr = _.invokerOn(arr);\n *\n * invokerOnArr(\"filter\", isEven) // => [2, 4]\n * invokerOnArr(\"slice\", 1, 3) // => [2, 3]\n *\n * @memberof module:lamb\n * @category Function\n * @see {@link module:lamb.invoker|invoker}\n * @param {Object} target\n * @returns {Function}\n */\n function invokerOn (target) {\n return function (methodName) {\n var args = slice(arguments, 1);\n var method = target[methodName];\n return type(method) === \"Function\" ? method.apply(target, args) : void 0;\n };\n }\n\n /**\n * Builds a function that allows to map over the received arguments before applying them to the original one.\n * @example\n * var sumArray = _.invoker(\"reduce\", _.add);\n * var sum = _.compose(sumArray, _.list);\n *\n * sum(1, 2, 3, 4, 5) // => 15\n *\n * var square = _.partial(Math.pow, _, 2);\n * var sumSquares = _.mapArgs(sum, square);\n *\n * sumSquares(1, 2, 3, 4, 5) // => 55\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {ListIteratorCallback} mapper\n * @returns {Function}\n */\n function mapArgs (fn, mapper) {\n return compose(partial(apply, fn), mapWith(mapper), list);\n }\n\n /**\n * Creates a pipeline of functions, where each function consumes the result of the previous one.
\n * See also {@link module:lamb.compose|compose}.\n * @example\n * var square = _.partial(Math.pow, _, 2);\n * var getMaxAndSquare = _.pipe(Math.max, square);\n *\n * getMaxAndSquare(3, 5) // => 25\n *\n * @memberof module:lamb\n * @category Function\n * @function\n * @param {...Function} fn\n * @returns {Function}\n */\n var pipe = flip(compose);\n\n /**\n * Builds a function that allows to \"tap\" into the arguments of the original one.\n * This allows to extract simple values from complex ones, transform arguments or simply intercept them.\n * If a \"tapper\" isn't found the argument is passed as it is.\n * @example\n * var someObject = {count: 5};\n * var someArrayData = [2, 3, 123, 5, 6, 7, 54, 65, 76, 0];\n * var getDataAmount = _.tapArgs(_.add, _.getKey(\"count\"), _.getKey(\"length\"));\n *\n * getDataAmount(someObject, someArrayData); // => 15\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {...?Function} [tapper]\n * @returns {Function}\n */\n function tapArgs (fn) {\n var tappers = slice(arguments, 1);\n\n return function () {\n var len = arguments.length;\n var args = [];\n\n for (var i = 0; i < len; i++) {\n args.push(tappers[i] ? tappers[i](arguments[i]) : arguments[i]);\n }\n\n return fn.apply(this, args);\n };\n }\n\n /**\n * Returns a function that will invoke the passed function at most once in the given timespan.
\n * The first call in this case happens as soon as the function is invoked; see also {@link module:lamb.debounce|debounce}\n * for a different behaviour where the first call is delayed.\n * @example\n * var log = _.throttle(console.log.bind(console), 5000);\n *\n * log(\"Hi\"); // console logs \"Hi\"\n * log(\"Hi again\"); // nothing happens\n * // after five seconds\n * log(\"Hello world\"); // console logs \"Hello world\"\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} timespan - Expressed in milliseconds.\n * @returns {Function}\n */\n function throttle (fn, timespan) {\n var result;\n var lastCall = 0;\n\n return function () {\n var now = Date.now();\n\n if (now - lastCall >= timespan) {\n lastCall = now;\n result = fn.apply(this, arguments);\n }\n\n return result;\n };\n }\n\n /**\n * Builds a function that passes only one argument to the given function.
\n * It's simply a shortcut for a common use case of {@link module:lamb.aritize|aritize},\n * exposed for convenience.
\n * See also {@link module:lamb.binary|binary}.\n * @example\n * var weights = [\"2 Kg\", \"10 Kg\", \"1 Kg\", \"7 Kg\"];\n *\n * weights.map(_.unary(parseInt)) // => [2, 10, 1, 7]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @returns {Function}\n */\n function unary (fn) {\n return function (a) {\n return fn(a);\n };\n }\n\n /**\n * Wraps the function fn inside a wrapper function.
\n * This allows to conditionally execute fn, to tamper with its arguments or return value\n * and to run code before and after its execution.
\n * Being this nothing more than a \"{@link module:lamb.flip|flipped}\" [partial application]{@link module:lamb.partial},\n * you can also easily build new functions from existent ones.\n * @example\n * var arrayMax = _.wrap(Math.max, _.apply);\n *\n * arrayMax([4, 5, 2, 6, 1]) // => 6\n *\n * @memberof module:lamb\n * @category Function\n * @function\n * @param {Function} fn\n * @param {Function} wrapper\n * @returns {Function}\n */\n var wrap = binary(flip(partial));\n\n lamb.apply = apply;\n lamb.applyArgs = applyArgs;\n lamb.aritize = aritize;\n lamb.binary = binary;\n lamb.curry = curry;\n lamb.curryRight = curryRight;\n lamb.curryable = curryable;\n lamb.curryableRight = curryableRight;\n lamb.debounce = debounce;\n lamb.flip = flip;\n lamb.getArgAt = getArgAt;\n lamb.invoker = invoker;\n lamb.invokerOn = invokerOn;\n lamb.mapArgs = mapArgs;\n lamb.pipe = pipe;\n lamb.tapArgs = tapArgs;\n lamb.throttle = throttle;\n lamb.unary = unary;\n lamb.wrap = wrap;\n\n\n function _immutable (obj, seen) {\n if (seen.indexOf(obj) === -1) {\n seen.push(Object.freeze(obj));\n\n Object.getOwnPropertyNames(obj).forEach(function (key) {\n var value = obj[key];\n\n if (typeof value === \"object\" && !isNull(value)) {\n _immutable(value, seen);\n }\n });\n }\n\n return obj;\n }\n\n function _keyToPair (key) {\n return [key, this[key]];\n }\n\n function _merge (getKeys) {\n return reduce(slice(arguments, 1), function (result, source) {\n forEach(getKeys(source), function (key) {\n result[key] = source[key];\n });\n\n return result;\n }, {});\n }\n\n var _pairsFrom = _curry(function (getKeys, obj) {\n return getKeys(obj).map(_keyToPair, obj);\n });\n\n function _safeEnumerables (obj) {\n var keys = [];\n\n for (var key in obj) {\n keys.push(key);\n }\n\n return keys;\n }\n\n var _safeKeys = compose(Object.keys, Object);\n\n var _tearFrom = _curry(function (getKeys, obj) {\n return getKeys(obj).reduce(function (result, key) {\n result[0].push(key);\n result[1].push(obj[key]);\n return result;\n }, [[], []]);\n });\n\n var _unsafeKeyListFrom = _curry(function (getKeys, obj) {\n return (isNil(obj) ? Object.keys : getKeys)(obj);\n });\n\n var _valuesFrom = _curry(function (getKeys, obj) {\n return getKeys(obj).map(partial(getIn, obj));\n });\n\n /**\n * Builds a checker function meant to be used with {@link module:lamb.validate|validate}.
\n * Note that the function accepts multiple keyPaths as a means to compare their values. In\n * other words all the received keyPaths will be passed as arguments to the predicate\n * to run the test.
\n * If you want to run the same single property check with multiple properties, you should build\n * multiple checkers and combine them with {@link module:lamb.validate|validate}.\n * @example\n * var user = {\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * username: \"jdoe\",\n * password: \"abc123\",\n * passwordConfirm: \"abc123\"\n * }\n * };\n * var pwdMatch = _.checker(\n * _.is,\n * \"Passwords don't match\",\n * [\"login.password\", \"login.passwordConfirm\"]\n * );\n *\n * pwdMatch(user) // => []\n *\n * var newUser = _.setPathIn(user, \"login.passwordConfirm\", \"avc123\");\n *\n * pwdMatch(newUser) // => [\"Passwords don't match\", [\"login.password\", \"login.passwordConfirm\"]]\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.validate|validate}, {@link module:lamb.validateWith|validateWith}\n * @param {Function} predicate - The predicate to test the object properties\n * @param {String} message - The error message\n * @param {String[]} keyPaths - The array of property names, or {@link module:lamb.getPathIn|paths}, to test.\n * @param {String} [pathSeparator=\".\"]\n * @returns {Array} An error in the form [\"message\", [\"propertyA\", \"propertyB\"]] or an empty array.\n */\n function checker (predicate, message, keyPaths, pathSeparator) {\n return function (obj) {\n var getValues = partial(getPathIn, obj, _, pathSeparator);\n return predicate.apply(obj, keyPaths.map(getValues)) ? [] : [message, keyPaths];\n };\n }\n\n /**\n * Creates an array with all the enumerable properties of the given object.\n * @example Showing the difference with {@link module:lamb.keys|keys}\n * var baseFoo = Object.create({a: 1}, {b: {value: 2}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3},\n * d: {value: 4, enumerable: true}\n * });\n *\n * _.keys(foo) // => [\"d\"]\n * _.enumerables(foo) // => [\"d\", \"a\"]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.keys|keys}\n * @param {Object} obj\n * @returns {String[]}\n */\n var enumerables = _unsafeKeyListFrom(_safeEnumerables);\n\n /**\n * Builds an object from a list of key / value pairs like the one\n * returned by [pairs]{@link module:lamb.pairs} or {@link module:lamb.ownPairs|ownPairs}.
\n * In case of duplicate keys the last key / value pair is used.\n * @example\n * _.fromPairs([[\"a\", 1], [\"b\", 2], [\"c\", 3]]) // => {\"a\": 1, \"b\": 2, \"c\": 3}\n * _.fromPairs([[\"a\", 1], [\"b\", 2], [\"a\", 3]]) // => {\"a\": 3, \"b\": 2}\n * _.fromPairs([[1], [void 0, 2], [null, 3]]) // => {\"1\": undefined, \"undefined\": 2, \"null\": 3}\n *\n * @memberof module:lamb\n * @category Object\n * @param {Array>} pairsList\n * @returns {Object}\n */\n function fromPairs (pairsList) {\n var result = {};\n\n pairsList.forEach(function (pair) {\n result[pair[0]] = pair[1];\n });\n\n return result;\n }\n\n /**\n * Verifies the existence of a property in an object.\n * @example\n * var user1 = {name: \"john\"};\n *\n * _.has(user1, \"name\") // => true\n * _.has(user1, \"surname\") // => false\n * _.has(user1, \"toString\") // => true\n *\n * var user2 = Object.create(null);\n *\n * // not inherited through the prototype chain\n * _.has(user2, \"toString\") // => false\n *\n * @memberof module:lamb\n * @category Object\n * @param {Object} obj\n * @param {String} key\n * @returns {Boolean}\n */\n function has (obj, key) {\n return key in obj;\n }\n\n /**\n * Curried version of {@link module:lamb.has|has}.
\n * Returns a function expecting the object to check against the given key.\n * @example\n * var user1 = {name: \"john\"};\n * var user2 = {};\n * var hasName = _.hasKey(\"name\");\n *\n * hasName(user1) // => true\n * hasName(user2) // => false\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {String} key\n * @returns {Function}\n */\n var hasKey = _curry(has, 2, true);\n\n /**\n * Builds a function expecting an object to check against the given key / value pair.\n * @example\n * var hasTheCorrectAnswer = _.hasKeyValue(\"answer\", 42);\n *\n * hasTheCorrectAnswer({answer: 2}) // false\n * hasTheCorrectAnswer({answer: 42}) // true\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {String} key\n * @param {*} value\n * @returns {Function}\n */\n var hasKeyValue = function (key, value) {\n return compose(partial(is, value), getKey(key));\n };\n\n /**\n * Verifies if an object has the specified property and that the property isn't inherited through\n * the prototype chain.
\n * @example Comparison with has.\n * var user = {name: \"john\"};\n *\n * _.has(user, \"name\") // => true\n * _.has(user, \"surname\") // => false\n * _.has(user, \"toString\") // => true\n *\n * _.hasOwn(user, \"name\") // => true\n * _.hasOwn(user, \"surname\") // => false\n * _.hasOwn(user, \"toString\") // => false\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @param {String} key\n * @returns {Boolean}\n */\n var hasOwn = generic(_objectProto.hasOwnProperty);\n\n /**\n * Curried version of {@link module:lamb.hasOwn|hasOwn}.
\n * Returns a function expecting the object to check against the given key.\n * @example\n * var user = {name: \"john\"};\n * var hasOwnName = _.hasOwnKey(\"name\");\n * var hasOwnToString = _.hasOwnToString(\"toString\");\n *\n * hasOwnName(user) // => true\n * hasOwnToString(user) // => false\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {String} key\n * @returns {Function}\n */\n var hasOwnKey = _curry(hasOwn, 2, true);\n\n /**\n * Makes an object immutable by recursively calling [Object.freeze]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze}\n * on its members.
\n * Any attempt to extend or modify the object can throw a TypeError or fail silently,\n * depending on the environment and the [strict mode]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode} directive.\n * @example\n * var user = _.immutable({\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * username: \"jdoe\",\n * password: \"abc123\"\n * },\n * luckyNumbers: [13, 17]\n * });\n *\n * // All of these statements will fail and possibly\n * // throw a TypeError (see the function description)\n * user.name = \"Joe\";\n * delete user.name;\n * user.newProperty = [];\n * user.login.password = \"foo\";\n * user.luckyNumbers.push(-13);\n *\n * @memberof module:lamb\n * @category Object\n * @param {Object} obj\n * @returns {Object}\n */\n function immutable (obj) {\n return _immutable(obj, []);\n }\n\n /**\n * Retrieves the list of the own enumerable properties of an object.
\n * Although [Object.keys]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys}\n * is already present in ECMAScript 5, its behaviour changed in the subsequent specifications\n * of the standard as you can read in the link above.
\n * This function shims the ECMAScript 6 version, by forcing a conversion to\n * object for any value but null and undefined.\n * @example Showing the difference with {@link module:lamb.enumerables|enumerables}\n * var baseFoo = Object.create({a: 1}, {b: {value: 2}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3},\n * d: {value: 4, enumerable: true}\n * });\n *\n * _.enumerables(foo) // => [\"d\", \"a\"]\n * _.keys(foo) // => [\"d\"]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.enumerables|enumerables}\n * @param {Object} obj\n * @returns {String[]}\n */\n var keys = _unsafeKeyListFrom(_safeKeys);\n\n /**\n * Builds an object from the two given lists, using the first one as keys and the last one as values.
\n * If the list of keys is longer than the values one, the keys will be created with undefined values.
\n * If more values than keys are supplied, the extra values will be ignored.
\n * See also {@link module:lamb.tear|tear} and {@link module:lamb.tearOwn|tearOwn} for the reverse operation.\n * @example\n * _.make([\"a\", \"b\", \"c\"], [1, 2, 3]) // => {a: 1, b: 2, c: 3}\n * _.make([\"a\", \"b\", \"c\"], [1, 2]) // => {a: 1, b: 2, c: undefined}\n * _.make([\"a\", \"b\"], [1, 2, 3]) // => {a: 1, b: 2}\n * _.make([null, void 0, 2], [1, 2, 3]) // => {\"null\": 1, \"undefined\": 2, \"2\": 3}\n *\n * @memberof module:lamb\n * @category Object\n * @param {String[]} keys\n * @param {Array} values\n * @returns {Object}\n */\n function make (keys, values) {\n var result = {};\n var valuesLen = values.length;\n\n for (var i = 0, len = keys.length; i < len; i++) {\n result[keys[i]] = i < valuesLen ? values[i] : void 0;\n }\n\n return result;\n }\n\n /**\n * Merges the enumerable properties of the provided sources into a new object.
\n * In case of key homonymy each source has precedence over the previous one.
\n * See also {@link module:lamb.mergeOwn|mergeOwn} for merging only own properties of\n * the given sources.\n * @example\n * _.merge({a: 1}, {b: 3, c: 4}, {b: 5}) // => {a: 1, b: 5, c: 4}\n *\n * @example Arrays or array-like objects will be transformed to objects with numbers as keys:\n * _.merge([1, 2], {a: 2}) // => {\"0\": 1, \"1\": 2, a: 2}\n * _.merge(\"foo\", {a: 2}) // => {\"0\": \"f\", \"1\": \"o\", \"2\": \"o\", a: 2}\n *\n * @example Every other value will be treated as an empty object:\n * _.merge({a: 2}, null, NaN) // => {a: 2}\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {...Object} source\n * @returns {Object}\n */\n var merge = partial(_merge, _safeEnumerables);\n\n /**\n * Same as {@link module:lamb.merge|merge}, but only the own properties of the sources are taken into account.\n * @example showing the difference with merge:\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * var bar = {d: 4};\n *\n * _.merge(foo, bar) // => {a: 1, b: 2, c: 3, d: 4}\n * _.mergeOwn(foo, bar) // => {c: 3, d: 4}\n *\n * @example Arrays or array-like objects will be transformed to objects with numbers as keys:\n * _.mergeOwn([1, 2], {a: 2}) // => {\"0\": 1, \"1\": 2, a: 2}\n * _.mergeOwn(\"foo\", {a: 2}) // => {\"0\": \"f\", \"1\": \"o\", \"2\": \"o\", a: 2}\n *\n * @example Every other value will be treated as an empty object:\n * _.mergeOwn({a: 2}, null, NaN) // => {a: 2}\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {...Object} source\n * @returns {Object}\n */\n var mergeOwn = partial(_merge, _safeKeys);\n\n /**\n * Same as {@link module:lamb.pairs|pairs}, but only the own enumerable properties of the object are\n * taken into account.
\n * See also {@link module:lamb.fromPairs|fromPairs} for the reverse operation.\n * @example showing the difference with pairs\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * _.pairs(foo) // => [[\"c\", 3], [\"b\", 2], [\"a\", 1]]\n * _.ownPairs(foo) // => [[\"c\", 3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array>}\n */\n var ownPairs = _pairsFrom(keys);\n\n /**\n * Same as {@link module:lamb.values|values}, but only the own enumerable properties of the object are\n * taken into account.
\n * @example showing the difference with values\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * _.values(foo) // => [3, 2, 1]\n * _.ownValues(foo) // => [3]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array}\n */\n var ownValues = _valuesFrom(keys);\n\n /**\n * Converts an object into an array of key / value pairs of its enumerable properties.
\n * See also {@link module:lamb.ownPairs|ownPairs} for picking only the own enumerable\n * properties and {@link module:lamb.fromPairs|fromPairs} for the reverse operation.\n * @example\n * _.pairs({a: 1, b: 2, c: 3}) // => [[\"a\", 1], [\"b\", 2], [\"c\", 3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array>}\n */\n var pairs = _pairsFrom(enumerables);\n\n /**\n * Returns an object containing only the specified properties of the given object.
\n * Non existent properties will be ignored.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n *\n * _.pick(user, [\"name\", \"age\"]) // => {\"name\": \"john\", \"age\": 30};\n * _.pick(user, [\"name\", \"email\"]) // => {\"name\": \"john\"}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.pickIf|pickIf}\n * @param {Object} source\n * @param {String[]} whitelist\n * @returns {Object}\n */\n function pick (source, whitelist) {\n var result = {};\n\n whitelist.forEach(function (key) {\n if (key in source) {\n result[key] = source[key];\n }\n });\n\n return result;\n }\n\n /**\n * Builds a function expecting an object whose properties will be checked against the given predicate.
\n * The properties satisfying the predicate will be included in the resulting object.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n * var pickIfIsString = _.pickIf(_.isType(\"String\"));\n *\n * pickIfIsString(user) // => {name: \"john\", surname: \"doe\"}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.pick|pick}\n * @param {ObjectIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function pickIf (predicate, predicateContext) {\n return function (source) {\n var result = {};\n\n for (var key in source) {\n if (predicate.call(predicateContext, source[key], key, source)) {\n result[key] = source[key];\n }\n }\n\n return result;\n };\n }\n\n /**\n * Creates a copy of the given object with its enumerable keys renamed as\n * indicated in the provided lookup table.\n * @example\n * var person = {\"firstName\": \"John\", \"lastName\": \"Doe\"};\n * var keysMap = {\"firstName\": \"name\", \"lastName\": \"surname\"};\n *\n * _.rename(person, keysMap) // => {\"name\": \"John\", \"surname\": \"Doe\"}\n *\n * @example It's safe using it to swap keys:\n * var keysMap = {\"firstName\": \"lastName\", \"lastName\": \"firstName\"};\n *\n * _.rename(person, keysMap) // => {\"lastName\": \"John\", \"firstName\": \"Doe\"}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.renameKeys|renameKeys}, {@link module:lamb.renameWith|renameWith}\n * @param {Object} source\n * @param {Object} keysMap\n * @returns {Object}\n */\n function rename (source, keysMap) {\n keysMap = Object(keysMap);\n var result = {};\n var oldKeys = enumerables(source);\n\n for (var prop in keysMap) {\n if (~oldKeys.indexOf(prop)) {\n result[keysMap[prop]] = source[prop];\n }\n }\n\n for (var i = 0, len = oldKeys.length, key; i < len; i++) {\n key = oldKeys[i];\n\n if (!(key in keysMap || key in result)) {\n result[key] = source[key];\n }\n }\n\n return result;\n }\n\n /**\n * A curried version of {@link module:lamb.rename|rename} expecting a\n * keysMap to build a function waiting for the object to act upon.\n * @example\n * var persons = [\n * {\"firstName\": \"John\", \"lastName\": \"Doe\"},\n * {\"first_name\": \"Mario\", \"last_name\": \"Rossi\"},\n * ];\n * var normalizeKeys = _.renameKeys({\n * \"firstName\": \"name\",\n * \"first_name\": \"name\",\n * \"lastName\": \"surname\",\n * \"last_name\": \"surname\"\n * });\n *\n * persons.map(normalizeKeys) // => [{\"name\": \"John\", \"surname\": \"Doe\"}, {\"name\": \"Mario\", \"surname\": \"Rossi\"}]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.rename|rename}, {@link module:lamb.renameWith|renameWith}\n * @param {Object} keysMap\n * @returns {Function}\n */\n var renameKeys = _curry(rename, 2, true);\n\n /**\n * Uses the provided function as a keysMap generator and returns\n * a function expecting the object whose keys we want to {@link module:lamb.rename|rename}.\n * @example\n * var person = {\"NAME\": \"John\", \"SURNAME\": \"Doe\"};\n * var makeLowerKeysMap = function (source) {\n * var sourceKeys = _.keys(source);\n * return _.make(sourceKeys, sourceKeys.map(_.invoker(\"toLowerCase\")));\n * };\n * var lowerKeysFor = _.renameWith(makeLowerKeysMap);\n *\n * lowerKeysFor(person) // => {\"name\": \"John\", \"surname\": \"doe\"};\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.rename|rename}, {@link module:lamb.renameKeys|renameKeys}\n * @param {Function} fn\n * @returns {Function}\n */\n function renameWith (fn) {\n return function (source) {\n return rename(source, fn(source));\n };\n }\n\n /**\n * Returns a copy of the source object without the specified properties.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n *\n * _.skip(user, [\"name\", \"age\"]) // => {surname: \"doe\"};\n * _.skip(user, [\"name\", \"email\"]) // => {surname: \"doe\", age: 30};\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.skipIf|skipIf}\n * @param {Object} source\n * @param {String[]} blacklist\n * @returns {Object}\n */\n function skip (source, blacklist) {\n var result = {};\n\n for (var key in source) {\n if (blacklist.indexOf(key) === -1) {\n result[key] = source[key];\n }\n }\n\n return result;\n }\n\n /**\n * Builds a function expecting an object whose properties will be checked against the given predicate.
\n * The properties satisfying the predicate will be omitted in the resulting object.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n * var skipIfIstring = _.skipIf(_.isType(\"String\"));\n *\n * skipIfIstring(user) // => {age: 30}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.skip|skip}\n * @param {ObjectIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function skipIf (predicate, predicateContext) {\n return pickIf(not(predicate), predicateContext);\n }\n\n /**\n * Tears an object apart by transforming it in an array of two lists: one containing its enumerable keys,\n * the other containing the corresponding values.
\n * Although this \"tearing apart\" may sound as a rather violent process, the source object will be unharmed.
\n * See also {@link module:lamb.tearOwn|tearOwn} for picking only the own enumerable properties and\n * {@link module:lamb.make|make} for the reverse operation.\n * @example\n * _.tear({a: 1, b: 2, c: 3}) // => [[\"a\", \"b\", \"c\"], [1, 2, 3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array, Array<*>>}\n */\n var tear = _tearFrom(enumerables);\n\n /**\n * Same as {@link module:lamb.tear|tear}, but only the own properties of the object are taken into account.
\n * See also {@link module:lamb.make|make} for the reverse operation.\n * @example showing the difference with tear\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * _.tear(foo) // => [[\"c\", \"b\", \"a\"], [3, 2, 1]]\n * _.tearOwn(foo) // => [[\"c\"], [3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array, Array<*>>}\n */\n var tearOwn = _tearFrom(keys);\n\n /**\n * Validates an object with the given list of {@link module:lamb.checker|checker} functions.\n * @example\n * var hasContent = function (s) { return s.trim().length > 0; };\n * var isAdult = function (age) { return age >= 18; };\n * var userCheckers = [\n * _.checker(hasContent, \"Name is required\", [\"name\"]),\n * _.checker(hasContent, \"Surname is required\", [\"surname\"]),\n * _.checker(isAdult, \"Must be at least 18 years old\", [\"age\"])\n * ];\n *\n * var user1 = {name: \"john\", surname: \"doe\", age: 30};\n * var user2 = {name: \"jane\", surname: \"\", age: 15};\n *\n * _.validate(user1, userCheckers) // => []\n * _.validate(user2, userCheckers) // => [[\"Surname is required\", [\"surname\"]], [\"Must be at least 18 years old\", [\"age\"]]]\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.validateWith|validateWith}\n * @see {@link module:lamb.checker|checker}\n * @param {Object} obj\n * @param {Function[]} checkers\n * @returns {Array>} An array of errors in the form returned by {@link module:lamb.checker|checker}, or an empty array.\n */\n function validate (obj, checkers) {\n return checkers.reduce(function (errors, checker) {\n var result = checker(obj);\n result.length && errors.push(result);\n return errors;\n }, []);\n }\n\n /**\n * A curried version of {@link module:lamb.validate|validate} accepting a list of {@link module:lamb.checker|checkers} and\n * returning a function expecting the object to validate.\n * @example\n * var hasContent = function (s) { return s.trim().length > 0; };\n * var isAdult = function (age) { return age >= 18; };\n * var userCheckers = [\n * _.checker(hasContent, \"Name is required\", [\"name\"]),\n * _.checker(hasContent, \"Surname is required\", [\"surname\"]),\n * _.checker(isAdult, \"Must be at least 18 years old\", [\"age\"])\n * ];\n * var validateUser = _.validateWith(userCheckers);\n *\n * var user1 = {name: \"john\", surname: \"doe\", age: 30};\n * var user2 = {name: \"jane\", surname: \"\", age: 15};\n *\n * validateUser(user1) // => []\n * validateUser(user2) // => [[\"Surname is required\", [\"surname\"]], [\"Must be at least 18 years old\", [\"age\"]]]\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.validate|validate}\n * @see {@link module:lamb.checker|checker}\n * @function\n * @param {Function[]} checkers\n * @returns {Function}\n */\n var validateWith = _curry(validate, 2, true);\n\n /**\n * Generates an array with the values of the enumerable properties of the given object.
\n * See also {@link module:lamb.ownValues|ownValues} for picking only the own properties of the object.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n *\n * _.values(user) // => [\"john\", \"doe\", 30]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array}\n */\n var values = _valuesFrom(enumerables);\n\n lamb.checker = checker;\n lamb.enumerables = enumerables;\n lamb.fromPairs = fromPairs;\n lamb.has = has;\n lamb.hasKey = hasKey;\n lamb.hasKeyValue = hasKeyValue;\n lamb.hasOwn = hasOwn;\n lamb.hasOwnKey = hasOwnKey;\n lamb.immutable = immutable;\n lamb.keys = keys;\n lamb.make = make;\n lamb.merge = merge;\n lamb.mergeOwn = mergeOwn;\n lamb.ownPairs = ownPairs;\n lamb.ownValues = ownValues;\n lamb.pairs = pairs;\n lamb.pick = pick;\n lamb.pickIf = pickIf;\n lamb.rename = rename;\n lamb.renameKeys = renameKeys;\n lamb.renameWith = renameWith;\n lamb.skip = skip;\n lamb.skipIf = skipIf;\n lamb.tear = tear;\n lamb.tearOwn = tearOwn;\n lamb.validate = validate;\n lamb.validateWith = validateWith;\n lamb.values = values;\n\n\n function _getPadding (source, char, len) {\n return repeat(char[0] || \" \", Math.ceil(len - source.length));\n }\n\n /**\n * Pads a string to the desired length with the given char starting from the beginning of the string.\n * @example\n * _.padLeft(\"foo\", \"-\", 0) // => \"foo\"\n * _.padLeft(\"foo\", \"-\", -1) // => \"foo\"\n * _.padLeft(\"foo\", \"-\", 5) // => \"--foo\"\n * _.padLeft(\"foo\", \"-\", 3) // => \"foo\"\n * _.padLeft(\"foo\", \"ab\", 7) // => \"aaaafoo\"\n * _.padLeft(\"foo\", \"\", 5) // => \" foo\"\n * _.padLeft(\"\", \"-\", 5) // => \"-----\"\n *\n * @memberof module:lamb\n * @category String\n * @param {String} source\n * @param {String} [char=\" \"] - The padding char. If a string is passed only the first char is used.\n * @param {Number} len\n * @returns {String}\n */\n function padLeft (source, char, len) {\n return _getPadding(source, char, len) + source;\n }\n\n /**\n * Pads a string to the desired length with the given char starting from the end of the string.\n * @example\n * _.padRight(\"foo\", \"-\", 0) // => \"foo\"\n * _.padRight(\"foo\", \"-\", -1) // => \"foo\"\n * _.padRight(\"foo\", \"-\", 5) // => \"foo--\"\n * _.padRight(\"foo\", \"-\", 3) // => \"foo\"\n * _.padRight(\"foo\", \"ab\", 7) // => \"fooaaaa\"\n * _.padRight(\"foo\", \"\", 5) // => \"foo \"\n * _.padRight(\"\", \"-\", 5) // => \"-----\"\n *\n * @memberof module:lamb\n * @category String\n * @param {String} source\n * @param {String} [char=\" \"] - The padding char. If a string is passed only the first char is used.\n * @param {Number} len\n * @returns {String}\n */\n function padRight (source, char, len) {\n return source + _getPadding(source, char, len);\n }\n\n /**\n * Builds a new string by repeating the source string the desired amount of times.
\n * Note that unlike the current ES6 proposal for [String.prototype.repeat]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat},\n * this function doesn't throw a RangeError if count is negative, but returns an empty string instead.\n * @example\n * _.repeat(\"Hello\", -1) // => \"\"\n * _.repeat(\"Hello\", 1) // => \"Hello\"\n * _.repeat(\"Hello\", 3) // => \"HelloHelloHello\"\n *\n * @memberof module:lamb\n * @category String\n * @param {String} source\n * @param {Number} count\n * @returns {String}\n */\n function repeat (source, count) {\n var result = \"\";\n\n for (var i = 0; i < count; i++) {\n result += source;\n }\n\n return result;\n }\n\n /**\n * Builds a predicate expecting a string to test against the given regular expression pattern.\n * @example\n * var hasNumbersOnly = _.testWith(/^\\d+$/);\n *\n * hasNumbersOnly(\"123\") // => true\n * hasNumbersOnly(\"123 Kg\") // => false\n *\n * @memberof module:lamb\n * @category String\n * @param {RegExp} pattern\n * @returns {Function}\n */\n function testWith (pattern) {\n return _reProto.test.bind(pattern);\n }\n\n lamb.padLeft = padLeft;\n lamb.padRight = padRight;\n lamb.repeat = repeat;\n lamb.testWith = testWith;\n\n /* istanbul ignore next */\n if (typeof exports === \"object\") {\n module.exports = lamb;\n } else if (typeof define === \"function\" && define.amd) {\n define(function() { return lamb; });\n } else {\n host.lamb = lamb;\n }\n}(this);\n\n/**\n * @callback AccumulatorCallback\n * @global\n * @param {*} previousValue The value returned it the last execution of the accumulator or, in the first iteration, the {@link module:lamb.reduce|initialValue} if supplied.\n * @param {*} currentValue The value being processed in the current iteration.\n * @param {Number} idx - The index of the element being processed.\n * @param {ArrayLike} arrayLike - The list being traversed.\n */\n\n/**\n * The built-in arguments object.\n * @typedef {arguments} arguments\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments|arguments} in Mozilla documentation.\n */\n\n/**\n * The built-in Array object.\n * @typedef {Array} Array\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array|Array} in Mozilla documentation.\n */\n\n/**\n * Any array-like object.\n * @typedef {Array|String|arguments|?} ArrayLike\n * @global\n */\n\n/**\n * The built-in Boolean object.\n * @typedef {Boolean} Boolean\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean|Boolean} in Mozilla documentation.\n */\n\n/**\n * The built-in Date object.\n * @typedef {Date} Date\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date|Date} in Mozilla documentation.\n */\n\n/**\n * The built-in Function object.\n * @typedef {Function} function\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function|Function} and\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions|Functions} in Mozilla documentation.\n */\n\n/**\n * @callback ListIteratorCallback\n * @global\n * @param {*} element - The element being evaluated.\n * @param {Number} idx - The index of the element within the list.\n * @param {ArrayLike} arrayLike - The list being traversed.\n */\n\n/**\n * The built-in Number object.\n * @typedef {Number} Number\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number|Number} in Mozilla documentation.\n */\n\n/**\n * The built-in Object object.\n * @typedef {Object} Object\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object|Object} in Mozilla documentation.\n */\n\n/**\n * @callback ObjectIteratorCallback\n * @global\n * @param {*} value - The value of the current property.\n * @param {String} key - The property name.\n * @param {Object} source - The object being traversed.\n */\n\n/**\n * The built-in RegExp object.\n * @typedef {RegExp} RegExp\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp|RegExp} in Mozilla documentation.\n */\n\n/**\n * Represent a sorting criteria used by {@link module:lamb.sortedInsert|sortedInsert}, {@link module:lamb.sort|sort} and {@link module:lamb.sortWith|sortWith},\n * and it's usually built using {@link module:lamb.sorter|sorter} and {@link module:lamb.sorterDesc|sorterDesc}.\n * @typedef {Sorter} Sorter\n * @global\n * @property {Boolean} isDescending\n * @property {Function} compare\n */\n\n/**\n * The built-in String object.\n * @typedef {String} String\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String|String} in Mozilla documentation.\n */\n"],"sourceRoot":"/source/"} \ No newline at end of file +{"version":3,"sources":["lamb.js"],"names":["host","always","value","compose","functions","arguments","args","len","length","apply","this","identity","partial","fn","slice","boundArg","lastArgumentIdx","newArgs","argsLen","i","_","push","adapter","result","isUndefined","allOf","predicates","every","predicate","anyOf","some","condition","trueFn","falseFn","applyArgsTo","applyArgs","is","a","b","isSVZ","isGT","isGTE","isLT","isLTE","not","add","clamp","n","min","max","divide","generate","start","iteratee","iterateeContext","limit","call","modulo","Math","floor","multiply","randomInt","random","range","step","ceil","remainder","subtract","isNull","isType","typeName","type","_objectProto","toString","replace","_getNaturalIndex","index","_isInteger","_getPathInfo","obj","parts","currentKey","idx","target","_isIndex","_isEnumerable","isValid","key","Array","isArray","parseInt","Object","_isOwnEnumerable","_safeEnumerables","indexOf","_setIndex","arrayLike","updater","_setPathIn","v","setIn","getIn","getIndex","getPath","path","separator","getPathIn","split","reduce","tapArgs","Number","setAt","source","_merge","make","setKey","setPath","setPathIn","updateAt","updateIn","updateKey","updatePath","updatePathIn","pathInfo","_findSliceEndIndex","predicateContext","_flatten","array","output","forEach","contains","fromIndex","isIn","difference","rest","shallowFlatten","isInRest","filter","dropWhile","filterWith","find","element","findIndex","flatMapWith","flatMap","flatten","insert","splice","insertAt","intersection","uniques","item","list","mapWith","map","partition","el","partitionWith","pluck","getKey","pluckKey","reduceRightWith","accumulator","initialValue","reduceRight","binary","reduceWith","reverse","_arrayProto","concat","takeWhile","transpose","j","minLen","seen","_groupWith","makeValue","startValue","countBy","count","groupBy","group","indexBy","_comparer","String","_compareWith","criteria","isDescSort","criterion","compare","isDescending","_getInsertionIndex","comparer","end","pivot","_makeCriteria","sorters","_makeCriterion","_sorter","reader","sort","data","sortedInsert","sortWith","_currier","arity","isRightCurry","slicer","argsHolder","_curry","isAutoCurry","aritize","curry","curryRight","curryable","curryableRight","debounce","timespan","timeoutID","context","debounced","clearTimeout","setTimeout","flip","getArgAt","getAt","invoker","methodName","boundArgs","method","invokerOn","mapArgs","mapper","tappers","throttle","lastCall","now","Date","unary","_immutable","freeze","getOwnPropertyNames","_keyToPair","getKeys","keys","checker","message","keyPaths","pathSeparator","getValues","fromPairs","pairsList","pair","has","immutable","values","valuesLen","pick","whitelist","pickIf","rename","keysMap","oldKeys","enumerables","prop","renameWith","skip","blacklist","skipIf","validate","checkers","errors","_getPadding","char","repeat","padLeft","padRight","testWith","pattern","_reProto","test","bind","lamb","create","_version","prototype","RegExp","generic","Function","isNot","isNil","propertyIsEnumerable","head","last","setIndex","updateIndex","drop","dropN","init","tail","take","takeN","union","zip","zipWithIndex","sorter","sorterDesc","pipe","wrap","_pairsFrom","_safeKeys","_tearFrom","_unsafeKeyListFrom","_valuesFrom","hasKey","hasKeyValue","hasOwn","hasOwnProperty","hasOwnKey","merge","mergeOwn","ownPairs","ownValues","pairs","renameKeys","tear","tearOwn","validateWith","exports","module","define","amd"],"mappings":";;;;;;;;CAQC,SAAUA,GACP,YA4CA,SAASC,GAAQC,GACb,MAAO,YACH,MAAOA,IA4Bf,QAASC,KACL,GAAIC,GAAYC,SAEhB,OAA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ACfO,GAAKN,SAAWA,GAChBM,GAAKR,OAASA,GACdQ,GAAKL,SAAWA,GAGO,gBAAZmD,SACPC,OAAOD,QAAU9C,GACQ,kBAAXgD,SAAyBA,OAAOC,IAC9CD,OAAO,WAAa,MAAOhD,MAE3B1R,EAAK0R,KAAOA,IAElBhR","file":"lamb.min.js","sourcesContent":["/**\n * @overview lamb - A lightweight, and docile, JavaScript library to help embracing functional programming.\n * @author Andrea Scartabelli \n * @version 0.27.0\n * @module lamb\n * @license MIT\n * @preserve\n */\n!function (host) {\n \"use strict\";\n\n var lamb = Object.create(null);\n\n /**\n * The current module version.\n * @memberof module:lamb\n * @private\n * @category Core\n * @type String\n */\n lamb._version = \"0.27.0\";\n\n // alias used as a placeholder argument for partial application\n var _ = lamb;\n\n // some prototype shortcuts for internal use\n var _arrayProto = Array.prototype;\n var _objectProto = Object.prototype;\n var _reProto = RegExp.prototype;\n\n /**\n * Builds a function that returns a constant value.\n * It's actually the simplest form of the K combinator or Kestrel.\n * @example\n * var truth = _.always(true);\n *\n * truth() // => true\n * truth(false) // => true\n * truth(1, 2) // => true\n *\n * // the value being returned is actually the\n * // very same value passed to the function\n * var foo = {bar: \"baz\"};\n * var alwaysFoo = _.always(foo);\n *\n * alwaysFoo() === foo // => true\n *\n * @memberof module:lamb\n * @category Core\n * @see [SKI combinator calculus]{@link https://en.wikipedia.org/wiki/SKI_combinator_calculus}\n * @param {*} value\n * @returns {Function}\n */\n function always (value) {\n return function () {\n return value;\n };\n }\n\n /**\n * Returns a function that is the composition of the functions given as parameters.\n * Each function consumes the result of the function that follows.\n * @example\n * var sayHi = function (name) { return \"Hi, \" + name; };\n * var capitalize = function (s) {\n * return s[0].toUpperCase() + s.substr(1).toLowerCase();\n * };\n * var fixNameAndSayHi = _.compose(sayHi, capitalize);\n *\n * sayHi(\"bOb\") // => \"Hi, bOb\"\n * fixNameAndSayHi(\"bOb\") // \"Hi, Bob\"\n *\n * var getName = _.getKey(\"name\");\n * var users = [{name: \"fred\"}, {name: \"bOb\"}];\n * var sayHiToUser = _.compose(fixNameAndSayHi, getName);\n *\n * users.map(sayHiToUser) // [\"Hi, Fred\", \"Hi, Bob\"]\n *\n * @memberof module:lamb\n * @category Function\n * @param {...Function} fn\n * @returns {Function}\n */\n function compose () {\n var functions = arguments;\n\n return function () {\n var args = arguments;\n var len = functions.length;\n\n while (len--) {\n args = [functions[len].apply(this, args)];\n }\n\n return args[0];\n };\n }\n\n /**\n * Creates generic functions out of methods.\n * @memberof module:lamb\n * @category Core\n * @author A very little change on a great idea by [Irakli Gozalishvili]{@link https://github.com/Gozala/}. Thanks for this *beautiful* one-liner (never liked your \"unbind\" naming choice, though).\n * @function\n * @example\n * // Lamb's \"filter\" is actually implemented like this\n * var filter = _.generic(Array.prototype.filter);\n * var isLowerCase = function (s) { return s.toLowerCase() === s; };\n *\n * filter([\"Foo\", \"bar\", \"baZ\"], isLowerCase) // => [\"bar\"]\n *\n * // the function will work with any array-like object\n * filter(\"fooBAR\", isLowerCase) // => [\"f\", \"o\", \"o\"]\n *\n * @param {Function} method\n * @returns {Function}\n */\n var generic = Function.bind.bind(Function.call);\n\n /**\n * The I combinator. Any value passed to the function is simply returned as it is.\n * @example\n * var foo = {bar: \"baz\"};\n *\n * _.identity(foo) === foo // true\n *\n * @memberof module:lamb\n * @category Core\n * @see [SKI combinator calculus]{@link https://en.wikipedia.org/wiki/SKI_combinator_calculus}\n * @param {*} value\n * @returns {*} The value passed as parameter.\n */\n function identity (value) {\n return value;\n }\n\n /**\n * Builds a partially applied function. The lamb object itself can be used as a placeholder argument:\n * it's useful to alias it as _ or __.\n * @example\n * var weights = [\"2 Kg\", \"10 Kg\", \"1 Kg\", \"7 Kg\"];\n * var parseInt10 = _.partial(parseInt, _, 10);\n *\n * weights.map(parseInt10) // => [2, 10, 1, 7]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {...*} args\n * @returns {Function}\n */\n function partial (fn) {\n var args = slice(arguments, 1);\n\n return function () {\n var lastArgumentIdx = 0;\n var newArgs = [];\n var argsLen = args.length;\n\n for (var i = 0, boundArg; i < argsLen; i++) {\n boundArg = args[i];\n newArgs[i] = boundArg === _ ? arguments[lastArgumentIdx++] : boundArg;\n }\n\n for (var len = arguments.length; lastArgumentIdx < len; lastArgumentIdx++) {\n newArgs.push(arguments[lastArgumentIdx]);\n }\n\n return fn.apply(this, newArgs);\n };\n }\n\n lamb.always = always;\n lamb.compose = compose;\n lamb.generic = generic;\n lamb.identity = identity;\n lamb.partial = partial;\n\n\n /**\n * Builds an array comprised of all values of the array-like object passing the predicate test.
\n * It's a generic version of [Array.prototype.filter]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/filter}.\n * @example\n * var isLowerCase = function (s) { return s.toLowerCase() === s; };\n *\n * _.filter([\"Foo\", \"bar\", \"baZ\"], isLowerCase) // => [\"bar\"]\n *\n * // the function will work with any array-like object\n * _.filter(\"fooBAR\", isLowerCase) // => [\"f\", \"o\", \"o\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.filterWith|filterWith}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Array}\n */\n var filter = generic(_arrayProto.filter);\n\n /**\n * Executes the provided iteratee for each element of the given array-like object.
\n * It's a generic version of [Array.prototype.forEach]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach}.\n * @example Adding a CSS class to all elements of a NodeList in a browser environment\n * var addClass = function (className) {\n * return function (element) {\n * element.classList.add(className);\n * };\n * };\n * var paragraphs = document.querySelectorAll(\"#some-container p\");\n *\n * _.forEach(paragraphs, addClass(\"main\"));\n * // each \"p\" element in the container will have the \"main\" class now\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n */\n var forEach = generic(_arrayProto.forEach);\n\n /**\n * Creates an array from the results of the provided iteratee.
\n * It's a generic version of [Array.prototype.map]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/map}.\n * @example\n * function getSquareRoots () {\n * return _.map(arguments, Math.sqrt);\n * }\n *\n * getSquareRoots(4, 9, 16) // => [2, 3, 4]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.mapWith|mapWith}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n var map = generic(_arrayProto.map);\n\n /**\n * Reduces (or folds) the values of an array-like object, starting from the first, to a new value using the provided accumulator function.
\n * It's a generic version of [Array.prototype.reduce]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce}.\n * @example\n * _.reduce([1, 2, 3, 4], _.add) // => 10\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.reduceRight|reduceRight}\n * @see {@link module:lamb.reduceWith|reduceWith}, {@link module:lamb.reduceRightWith|reduceRightWith}\n * @param {ArrayLike} arrayLike\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {*}\n */\n var reduce = generic(_arrayProto.reduce);\n\n /**\n * Same as {@link module:lamb.reduce|reduce}, but starts the fold operation from the last element instead.
\n * It's a generic version of [Array.prototype.reduceRight]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight}.\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.reduce|reduce}\n * @see {@link module:lamb.reduceWith|reduceWith}, {@link module:lamb.reduceRightWith|reduceRightWith}\n * @param {ArrayLike} arrayLike\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {*}\n */\n var reduceRight = generic(_arrayProto.reduceRight);\n\n /**\n * Builds an array by extracting a portion of an array-like object.
\n * It's a generic version of [Array.prototype.slice]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice}.\n * @example\n * _.slice([\"foo\", \"bar\", \"baz\"], 0, 2) // => [\"foo\", \"bar\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {ArrayLike} arrayLike - Any array like object.\n * @param {Number} [start=0] - Zero-based index at which to begin extraction.\n * @param {Number} [end=arrayLike.length] - Zero-based index at which to end extraction. Extracts up to but not including end.\n * @returns {Array}\n */\n var slice = generic(_arrayProto.slice);\n\n lamb.filter = filter;\n lamb.forEach = forEach;\n lamb.map = map;\n lamb.reduce = reduce;\n lamb.reduceRight = reduceRight;\n lamb.slice = slice;\n\n\n /**\n * Accepts a series of functions and builds a function that applies the received arguments to each one and\n * returns the first non-undefined value.
\n * Meant to work in sinergy with {@link module:lamb.condition|condition} and {@link module:lamb.invoker|invoker},\n * can be useful as a strategy pattern for functions, to mimic conditional logic and also to build polymorphic functions.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var filterString = _.compose(_.invoker(\"join\", \"\"), _.filter);\n * var filterAdapter = _.adapter(\n * _.invoker(\"filter\"),\n * _.condition(_.isType(\"String\"), filterString)\n * );\n *\n * filterAdapter([1, 2, 3, 4, 5, 6], isEven)) // => [2, 4, 6]\n * filterAdapter(\"123456\", isEven)) // => \"246\"\n * filterAdapter({}, isEven)) // => undefined\n *\n * // obviously it's composable\n * var filterWithDefault = _.adapter(filterAdapter, _.always(\"Not implemented\"));\n *\n * filterWithDefault([1, 2, 3, 4, 5, 6], isEven)) // => [2, 4, 6]\n * filterWithDefault(\"123456\", isEven)) // => \"246\"\n * filterWithDefault({}, isEven)) // => \"Not implemented\"\n *\n * @memberof module:lamb\n * @category Logic\n * @param {...Function} fn\n * @returns {Function}\n */\n function adapter () {\n var functions = slice(arguments);\n\n return function () {\n var len = functions.length;\n var result;\n\n for (var i = 0; i < len; i++) {\n result = apply(functions[i], arguments);\n\n if (!isUndefined(result)) {\n break;\n }\n }\n\n return result;\n };\n }\n\n /**\n * Builds a predicate that returns true if all the given predicates are satisfied.\n * The arguments passed to the resulting function are applied to every predicate unless one of them returns false.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var isPositive = function (n) { return n > 0; };\n * var isPositiveEven = _.allOf(isEven, isPositive);\n *\n * isPositiveEven(-2) // => false\n * isPositiveEven(11) // => false\n * isPositiveEven(6) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see {@link module:lamb.anyOf|anyOf}\n * @param {...Function} predicate\n * @returns {Function}\n */\n function allOf () {\n var predicates = slice(arguments);\n\n return function () {\n var args = arguments;\n\n return predicates.every(function (predicate) {\n return predicate.apply(null, args);\n });\n };\n }\n\n /**\n * Builds a predicate that returns true if at least one of the given predicates is satisfied.\n * The arguments passed to the resulting function are applied to every predicate until one of them returns true.\n * @example\n * // Lamb's \"isNil\" is actually implemented like this\n * var isNil = _.anyOf(_.isNull, _.isUndefined);\n *\n * isNil(NaN) // => false\n * isNil({}) // => false\n * isNil(null) // => true\n * isNil(void 0) // => true\n * isNil() // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see {@link module:lamb.allOf|allOf}\n * @param {...Function} predicate\n * @returns {Function}\n */\n function anyOf () {\n var predicates = slice(arguments);\n\n return function () {\n var args = arguments;\n\n return predicates.some(function (predicate) {\n return predicate.apply(null, args);\n });\n };\n }\n\n /**\n * Builds a function that will apply the received arguments to trueFn, if the predicate is satisfied with\n * the same arguments, or to falseFn otherwise.
\n * If falseFn isn't provided and the predicate isn't satisfied the function will return undefined.
\n * Although you can use other conditions as trueFn or falseFn, it's probably better to\n * use {@link module:lamb.adapter|adapter} to build more complex behaviours.\n * @example\n * var isEven = function (n) { return n % 2 === 0};\n * var halve = function (n) { return n / 2; };\n * var halveIfEven = _.condition(isEven, halve, _.identity);\n *\n * halveIfEven(5) // => 5\n * halveIfEven(6) // => 3\n *\n * @memberof module:lamb\n * @category Logic\n * @see {@link module:lamb.invoker|invoker}\n * @param {Function} predicate\n * @param {Function} trueFn\n * @param {Function} [falseFn]\n * @returns {Function}\n */\n function condition (predicate, trueFn, falseFn) {\n return function () {\n var applyArgsTo = applyArgs(arguments);\n return applyArgsTo(predicate) ? applyArgsTo(trueFn) : falseFn ? applyArgsTo(falseFn) : void 0;\n };\n }\n\n /**\n * Verifies that the two supplied values are the same value using the \"SameValue\" comparison.
\n * Note that this doesn't behave as the strict equality operator, but rather as a shim of ES6's\n * [Object.is]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is}.\n * Differences are that 0 and -0 aren't the same value and, finally, NaN is equal to itself.
\n * See also {@link module:lamb.isSVZ|isSVZ} which performs the check using the \"SameValueZero\" comparison.\n * @example\n * var testObject = {};\n *\n * _.is({}, testObject) // => false\n * _.is(testObject, testObject) // => true\n * _.is(\"foo\", \"foo\") // => true\n * _.is(0, -0) // => false\n * _.is(0 / 0, NaN) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see [SameValue comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue}\n * @see [SameValueZero comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero}\n * @param {*} a\n * @param {*} b\n * @returns {Boolean}\n */\n function is (a, b) {\n return a === 0 && b === 0 ? 1 / a === 1 / b : isSVZ(a, b);\n }\n\n /**\n * Verifies that the first given value is greater than the second.\n * @example\n * var pastDate = new Date(2010, 2, 12);\n * var today = new Date();\n *\n * _.isGT(today, pastDate) // true\n * _.isGT(pastDate, today) // false\n * _.isGT(3, 4) // false\n * _.isGT(3, 3) // false\n * _.isGT(3, 2) // true\n * _.isGT(0, -0) // false\n * _.isGT(-0, 0) // false\n * _.isGT(\"a\", \"A\") // true\n * _.isGT(\"b\", \"a\") // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isGT (a, b) {\n return a > b;\n }\n\n /**\n * Verifies that the first given value is greater than or equal to the second.\n * Regarding equality, beware that this is simply a wrapper for the native operator, so -0 === 0.\n * @example\n * _.isGTE(3, 4) // false\n * _.isGTE(3, 3) // true\n * _.isGTE(3, 2) // true\n * _.isGTE(0, -0) // true\n * _.isGTE(-0, 0) // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isGTE (a, b) {\n return a >= b;\n }\n\n /**\n * Verifies that the first given value is less than the second.\n * @example\n * var pastDate = new Date(2010, 2, 12);\n * var today = new Date();\n *\n * _.isLT(today, pastDate) // false\n * _.isLT(pastDate, today) // true\n * _.isLT(3, 4) // true\n * _.isLT(3, 3) // false\n * _.isLT(3, 2) // false\n * _.isLT(0, -0) // false\n * _.isLT(-0, 0) // false\n * _.isLT(\"a\", \"A\") // false\n * _.isLT(\"a\", \"b\") // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isLT (a, b) {\n return a < b;\n }\n\n /**\n * Verifies that the first given value is less than or equal to the second.\n * Regarding equality, beware that this is simply a wrapper for the native operator, so -0 === 0.\n * @example\n * _.isLTE(3, 4) // true\n * _.isLTE(3, 3) // true\n * _.isLTE(3, 2) // false\n * _.isLTE(0, -0) // true\n * _.isLTE(-0, 0) // true\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Number|String|Date|Boolean} a\n * @param {Number|String|Date|Boolean} b\n * @returns {Boolean}\n */\n function isLTE (a, b) {\n return a <= b;\n }\n\n /**\n * A simple negation of {@link module:lamb.is|is}, exposed for convenience.\n * @example\n * _.isNot(\"foo\", \"foo\") // => false\n * _.isNot(0, -0) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @function\n * @param {*} valueA\n * @param {*} valueB\n * @returns {Boolean}\n */\n var isNot = not(is);\n\n /**\n * Verifies that the two supplied values are the same value using the \"SameValueZero\" comparison.
\n * With this comparison NaN is equal to itself, but 0 and -0 are\n * considered the same value too.
\n * See also {@link module:lamb.is|is} to perform a \"SameValue\" comparison.\n * @example\n * var testObject = {};\n *\n * _.isSVZ({}, testObject) // => false\n * _.isSVZ(testObject, testObject) // => true\n * _.isSVZ(\"foo\", \"foo\") // => true\n * _.isSVZ(0, -0) // => true\n * _.isSVZ(0 / 0, NaN) // => true\n *\n * @memberof module:lamb\n * @category Logic\n * @see [SameValue comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevalue}\n * @see [SameValueZero comparison]{@link https://people.mozilla.org/~jorendorff/es6-draft.html#sec-samevaluezero}\n * @param {*} a\n * @param {*} b\n * @returns {Boolean}\n */\n function isSVZ (a, b) {\n return a !== a ? b !== b : a === b;\n }\n\n /**\n * Returns a predicate that negates the given one.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var isOdd = _.not(isEven);\n *\n * isOdd(5) // => true\n * isOdd(4) // => false\n *\n * @memberof module:lamb\n * @category Logic\n * @param {Function} predicate\n * @returns {Function}\n */\n function not (predicate) {\n return function () {\n return !predicate.apply(null, arguments);\n };\n }\n\n lamb.adapter = adapter;\n lamb.allOf = allOf;\n lamb.anyOf = anyOf;\n lamb.condition = condition;\n lamb.is = is;\n lamb.isGT = isGT;\n lamb.isGTE = isGTE;\n lamb.isLT = isLT;\n lamb.isLTE = isLTE;\n lamb.isNot = isNot;\n lamb.isSVZ = isSVZ;\n lamb.not = not;\n\n\n /**\n * Adds two numbers.\n * @example\n * _.add(4, 5) // => 9\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function add (a, b) {\n return a + b;\n }\n\n /**\n * \"Clamps\" a number within the given limits.\n * @example\n * _.clamp(-5, 0, 10) // => 0\n * _.clamp(5, 0, 10) // => 5\n * _.clamp(15, 0, 10) // => 10\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} n\n * @param {Number} min\n * @param {Number} max\n * @returns {Number}\n */\n function clamp (n, min, max) {\n return n < min ? min : n > max ? max : n;\n }\n\n /**\n * Divides two numbers.\n * @example\n * _.divide(5, 2) // => 2.5\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function divide (a, b) {\n return a / b;\n }\n\n /**\n * Generates a sequence of values of the desired length with the provided iteratee.\n * The values being iterated, and received by the iteratee, are the results generated so far.\n * @example\n * var fibonacci = function (n, idx, results) {\n * return n + (results[idx - 1] || 0);\n * };\n *\n * _.generate(1, 10, fibonacci) // => [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n *\n * @memberof module:lamb\n * @category Math\n * @param {*} start - The starting value\n * @param {Number} len - The desired length for the sequence\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n function generate (start, len, iteratee, iterateeContext) {\n var result = [start];\n\n for (var i = 0, limit = len - 1; i < limit; i++) {\n result.push(iteratee.call(iterateeContext, result[i], i, result));\n }\n\n return result;\n }\n\n /**\n * Performs the modulo operation and should not be confused with the {@link module:lamb.remainder|remainder}.\n * The function performs a floored division to calculate the result and not a truncated one, hence the sign of\n * the dividend is not kept, unlike the {@link module:lamb.remainder|remainder}.\n * @example\n * _.modulo(5, 3) // => 2\n * _.remainder(5, 3) // => 2\n *\n * _.modulo(-5, 3) // => 1\n * _.remainder(-5, 3) // => -2\n *\n * @memberof module:lamb\n * @category Math\n * @see {@link http://en.wikipedia.org/wiki/Modulo_operation}\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function modulo (a, b) {\n return a - (b * Math.floor(a / b));\n }\n\n /**\n * Multiplies two numbers.\n * @example\n * _.multiply(5, 3) // => 15\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function multiply (a, b) {\n return a * b;\n }\n\n /**\n * Generates a random integer between two given integers, both included.\n * Note that no safety measure is taken if the provided arguments aren't integers, so\n * you may end up with unexpected (not really) results.\n * For example randomInt(0.1, 1.2) could be 2.\n * @example\n *\n * _.randomInt(1, 10) // => an integer >=1 && <= 10\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} min\n * @param {Number} max\n * @returns {Number}\n */\n function randomInt (min, max) {\n return Math.floor(Math.random() * (max - min + 1) + min);\n }\n\n /**\n * Generates an arithmetic progression of numbers starting from start up to,\n * but not including, limit, using the given step.\n * @example\n * _.range(2, 10) // => [2, 3, 4, 5, 6, 7, 8, 9]\n * _.range(2, 10, 0) // => [2]\n * _.range(1, -10, -2) // => [1, -1, -3, -5, -7, -9]\n * _.range(1, -10, 2) // => [1]\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} start\n * @param {Number} limit\n * @param {Number} [step=1]\n * @returns {Number[]}\n */\n function range (start, limit, step) {\n if (step === 0 || arguments.length < 2) {\n return [start];\n }\n\n if (!step) {\n step = 1;\n }\n\n var len = Math.max(Math.ceil((limit - start) / step), 0);\n return generate(start, len, partial(add, step));\n }\n\n /**\n * Gets the remainder of the division of two numbers.\n * Not to be confused with the {@link module:lamb.modulo|modulo} as the remainder\n * keeps the sign of the dividend and may lead to some unexpected results.\n * @example\n * // example of wrong usage of the remainder\n * // (in this case the modulo operation should be used)\n * var isOdd = function (n) { return _.remainder(n, 2) === 1; };\n * isOdd(-3) // => false as -3 % 2 === -1\n *\n * @memberof module:lamb\n * @category Math\n * @see {@link http://en.wikipedia.org/wiki/Modulo_operation}\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function remainder (a, b) {\n return a % b;\n }\n\n /**\n * Subtracts two numbers.\n * @example\n * _.subtract(5, 3) // => 2\n *\n * @memberof module:lamb\n * @category Math\n * @param {Number} a\n * @param {Number} b\n * @returns {Number}\n */\n function subtract (a, b) {\n return a - b;\n }\n\n lamb.add = add;\n lamb.clamp = clamp;\n lamb.divide = divide;\n lamb.generate = generate;\n lamb.modulo = modulo;\n lamb.multiply = multiply;\n lamb.randomInt = randomInt;\n lamb.range = range;\n lamb.remainder = remainder;\n lamb.subtract = subtract;\n\n\n /**\n * Verifies if a value is null or undefined.\n * @example\n * _.isNil(NaN) // => false\n * _.isNil({}) // => false\n * _.isNil(null) // => true\n * _.isNil(void 0) // => true\n * _.isNil() // => true\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isNull|isNull} and {@link module:lamb.isNull|isUndefined} for individual checks.\n * @function\n * @param {*} value\n * @returns {Boolean}\n */\n var isNil = anyOf(isNull, isUndefined);\n\n /**\n * Verifies if a value is null.\n * @example\n * _.isNull(null) // => true\n * _.isNull(void 0) // => false\n * _.isNull(false) // => false\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isNil|isNil} if you want to check for undefined too.\n * @param {*} value\n * @returns {Boolean}\n */\n function isNull (value) {\n return value === null;\n }\n\n /**\n * Builds a predicate that expects a value to check against the specified type.\n * @example\n * var isString = _.isType(\"String\");\n *\n * isString(\"Hello\") // => true\n * isString(new String(\"Hi\")) // => true\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.type|type}\n * @param {String} typeTag\n * @returns {Function}\n */\n function isType (typeName) {\n return function (value) {\n return type(value) === typeName;\n };\n }\n\n /**\n * Verifies if a value is undefined.\n * @example\n * _.isUndefined(null) // => false\n * _.isUndefined(void 0) // => true\n * _.isUndefined(false) // => false\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isNil|isNil} if you want to check for null too.\n * @param {*} value\n * @returns {Boolean}\n */\n function isUndefined (value) {\n // using void because undefined could be theoretically shadowed\n return value === void 0;\n }\n\n /**\n * Retrieves the \"type tag\" from the given value.\n * @example\n * var x = 5;\n * var y = new Number(5);\n *\n * typeof x // => \"number\"\n * typeof y // => \"object\"\n * _.type(x) // => \"Number\"\n * _.type(y) // => \"Number\"\n *\n * _.type(Object.prototype.toString) // => \"Function\"\n * _.type(/a/) // => \"RegExp\"\n *\n * @memberof module:lamb\n * @category Type\n * @see {@link module:lamb.isType|isType}\n * @param {*} value\n * @returns {String}\n */\n function type (value) {\n return _objectProto.toString.call(value).replace(/^\\[\\w+\\s+|\\]$/g, \"\");\n }\n\n lamb.isNil = isNil;\n lamb.isNull = isNull;\n lamb.isType = isType;\n lamb.isUndefined = isUndefined;\n lamb.type = type;\n\n\n function _getNaturalIndex (index, len) {\n if (_isInteger(index) && _isInteger(len)) {\n return clamp(index, -len, len - 1) === index ? index < 0 ? index + len : index : void 0;\n }\n }\n\n function _getPathInfo (obj, parts) {\n var target = obj;\n var i = -1;\n var len = parts.length;\n var currentKey;\n var idx;\n\n while (++i < len) {\n currentKey = parts[i];\n\n if (_isIndex(target, currentKey)) {\n idx = _getNaturalIndex(+currentKey, target.length);\n\n if (isUndefined(idx)) {\n break;\n }\n\n target = target[idx];\n } else {\n if (!_isEnumerable(target, currentKey)) {\n break;\n }\n\n target = target[currentKey];\n }\n }\n\n return i === len ? {isValid: true, target: target} : {isValid: false, target: void 0};\n }\n\n function _isIndex (target, key) {\n return Array.isArray(target) && parseInt(key, 10) == key;\n }\n\n function _isEnumerable (obj, key) {\n return key in Object(obj) && (_isOwnEnumerable(obj, key) || ~_safeEnumerables(obj).indexOf(key));\n }\n\n function _isInteger (n) {\n return Math.floor(n) === n;\n }\n\n var _isOwnEnumerable = generic(_objectProto.propertyIsEnumerable);\n\n function _setIndex (arrayLike, index, value, updater) {\n var result = slice(arrayLike);\n var idx = _getNaturalIndex(index, result.length);\n\n if (!isUndefined(idx)) {\n result[idx] = updater ? updater(arrayLike[idx]) : value;\n }\n\n return result;\n }\n\n function _setPathIn (obj, parts, value) {\n var key = parts[0];\n var v = parts.length === 1 ? value : _setPathIn(\n _getPathInfo(obj, [key]).target,\n parts.slice(1),\n value\n );\n\n return _isIndex(obj, key) ? _setIndex(obj, +key, v) : setIn(obj, key, v);\n }\n\n /**\n * A curried version of {@link module:lamb.getIndex|getIndex} that uses the provided index\n * to build a function expecting the array-like object holding the element we want to retrieve.\n * @example\n * var getFifthElement = _.getAt(4);\n *\n * getFifthElement([1, 2, 3, 4, 5]) // => 5\n * getFifthElement(\"foo bar\") // => \"b\"\n * getFifthElement([]) // => undefined\n * getFifthElement(\"foo\") // => undefined\n *\n * @example Using negative indexes\n * _.getAt(-2)([1, 2, 3]) // => 2\n * _.getAt(-3)(\"foo\") // => \"f\"\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.getIndex|getIndex}\n * @see {@link module:lamb.head|head} and {@link module:lamb.last|last} for common use cases shortcuts.\n * @param {Number} index\n * @returns {Function}\n */\n var getAt = _curry(getIndex, 2, true);\n\n /**\n * Returns the value of the object property with the given key.\n * @example\n * var user = {name: \"John\"};\n *\n * _.getIn(user, \"name\") // => \"John\";\n * _.getIn(user, \"surname\") // => undefined\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.getKey|getKey}\n * @see {@link module:lamb.getPath|getPath}, {@link module:lamb.getPathIn|getPathIn}\n * @param {Object} obj\n * @param {String} key\n * @returns {*}\n */\n function getIn (obj, key) {\n return obj[key];\n }\n\n /**\n * Retrieves the element at the given index in an array-like object.
\n * Like {@link module:lamb.slice|slice} the index can be negative.
\n * If the index isn't supplied, or if its value isn't an integer within the array-like bounds,\n * the function will return undefined.
\n * getIndex will throw an exception when receives null or\n * undefined in place of an array-like object, but returns undefined\n * for any other value.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.getIndex(arr, 1) // => 2\n * _.getIndex(arr, -1) // => 5\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.getAt|getAt}\n * @see {@link module:lamb.head|head} and {@link module:lamb.last|last} for common use cases shortcuts.\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @returns {*}\n */\n function getIndex (arrayLike, index) {\n var idx = _getNaturalIndex(index, arrayLike.length);\n return isUndefined(idx) ? idx : arrayLike[idx];\n }\n\n /**\n * A curried version of {@link module:lamb.getIn|getIn}.
\n * Receives a property name and builds a function expecting the object from which we want to retrieve the property.\n * @example\n * var user1 = {name: \"john\"};\n * var user2 = {name: \"jane\"};\n * var getName = _.getKey(\"name\");\n *\n * getName(user1) // => \"john\"\n * getName(user2) // => \"jane\"\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.getIn|getIn}\n * @see {@link module:lamb.getPath|getPath}, {@link module:lamb.getPathIn|getPathIn}\n * @param {String} key\n * @returns {Function}\n */\n var getKey = _curry(getIn, 2, true);\n\n /**\n * Builds a partial application of {@link module:lamb.getPathIn|getPathIn} with the given\n * path and separator, expecting the object to act upon.
\n * @example\n * var user = {\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * \"user.name\": \"jdoe\",\n * password: \"abc123\"\n * }\n * };\n *\n * var getPwd = _.getPath(\"login.password\");\n * var getUsername = _.getPath(\"login/user.name\", \"/\");\n *\n * getPwd(user) // => \"abc123\";\n * getUsername(user) // => \"jdoe\"\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.getPathIn|getPathIn}\n * @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getKey|getKey}\n * @param {String} path\n * @param {String} [separator=\".\"]\n * @returns {Function}\n */\n function getPath (path, separator) {\n return partial(getPathIn, _, path, separator);\n }\n\n /**\n * Gets a nested property value from an object using the given path.
\n * The path is a string with property names separated by dots by default, but\n * it can be customised with the optional third parameter.
\n * You can use integers in the path, even negative ones, to refer to array-like\n * object indexes, but the priority will be given to existing object keys:\n * the last example explains this particular case.\n * @example\n * var user = {\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * \"user.name\": \"jdoe\",\n * password: \"abc123\"\n * },\n * scores: [\n * {id: 1, value: 10},\n * {id: 2, value: 20},\n * {id: 3, value: 30}\n * ]\n * };\n *\n * _.getPathIn(user, \"name\") // => \"John\"\n * _.getPathIn(user, \"login.password\") // => \"abc123\";\n * _.getPathIn(user, \"login/user.name\", \"/\") // => \"jdoe\"\n * _.getPathIn(user, \"name.foo\") // => undefined\n * _.getPathIn(user, \"name.foo.bar\") // => undefined\n *\n * @example Accessing array-like objects indexes:\n * _.getPathIn(user, \"login.password.1\") // => \"b\"\n * _.getPathIn(user, \"scores.0\") // => {id: 1, value: 10}\n * _.getPathIn(user, \"scores.-1.value\") // => 30\n *\n * @example Priority will be given to existing object keys over indexes:\n * _.getPathIn(user, \"scores.-1\") // => {id: 3, value: 30}\n *\n * // let's do something funny\n * user.scores[\"-1\"] = \"foo bar\";\n *\n * _.getPathIn(user, \"scores.-1\") // => \"foo bar\";\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.getPath|getPath}\n * @see {@link module:lamb.getIn|getIn}, {@link module:lamb.getKey|getKey}\n * @param {Object|ArrayLike} obj\n * @param {String} path\n * @param {String} [separator=\".\"]\n * @returns {*}\n */\n function getPathIn (obj, path, separator) {\n return path.split(separator || \".\").reduce(\n adapter(tapArgs(getIn, Object), tapArgs(getIndex, Object, Number)),\n obj\n );\n }\n\n /**\n * Retrieves the first element of an array-like object.
\n * Just a common use case of {@link module:lamb.getAt|getAt} exposed for convenience.\n * @example\n * _.head([1, 2, 3]) // => 1\n * _.head(\"hello\") // => \"h\"\n * _.head([]) // => undefined\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.last|last}\n * @see {@link module:lamb.getIndex|getIndex}, {@link module:lamb.getAt|getAt}\n * @param {ArrayLike} arrayLike\n * @returns {*}\n */\n var head = getAt(0);\n\n /**\n * Retrieves the last element of an array-like object.
\n * Just a common use case of {@link module:lamb.getAt|getAt} exposed for convenience.\n * @example\n * _.last([1, 2, 3]) // => 3\n * _.last(\"hello\") // => \"o\"\n * _.last([]) // => undefined\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.head|head}\n * @see {@link module:lamb.getIndex|getIndex}, {@link module:lamb.getAt|getAt}\n * @param {ArrayLike} arrayLike\n * @returns {*}\n */\n var last = getAt(-1);\n\n /**\n * Builds a function that creates a copy of an array-like object with the given\n * index changed to the desired value.
\n * If the index is not an integer or if it's out of bounds, the function\n * will return a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.setAt(2, 99)(arr) // => [1, 2, 99, 4, 5]\n * arr // => [1, 2, 3, 4, 5]\n *\n * _.setAt(10, 99)(arr) // => [1, 2, 3, 4, 5] (not a reference to `arr`)\n *\n * @example Using negative indexes\n * _.setAt(-1, 99)(arr) // => [1, 2, 3, 4, 99]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.setIndex|setIndex}\n * @param {Number} index\n * @param {*} value\n * @returns {Function}\n */\n function setAt (index, value) {\n return function (arrayLike) {\n return _setIndex(arrayLike, index, value);\n };\n }\n\n /**\n * Sets the specified key to the given value in a copy of the provided object.
\n * All the enumerable keys of the source object will be simply copied to an empty\n * object without breaking references.
\n * If the specified key is not part of the source object, it will be added to the\n * result.
\n * The main purpose of the function is to work on simple plain objects used as\n * data structures, such as JSON objects, and makes no effort to play nice with\n * objects created from an OOP perspective (it's not worth it).
\n * For example the prototype of the result will be Object's regardless\n * of the source's one.\n * @example\n * var user = {name: \"John\", surname: \"Doe\", age: 30};\n *\n * _.setIn(user, \"name\", \"Jane\") // => {name: \"Jane\", surname: \"Doe\", age: 30}\n * _.setIn(user, \"gender\", \"male\") // => {name: \"John\", surname: \"Doe\", age: 30, gender: \"male\"}\n *\n * // `user` still is {name: \"John\", surname: \"Doe\", age: 30}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setKey|setKey}\n * @see {@link module:lamb.setPath|setPath}, {@link module:lamb.setPathIn|setPathIn}\n * @param {Object} source\n * @param {String} key\n * @param {*} value\n * @returns {Object}\n */\n function setIn (source, key, value) {\n return _merge(_safeEnumerables, source, make([key], [value]));\n }\n\n /**\n * Creates a copy of an array-like object with the given index changed to\n * the desired value.
\n * If the index is not an integer or if it's out of bounds, the function\n * will return a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [1, 2, 3];\n *\n * _.setIndex(arr, 1, 99) // => [1, 99, 3]\n * _.setIndex(arr, -1, 99) // => [1, 2, 99]\n * _.setIndex(arr, 10, 99) // => [1, 2, 3] (not a reference to `arr`)\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.setAt|setAt}\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @param {*} value\n * @returns {*}\n */\n var setIndex = aritize(_setIndex, 3);\n\n /**\n * Builds a partial application of {@link module:lamb.setIn|setIn} with the provided\n * key and value.
\n * The resulting function expects the object to act upon.
\n * Please refer to {@link module:lamb.setIn|setIn}'s description for explanations about\n * how the copy of the source object is made.\n * @example\n * var user = {name: \"John\", surname: \"Doe\", age: 30};\n * var setAgeTo40 = _.setKey(\"age\", 40);\n *\n * setAgeTo40(user) // => {name: \"john\", surname: \"doe\", age: 40}\n *\n * // `user` still is {name: \"John\", surname: \"Doe\", age: 30}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setIn|setIn}\n * @see {@link module:lamb.setPath|setPath}, {@link module:lamb.setPathIn|setPathIn}\n * @param {String} key\n * @param {*} value\n * @returns {Function}\n */\n function setKey (key, value) {\n return partial(setIn, _, key, value);\n }\n\n /**\n * Builds a partial application of {@link module:lamb.setPathIn|setPathIn} expecting the\n * object to act upon.
\n * See {@link module:lamb.setPathIn|setPathIn} for more details and examples.\n * @example\n * var user = {id: 1, status: {active: false}};\n * var activate = _.setPath(\"status.active\", true);\n *\n * activate(user) // => {id: 1, status: {active: true}}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setPathIn|setPathIn}\n * @see {@link module:lamb.setIn|setIn}, {@link module:lamb.setKey|setKey}\n * @param {String} path\n * @param {*} value\n * @param {String} [separator=\".\"]\n * @returns {Function}\n */\n function setPath (path, value, separator) {\n return partial(setPathIn, _, path, value, separator);\n }\n\n /**\n * Allows to change a nested value in a copy of the provided object.
\n * The function will delegate the \"set action\" to {@link module:lamb.setIn|setIn} or\n * {@link module:lamb.setAt|setAt} depending on the value encountered in the path,\n * so please refer to the documentation of those functions for specifics about the\n * implementation.
\n * Note anyway that the distinction will be between Arrays, delegated\n * to {@link module:lamb.setAt|setAt}, and everything else (including array-like objects),\n * which will be delegated to {@link module:lamb.setIn|setIn}.
\n * As a result of that, array-like objects will be converted to objects having numbers as keys\n * and paths targeting non-object values will be converted to empty objects.
\n * Non-enumerable properties encountered in the path will be considered as non-existent properties.
\n * Like {@link module:lamb.getPathIn|getPathIn} or {@link module:lamb.getPath|getPath} you can\n * use custom path separators.\n * @example\n * var user = {id: 1, status: {active : false, scores: [2, 4, 6]}};\n *\n * _.setPathIn(user, \"status.active\", true) // => {id: 1, status: {active : true, scores: [2, 4, 6]}}\n *\n * @example Targeting arrays\n * _.setPathIn(user, \"status.scores.0\", 8) // => {id: 1, status: {active : false, scores: [8, 4, 6]}}\n *\n * // you can use negative indexes as well\n * _.setPathIn(user, \"status.scores.-1\", 8) // => {id: 1, status: {active : false, scores: [2, 4, 8]}}\n *\n * @example Arrays can also be part of the path and not necessarily its target\n * var user = {id: 1, scores: [\n * {value: 2, year: \"2000\"},\n * {value: 4, year: \"2001\"},\n * {value: 6, year: \"2002\"}\n * ]};\n *\n * var newUser = _.setPathIn(user, \"scores.0.value\", 8);\n * // \"newUser\" holds:\n * // {id: 1, scores: [\n * // {value: 8, year: \"2000\"},\n * // {value: 4, year: \"2001\"},\n * // {value: 6, year: \"2002\"}\n * // ]}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.setPath|setPath}\n * @see {@link module:lamb.setIn|setIn}, {@link module:lamb.setKey|setKey}\n * @param {Object|Array} source\n * @param {String} path\n * @param {*} value\n * @param {String} [separator=\".\"]\n * @returns {Object|Array}\n */\n function setPathIn (source, path, value, separator) {\n return _setPathIn(source, path.split(separator || \".\"), value);\n }\n\n /**\n * Builds a function that creates a copy of an array-like object with the given index\n * changed by applying the provided function to its value.
\n * If the index is not an integer or if it's out of bounds, the function will return\n * a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [\"a\", \"b\", \"c\"];\n * var toUpperCase = _.invoker(\"toUpperCase\");\n *\n * _.updateAt(1, toUpperCase)(arr) // => [\"a\", \"B\", \"c\"]\n * _.updateAt(-1, toUpperCase)(arr) // => [\"a\", \"b\", \"C\"]\n * _.updateAt(10, toUpperCase)(arr) // => [\"a\", \"b\", \"c\"] (not a reference to `arr`)\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.updateIndex|updateIndex}\n * @param {Number} index\n * @param {Function} updater\n * @returns {Function}\n */\n function updateAt (index, updater) {\n return function (arrayLike) {\n return _setIndex(arrayLike, index, null, updater);\n };\n }\n\n /**\n * Creates a copy of the given object having the desired key value updated by applying\n * the provided function to it.
\n * This function is meant for updating existing enumerable properties, and for those it\n * will delegate the \"set action\" to {@link module:lamb.setIn|setIn}; a copy of the\n * source is returned otherwise.\n * @example\n * var user = {name: \"John\", visits: 2};\n * var toUpperCase = _.invoker(\"toUpperCase\");\n *\n * _.updateIn(user, \"name\", toUpperCase) // => {name: \"JOHN\", visits: 2}\n * _.updateIn(user, \"surname\", toUpperCase) // => {name: \"John\", visits: 2}\n *\n * @example Non-enumerable properties will be treated as non-existent:\n * var user = Object.create({name: \"John\"}, {visits: {value: 2}});\n * var increment = _.partial(_.add, 1);\n *\n * _.updateIn(user, \"visits\", increment) // => {name: \"John\", visits: 2}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updateKey|updateKey}\n * @see {@link module:lamb.updatePath|updatePath}, {@link module:lamb.updatePathIn|updatePathIn}\n * @param {Object} source\n * @param {String} key\n * @param {Function} updater\n * @returns {Object}\n */\n function updateIn (source, key, updater) {\n return _isEnumerable(source, key) ? setIn(source, key, updater(source[key])) : _merge(_safeEnumerables, source);\n }\n\n /**\n * Creates a copy of an array-like object with the given index changed by applying the\n * provided function to its value.
\n * If the index is not an integer or if it's out of bounds, the function will return\n * a copy of the original array.
\n * Negative indexes are allowed.\n * @example\n * var arr = [\"a\", \"b\", \"c\"];\n * var toUpperCase = _.invoker(\"toUpperCase\");\n *\n * _.updateIndex(arr, 1, toUpperCase) // => [\"a\", \"B\", \"c\"]\n * _.updateIndex(arr, -1, toUpperCase) // => [\"a\", \"b\", \"C\"]\n * _.updateIndex(arr, 10, toUpperCase) // => [\"a\", \"b\", \"c\"] (not a reference to `arr`)\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.updateAt|updateAt}\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @param {Function} updater\n * @returns {Array}\n */\n var updateIndex = partial(_setIndex, _, _, null);\n\n /**\n * Builds a partial application of {@link module:lamb.updateIn|updateIn} with the provided\n * key and updater, expecting the object to act upon.\n * @example\n * var user = {name: \"John\", visits: 2};\n * var increment = _.partial(_.add, 1);\n * var incrementVisits = _.updateKey(\"visits\", increment);\n *\n * incrementVisits(user) // => {name: \"John\", visits: 3}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updateIn|updateIn}\n * @see {@link module:lamb.updatePath|updatePath}, {@link module:lamb.updatePathIn|updatePathIn}\n * @param {String} key\n * @param {Function} updater\n * @returns {Function}\n */\n function updateKey (key, updater) {\n return partial(updateIn, _, key, updater);\n }\n\n /**\n * Builds a partial application of {@link module:lamb.updateIn|updateIn} expecting the object to act upon.\n * @example\n * var user = {id: 1, status: {scores: [2, 4, 6], visits: 0}};\n * var increment = _.partial(_.add, 1);\n * var incrementScores = _.updatePath(\"status.scores\", _.mapWith(increment))\n *\n * incrementScores(user) // => {id: 1, status: {scores: [3, 5, 7], visits: 0}}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updatePathIn|updatePathIn}\n * @see {@link module:lamb.updateIn|updateIn}, {@link module:lamb.updateKey|updateKey}\n * @param {String} path\n * @param {Function} updater\n * @param {String} [separator=\".\"]\n * @returns {Function}\n */\n function updatePath (path, updater, separator) {\n return partial(updatePathIn, _, path, updater, separator);\n }\n\n /**\n * Allows to change a nested value in a copy of the given object by applying the provided\n * function to it.
\n * This function is meant for updating existing enumerable properties, and for those it\n * will delegate the \"set action\" to {@link module:lamb.setPathIn|setPathIn}; a copy of the\n * source is returned otherwise.
\n * Like the other \"path\" functions, negative indexes can be used to access array elements.\n * @example\n * var user = {id: 1, status: {scores: [2, 4, 6], visits: 0}};\n * var increment = _.partial(_.add, 1);\n *\n * _.updatePathIn(user, \"status.visits\", increment) // => {id: 1, status: {scores: [2, 4, 6]}, visits: 1}\n *\n * @example Targeting arrays\n * _.updatePathIn(user, \"status.scores.0\", increment) // => {id: 1, status: {scores: [3, 4, 6], visits: 0}}\n *\n * // you can use negative indexes as well\n * _.updatePathIn(user, \"status.scores.-1\", increment) // => {id: 1, status: {scores: [2, 4, 7], visits: 0}}\n *\n * @example Arrays can also be part of the path and not necessarily its target\n * var user = {id: 1, scores: [\n * {value: 2, year: \"2000\"},\n * {value: 4, year: \"2001\"},\n * {value: 6, year: \"2002\"}\n * ]};\n *\n * var newUser = _.updatePathIn(user, \"scores.0.value\", increment);\n * // \"newUser\" holds:\n * // {id: 1, scores: [\n * // {value: 3, year: \"2000\"},\n * // {value: 4, year: \"2001\"},\n * // {value: 6, year: \"2002\"}\n * // ]}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.updatePath|updatePath}\n * @see {@link module:lamb.updateIn|updateIn}, {@link module:lamb.updateKey|updateKey}\n * @param {Object|Array} source\n * @param {String} path\n * @param {Function} updater\n * @param {String} [separator=\".\"]\n * @returns {Object|Array}\n */\n function updatePathIn (source, path, updater, separator) {\n var parts = path.split(separator || \".\");\n var pathInfo = _getPathInfo(source, parts);\n\n if (pathInfo.isValid) {\n return _setPathIn(source, parts, updater(pathInfo.target));\n } else {\n return Array.isArray(source) ? slice(source) : _merge(_safeEnumerables, source);\n }\n }\n\n lamb.getAt = getAt;\n lamb.getIn = getIn;\n lamb.getIndex = getIndex;\n lamb.getKey = getKey;\n lamb.getPath = getPath;\n lamb.getPathIn = getPathIn;\n lamb.head = head;\n lamb.last = last;\n lamb.setAt = setAt;\n lamb.setIn = setIn;\n lamb.setIndex = setIndex;\n lamb.setKey = setKey;\n lamb.setPath = setPath;\n lamb.setPathIn = setPathIn;\n lamb.updateAt = updateAt;\n lamb.updateIn = updateIn;\n lamb.updateIndex = updateIndex;\n lamb.updateKey = updateKey;\n lamb.updatePath = updatePath;\n lamb.updatePathIn = updatePathIn;\n\n\n function _findSliceEndIndex (arrayLike, predicate, predicateContext) {\n var idx = -1;\n var len = arrayLike.length;\n\n while (++idx < len && predicate.call(predicateContext, arrayLike[idx], idx, arrayLike));\n\n return idx;\n }\n\n function _flatten (array, output) {\n array.forEach(function (value) {\n if (Array.isArray(value)) {\n _flatten(value, output);\n } else {\n output.push(value);\n }\n });\n\n return output;\n }\n\n /**\n * Builds a predicate to check if an array-like object contains the given value.
\n * Please note that the equality test is made with {@link module:lamb.isSVZ|isSVZ}; so you can\n * check for NaN, but 0 and -0 are the same value.
\n * See also {@link module:lamb.isIn|isIn} for an uncurried version.\n * @example\n * var containsNaN = _.contains(NaN, 0);\n *\n * containsNaN([0, 1, 2, 3, NaN]) // => true\n *\n * @memberof module:lamb\n * @category Array\n * @param {*} value\n * @param {Number} [fromIndex=0] The position at which to begin searching for the given value.\n * @returns {Function}\n */\n function contains (value, fromIndex) {\n return function (arrayLike) {\n return isIn(arrayLike, value, fromIndex);\n };\n }\n\n /**\n * Returns an array of items present only in the first of the given arrays.
\n * Note that since version 0.13.0 this function uses the [\"SameValueZero\" comparison]{@link module:lamb.isSVZ|isSVZ}.\n * @example\n * var a1 = [1, 2, 3, 4];\n * var a2 = [2, 4, 5];\n * var a3 = [4, 5, 3, 1];\n *\n * _.difference(a1, a2) // => [1, 3]\n * _.difference(a1, a2, a3) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @param {Array} array\n * @param {...Array} other\n * @returns {Array}\n */\n function difference (array) {\n var rest = shallowFlatten(slice(arguments, 1));\n var isInRest = partial(isIn, rest, _, 0);\n return array.filter(not(isInRest));\n }\n\n /**\n * Builds an array without the first n elements of the given array or array-like object.\n * Note that, being this only a shortcut for a specific use case of {@link module:lamb.slice|slice},\n * n can be a negative number.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.drop(arr, 2) // => [3, 4, 5]\n * _.drop(arr, -1) // => [5]\n * _.drop(arr, -10) // => [1, 2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {ArrayLike} arrayLike\n * @param {Number} n\n * @returns {Array}\n */\n var drop = binary(slice);\n\n /**\n * A curried version of {@link module:lamb.drop|drop} that expects the number of elements\n * to drop to build a function waiting for the list to take the elements from.\n * See the note and examples for {@link module:lamb.drop|drop} about passing a negative n.\n * @example\n * var drop2 = _.dropN(2);\n *\n * drop2([1, 2, 3, 4, 5]) // => [3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.drop|drop}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {Number} n\n * @returns {Function}\n */\n var dropN = _curry(drop, 2, true);\n\n /**\n * Builds a function that drops the first n elements satisfying a predicate from an array or array-like object.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var dropWhileIsEven = _.dropWhile(isEven);\n *\n * dropWhileIsEven([2, 4, 6, 8]) // => []\n * dropWhileIsEven([2, 4, 7, 8]) // => [7, 8]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.takeWhile|takeWhile}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function dropWhile (predicate, predicateContext) {\n return function (arrayLike) {\n return slice(arrayLike, _findSliceEndIndex(arrayLike, predicate, predicateContext));\n };\n }\n\n /**\n * Returns a partial application of {@link module:lamb.filter|filter} that uses the given predicate and\n * the optional context to build a function expecting the array-like object to act upon.\n * @example\n * var isLowerCase = function (s) { return s.toLowerCase() === s; };\n * var getLowerCaseEntries = _.filterWith(isLowerCase);\n *\n * getLowerCaseEntries([\"Foo\", \"bar\", \"baZ\"]) // => [\"bar\"]\n *\n * // array-like objects can be used as well\n * getLowerCaseEntries(\"fooBAR\") // => [\"f\", \"o\", \"o\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.filter|filter}\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function filterWith (predicate, predicateContext) {\n return partial(filter, _, predicate, predicateContext);\n }\n\n /**\n * Searches for an element satisfying the predicate in the given array-like object and returns it if\n * the search is successful. Returns undefined otherwise.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 40}\n * ];\n *\n * _.find(persons, _.hasKeyValue(\"age\", 40)) // => {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40}\n * _.find(persons, _.hasKeyValue(\"age\", 41)) // => undefined\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {*}\n */\n function find (arrayLike, predicate, predicateContext) {\n var result;\n\n for (var i = 0, len = arrayLike.length, element; i < len; i++) {\n element = arrayLike[i];\n\n if (predicate.call(predicateContext, element, i, arrayLike)) {\n result = element;\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Searches for an element satisfying the predicate in the given array-like object and returns its\n * index if the search is successful. Returns -1 otherwise.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 40}\n * ];\n *\n * _.findIndex(persons, _.hasKeyValue(\"age\", 40)) // => 1\n * _.findIndex(persons, _.hasKeyValue(\"age\", 41)) // => -1\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Number}\n */\n function findIndex (arrayLike, predicate, predicateContext) {\n var result = -1;\n\n for (var i = 0, len = arrayLike.length; i < len; i++) {\n if (predicate.call(predicateContext, arrayLike[i], i, arrayLike)) {\n result = i;\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Similar to {@link module:lamb.map|map}, but if the mapping function returns an array this will\n * be concatenated, rather than pushed, to the final result.\n * @example showing the difference with map\n * var words = [\"foo\", \"bar\"];\n * var toCharArray = function (s) { return s.split(\"\"); };\n *\n * _.map(words, toCharArray) // => [[\"f\", \"o\", \"o\"], [\"b\", \"a\", \"r\"]]\n * _.flatMap(words, toCharArray) // => [\"f\", \"o\", \"o\", \"b\", \"a\", \"r\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.flatMapWith|flatMapWith}\n * @param {Array} array\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n var flatMap = compose(shallowFlatten, map);\n\n /**\n * Builds a partial application of {@link module:lamb.flatMap|flatMap} using the given iteratee\n * and the optional context. The resulting function expects the array to act upon.\n * @example\n * var toCharArray = function (s) { return s.split(\"\"); };\n * var wordsToCharArray = _.flatMapWith(toCharArray);\n *\n * wordsToCharArray([\"foo\", \"bar\"]) // => [\"f\", \"o\", \"o\", \"b\", \"a\", \"r\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.flatMap|flatMap}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function flatMapWith (iteratee, iterateeContext) {\n return partial(flatMap, _, iteratee, iterateeContext);\n }\n\n /**\n * Flattens an array.\n * @example showing the difference with shallowFlatten\n * var arr = [1, 2, [3, 4, [5, 6]], 7, 8];\n *\n * _.flatten(arr) // => [1, 2, 3, 4, 5, 6, 7, 8]\n * _.shallowFlatten(arr) // => [1, 2, 3, 4, [5, 6], 7, 8]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.shallowFlatten|shallowFlatten}\n * @param {Array} array\n * @returns {Array}\n */\n function flatten (array) {\n return _flatten(array, []);\n }\n\n /**\n * Returns a copy of the given array-like object without the last element.\n * @example\n * _.init([1, 2, 3, 4]) // => [1, 2, 3]\n * _.init([1]) // => []\n * _.init([]) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.tail|tail}\n * @see {@link module:lamb.head|head}, {@link module:lamb.last|last}\n * @param {ArrayLike} arrayLike\n * @returns {Array}\n */\n var init = partial(slice, _, 0, -1);\n\n /**\n * Inserts the provided element in a copy of an array-like object at the\n * specified index.
\n * If the index is greater than the length of the array-like, the element\n * will be appended at the end.
\n * Negative indexes are allowed; when a negative index is out of bounds\n * the element will be inserted at the start of the resulting array.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.insert(arr, 3, 99) // => [1, 2, 3, 99, 4, 5]\n * _.insert(arr, -2, 99) // => [1, 2, 3, 99, 4, 5]\n * _.insert(arr, 10, 99) // => [1, 2, 3, 4, 5, 99]\n * _.insert(arr, -10, 99) // => [99, 1, 2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.insertAt|insertAt}\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @param {ArrayLike} arrayLike\n * @param {Number} index\n * @param {*} element\n * @returns {Array}\n */\n function insert (arrayLike, index, element) {\n var result = slice(arrayLike);\n result.splice(index, 0, element);\n return result;\n }\n\n /**\n * Builds a partial application of {@link module:lamb.insert|insert}\n * expecting the array-like object to act upon.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.insertAt(3, 99)(arr) // => [1, 2, 3, 99, 4, 5]\n * _.insertAt(-2, 99)(arr) // => [1, 2, 3, 99, 4, 5]\n * _.insertAt(10, 99)(arr) // => [1, 2, 3, 4, 5, 99]\n * _.insertAt(-10, 99)(arr) // => [99, 1, 2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.insert|insert}\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @param {Number} index\n * @param {*} element\n * @returns {Function}\n */\n function insertAt (index, element) {\n return partial(insert, _, index, element);\n }\n\n /**\n * Returns an array of every item present in all given arrays.
\n * Note that since version 0.13.0 this function uses the [\"SameValueZero\" comparison]{@link module:lamb.isSVZ|isSVZ}.\n * @example\n * var a1 = [1, 2, 3, 4];\n * var a2 = [2, 5, 4, 6];\n * var a3 = [5, 6, 7];\n *\n * _.intersection(a1, a2) // => [2, 4]\n * _.intersection(a1, a3) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @param {...Array} array\n * @return {Array}\n */\n function intersection () {\n var rest = slice(arguments, 1);\n return uniques(arguments[0]).filter(function (item) {\n return rest.every(contains(item));\n });\n }\n\n /**\n * Checks if an array-like object contains the given value.
\n * Please note that the equality test is made with {@link module:lamb.isSVZ|isSVZ}; so you can\n * check for NaN, but 0 and -0 are the same value.
\n * See also {@link module:lamb.contains|contains} for a curried version building a predicate.\n * @example\n * var numbers = [0, 1, 2, 3, NaN];\n *\n * _.isIn(numbers, 1) // => true\n * _.isIn(numbers, 0) // => true\n * _.isIn(numbers, -0) // => true\n * _.isIn(numbers, NaN) // => true\n * _.isIn(numbers, 2, 3) // => false\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {*} value\n * @param {Number} [fromIndex=0] The position at which to begin searching for the given value.\n * @returns {Boolean}\n */\n function isIn (arrayLike, value, fromIndex) {\n var result = false;\n\n for (var i = fromIndex >>> 0, len = arrayLike.length; i < len; i++) {\n if (isSVZ(value, arrayLike[i])) {\n result = true;\n break;\n }\n }\n\n return result;\n }\n\n /**\n * Generates an array with the values passed as arguments.\n * @example\n * _.list(1, 2, 3) // => [1, 2, 3]\n *\n * @memberof module:lamb\n * @category Array\n * @param {...*} value\n * @returns {Array}\n */\n function list () {\n return arguments.length === 1 ? [arguments[0]] : Array.apply(null, arguments);\n }\n\n /**\n * Builds a partial application of {@link module:lamb.map|map} using the given iteratee and the optional context.\n * The resulting function expects the array-like object to act upon.\n * @example\n * var square = function (n) { return n * n; };\n * var getSquares = _.mapWith(square);\n *\n * getSquares([1, 2, 3, 4, 5]) // => [1, 4, 9, 16, 25]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.map|map}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {function}\n */\n function mapWith (iteratee, iterateeContext) {\n return partial(map, _, iteratee, iterateeContext);\n }\n\n /**\n * Splits an array-like object in two lists: the first with the elements satisfying the given predicate,\n * the others with the remaining elements.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var numbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n *\n * _.partition(numbers, isEven) // => [[2, 4, 6, 8, 10], [1, 3, 5, 7, 9]]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.partitionWith|partitionWith}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Array, Array<*>>}\n */\n function partition (arrayLike, predicate, predicateContext) {\n var result = [[], []];\n var len = arrayLike.length;\n\n for (var i = 0, el; i < len; i++) {\n el = arrayLike[i];\n result[predicate.call(predicateContext, el, i, arrayLike) ? 0 : 1].push(el);\n }\n\n return result;\n }\n\n /**\n * Builds a partial application of {@link module:lamb.partition|partition} using the given predicate and the optional context.\n * The resulting function expects the array-like object to act upon.\n * @example\n * var users = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"active\": false},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"active\": true},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"active\": true},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"active\": false}\n * ];\n * var isActive = _.hasKeyValue(\"active\", true);\n * var splitByActiveStatus = _.partitionWith(isActive);\n *\n * splitByActiveStatus(users) // =>\n * // [[\n * // {\"name\": \"John\", \"surname\": \"Doe\", \"active\": true},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\", \"active\": true}\n * // ], [\n * // {\"name\": \"Jane\", \"surname\": \"Doe\", \"active\": false},\n * // {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"active\": false}\n * // ]]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.partition|partition}\n * @param {ListIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function partitionWith (predicate, predicateContext) {\n return partial(partition, _, predicate, predicateContext);\n }\n\n /**\n * \"Plucks\" the values of the specified key from a list of objects.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 15}\n * ];\n *\n * _.pluck(persons, \"age\") // => [12, 40, 18, 15]\n *\n * var lists = [\n * [1, 2],\n * [3, 4, 5],\n * [6]\n * ];\n *\n * _.pluck(lists, \"length\") // => [2, 3, 1]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.pluckKey|pluckKey}\n * @param {ArrayLike} arrayLike\n * @param {String} key\n * @returns {Array}\n */\n function pluck (arrayLike, key) {\n return map(arrayLike, getKey(key));\n }\n\n /**\n * A curried version of {@link module:lamb.pluck|pluck} expecting the key to retrieve to\n * build a function waiting for the array-like object to act upon.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"surname\": \"Doe\", \"age\": 12},\n * {\"name\": \"John\", \"surname\": \"Doe\", \"age\": 40},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\", \"age\": 18},\n * {\"name\": \"Paolo\", \"surname\": \"Bianchi\", \"age\": 15}\n * ];\n * var getAges = _.pluckKey(\"age\");\n *\n * getAges(persons) // => [12, 40, 18, 15]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.pluck|pluck}\n * @function\n * @param {String} key\n * @returns {Function}\n */\n function pluckKey (key) {\n return mapWith(getKey(key));\n }\n\n /**\n * A partial application of {@link module:lamb.reduce|reduceRight} that uses the\n * provided accumulator and the optional initialValue to\n * build a function expecting the array-like object to act upon.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.reduceRightWith(_.add)(arr) // => 15\n * _.reduceRightWith(_.subtract)(arr) // => -5\n * _.reduceRightWith(_.subtract, 0)(arr) // => -15\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.reduceWith|reduceWith}\n * @see {@link module:lamb.reduce|reduce}, {@link module:lamb.reduce|reduceRight}\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {Function}\n */\n function reduceRightWith (accumulator, initialValue) {\n var fn = arguments.length === 2 ? reduceRight : binary(reduceRight);\n return partial(fn, _, accumulator, initialValue);\n }\n\n /**\n * A partial application of {@link module:lamb.reduce|reduce} that uses the\n * provided accumulator and the optional initialValue to\n * build a function expecting the array-like object to act upon.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.reduceWith(_.add)(arr) // => 15\n * _.reduceWith(_.subtract)(arr) // => -13\n * _.reduceWith(_.subtract, 0)(arr) // => -15\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.reduceRightWith|reduceRightWith}\n * @see {@link module:lamb.reduce|reduce}, {@link module:lamb.reduce|reduceRight}\n * @param {AccumulatorCallback} accumulator\n * @param {*} [initialValue]\n * @returns {Function}\n */\n function reduceWith (accumulator, initialValue) {\n var fn = arguments.length === 2 ? reduce : binary(reduce);\n return partial(fn, _, accumulator, initialValue);\n }\n\n /**\n * Reverses a copy of the given array-like object.\n * @example\n * var arr = [1, 2, 3];\n *\n * _.reverse(arr) // => [3, 2, 1];\n *\n * // `arr` still is [1, 2, 3]\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @returns {Array}\n */\n function reverse (arrayLike) {\n return slice(arrayLike).reverse();\n }\n\n /**\n * Flattens the \"first level\" of an array.\n * @example showing the difference with flatten\n * var arr = [1, 2, [3, 4, [5, 6]], 7, 8];\n *\n * _.flatten(arr) // => [1, 2, 3, 4, 5, 6, 7, 8]\n * _.shallowFlatten(arr) // => [1, 2, 3, 4, [5, 6], 7, 8]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.flatten|flatten}\n * @param {Array} array\n * @returns {Array}\n */\n function shallowFlatten (array) {\n return _arrayProto.concat.apply([], array);\n }\n\n /**\n * Returns a copy of the given array-like object without the first element.\n * @example\n * _.tail([1, 2, 3, 4]) // => [2, 3, 4]\n * _.tail([1]) // => []\n * _.tail([]) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.init|init}\n * @see {@link module:lamb.head|head}, {@link module:lamb.last|last}\n * @param {ArrayLike} arrayLike\n * @returns {Array}\n */\n var tail = partial(slice, _, 1, void 0);\n\n /**\n * Retrieves the first n elements from an array or array-like object.\n * Note that, being this a partial application of {@link module:lamb.slice|slice},\n * n can be a negative number.\n * @example\n * var arr = [1, 2, 3, 4, 5];\n *\n * _.take(arr, 3) // => [1, 2, 3]\n * _.take(arr, -1) // => [1, 2, 3, 4]\n * _.take(arr, -10) // => []\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {ArrayLike} arrayLike\n * @param {Number} n\n * @returns {Array}\n */\n var take = partial(slice, _, 0, _);\n\n /**\n * A curried version of {@link module:lamb.take|take} that expects the number of elements\n * to retrieve to build a function waiting for the list to take the elements from.\n * See the note and examples for {@link module:lamb.take|take} about passing a negative n.\n * @example\n * var take2 = _.takeN(2);\n *\n * take2([1, 2, 3, 4, 5]) // => [1, 2]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.take|take}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @see {@link module:lamb.takeWhile|takeWhile}, {@link module:lamb.dropWhile|dropWhile}\n * @param {Number} n\n * @returns {Function}\n */\n var takeN = _curry(take, 2, true);\n\n /**\n * Builds a function that takes the first n elements satisfying a predicate from an array or array-like object.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var takeWhileIsEven = _.takeWhile(isEven);\n *\n * takeWhileIsEven([1, 2, 4, 6, 8]) // => []\n * takeWhileIsEven([2, 4, 7, 8]) // => [2, 4]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.dropWhile|dropWhile}\n * @see {@link module:lamb.take|take}, {@link module:lamb.takeN|takeN}\n * @see {@link module:lamb.drop|drop}, {@link module:lamb.dropN|dropN}\n * @param {ListIteratorCallback} predicate\n * @param {Object} predicateContext\n * @returns {Function}\n */\n function takeWhile (predicate, predicateContext) {\n return function (arrayLike) {\n return slice(arrayLike, 0, _findSliceEndIndex(arrayLike, predicate, predicateContext));\n };\n }\n\n /**\n * Transposes a matrix. Can also be used to reverse a {@link module:lamb.zip|zip} operation.
\n * Just like {@link module:lamb.zip|zip}, the received array-like objects will be truncated to the\n * shortest length.\n * @example transposing a matrix\n * _.transpose([\n * [1, 2, 3],\n * [4, 5, 6],\n * [7, 8, 9]\n * ]) // =>\n * // [\n * // [1, 4, 7],\n * // [2, 5, 8],\n * // [3, 6, 9]\n * // ]\n *\n * @example showing the relationship with zip\n * var zipped = _.zip([\"a\", \"b\", \"c\"], [1, 2, 3]); // => [[\"a\", 1], [\"b\", 2], [\"c\", 3]]\n *\n * _.transpose(zipped) // => [[\"a\", \"b\", \"c\"], [1, 2, 3]]\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike>} arrayLike\n * @returns {Array>}\n */\n function transpose (arrayLike) {\n var result = [];\n var minLen = apply(Math.min, pluck(arrayLike, \"length\")) >>> 0;\n var len = arrayLike.length;\n\n for (var i = 0, j; i < minLen; i++) {\n result.push([]);\n\n for (j = 0; j < len; j++) {\n result[i][j] = arrayLike[j][i];\n }\n }\n\n return result;\n }\n\n /**\n * Returns a list of every unique element present in the given array-like objects.\n * @example\n * _.union([1, 2, 3, 2], [3, 4], [1, 5]) // => [1, 2, 3, 4, 5]\n * _.union(\"abc\", \"bcd\", \"cde\") // => [\"a\", \"b\", \"c\", \"d\", \"e\"]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {...ArrayLike} arrayLike\n * @returns {Array}\n */\n var union = compose(uniques, flatMapWith(unary(slice)), list);\n\n /**\n * Returns an array comprised of the unique elements of the given array-like object.
\n * Can work with lists of complex objects if supplied with an iteratee.
\n * Note that since version 0.13.0 this function uses the [\"SameValueZero\" comparison]{@link module:lamb.isSVZ|isSVZ}.\n * @example with simple values\n * _.uniques([1, 2, 2, 3, 4, 3, 5, 1]) // => [1, 2, 3, 4, 5]\n *\n * @example with complex values\n * var data = [\n * {id: \"1\"},\n * {id: \"4\"},\n * {id: \"5\"},\n * {id: \"1\"},\n * {id: \"5\"},\n * ];\n *\n * _.uniques(data, _.getKey(\"id\")) // => [{id: \"1\"}, {id: \"4\"}, {\"id\": 5}]\n *\n * @memberof module:lamb\n * @category Array\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} [iteratee] Defaults to the [identity function]{@link module:lamb.identity}.\n * @param {Object} [iterateeContext]\n * @returns {Array}\n */\n function uniques (arrayLike, iteratee, iterateeContext) {\n if (typeof iteratee !== \"function\") {\n iteratee = identity;\n }\n\n var result = [];\n var seen = [];\n var value;\n\n for (var i = 0, len = arrayLike.length; i < len; i++) {\n value = iteratee.call(iterateeContext, arrayLike[i], i, arrayLike);\n\n if (!isIn(seen, value)) {\n seen.push(value);\n result.push(arrayLike[i]);\n }\n }\n\n return result;\n }\n\n /**\n * Builds a list of arrays out of the given array-like objects by pairing items with the same index.
\n * The received array-like objects will be truncated to the shortest length.
\n * See also {@link module:lamb.zipWithIndex|zipWithIndex} and {@link module:lamb.transpose|transpose} for the reverse operation.\n * @example\n * _.zip(\n * [\"a\", \"b\", \"c\"],\n * [1, 2, 3],\n * [true, false, true]\n * ) // => [[\"a\", 1, true], [\"b\", 2, false], [\"c\", 3, true]]\n *\n * _.zip([1, 2, 3, 4], [5, 6, 7]) // => [[1, 5], [2, 6], [3, 7]]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {...ArrayLike} arrayLike\n * @returns {Array>}\n */\n var zip = compose(transpose, list);\n\n /**\n * \"{@link module:lamb.zip|Zips}\" an array-like object by pairing its values with their index.\n * @example\n * _.zipWithIndex([\"a\", \"b\", \"c\"]) // => [[\"a\", 0], [\"b\", 1], [\"c\", 2]]\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @param {ArrayLike} arrayLike\n * @returns {Array>}\n */\n var zipWithIndex = mapWith(binary(list));\n\n lamb.contains = contains;\n lamb.difference = difference;\n lamb.drop = drop;\n lamb.dropN = dropN;\n lamb.dropWhile = dropWhile;\n lamb.filterWith = filterWith;\n lamb.find = find;\n lamb.findIndex = findIndex;\n lamb.flatMap = flatMap;\n lamb.flatMapWith = flatMapWith;\n lamb.flatten = flatten;\n lamb.init = init;\n lamb.insert = insert;\n lamb.insertAt = insertAt;\n lamb.intersection = intersection;\n lamb.isIn = isIn;\n lamb.list = list;\n lamb.mapWith = mapWith;\n lamb.partition = partition;\n lamb.partitionWith = partitionWith;\n lamb.pluck = pluck;\n lamb.pluckKey = pluckKey;\n lamb.reduceRightWith = reduceRightWith;\n lamb.reduceWith = reduceWith;\n lamb.reverse = reverse;\n lamb.shallowFlatten = shallowFlatten;\n lamb.tail = tail;\n lamb.take = take;\n lamb.takeN = takeN;\n lamb.takeWhile = takeWhile;\n lamb.transpose = transpose;\n lamb.union = union;\n lamb.uniques = uniques;\n lamb.zip = zip;\n lamb.zipWithIndex = zipWithIndex;\n\n\n function _groupWith (makeValue, startValue) {\n return function (arrayLike, iteratee, iterateeContext) {\n return reduce(arrayLike, function (result, element, idx) {\n var key = iteratee.call(iterateeContext, element, idx, arrayLike);\n var value = makeValue(key in result ? result[key] : startValue , element);\n\n result[key] = value;\n\n return result;\n }, {});\n };\n }\n\n /**\n * Transforms an array-like object in a lookup table with the keys generated by the provided\n * iteratee, having as values the count of matches for the key.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"age\": 12},\n * {\"name\": \"John\", \"age\": 40},\n * {\"name\": \"Mario\", \"age\": 17},\n * {\"name\": \"Paolo\", \"age\": 15}\n * ];\n * var getAgeStatus = function (person) { return person.age >= 18 ? \"adult\" : \"minor\"; };\n *\n * _.count(persons, getAgeStatus) // => {\"adult\": 1, \"minor\": 3}\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Object}\n */\n var count = _groupWith(partial(add, 1), 0);\n\n /**\n * Using the provided iteratee, and its optional context, builds a partial application of\n * {@link module:lamb.count|count} expecting the array-like object to act upon.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"city\": \"New York\"},\n * {\"name\": \"John\", \"city\": \"New York\"},\n * {\"name\": \"Mario\", \"city\": \"Rome\"},\n * {\"name\": \"Paolo\"}\n * ];\n * var getCityOrUnknown = _.adapter(_.getKey(\"city\"), _.always(\"Unknown\"));\n * var countByCity = _.countBy(getCityOrUnknown);\n *\n * countByCity(persons) // => {\"New York\": 2, \"Rome\": 1, \"Unknown\": 1}\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.count|count}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function countBy (iteratee, iterateeContext) {\n return partial(count, _, iteratee, iterateeContext);\n }\n\n /**\n * Transforms an array-like object into a lookup table using the provided iteratee as a grouping\n * criterion to generate keys and values.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"city\": \"New York\"},\n * {\"name\": \"John\", \"city\": \"New York\"},\n * {\"name\": \"Mario\", \"city\": \"Rome\"},\n * {\"name\": \"Paolo\"}\n * ];\n * var getCity = _.getKey(\"city\");\n * var personsByCity = _.group(persons, getCity);\n *\n * // \"personsByCity\" holds:\n * // {\n * // \"New York\": [\n * // {\"name\": \"Jane\", \"city\": \"New York\"},\n * // {\"name\": \"John\", \"city\": \"New York\"}\n * // ],\n * // \"Rome\": [\n * // {\"name\": \"Mario\", \"city\": \"Rome\"}\n * // ],\n * // \"undefined\": [\n * // {\"name\": \"Paolo\"}\n * // ]\n * // }\n *\n * @example Adding a custom value for missing keys\n *\n * var getCityOrUnknown = _.adapter(getCity, _.always(\"Unknown\"));\n *\n * var personsByCity = _.group(persons, getCityOrUnknown);\n *\n * // \"personsByCity\" holds:\n * // {\n * // \"New York\": [\n * // {\"name\": \"Jane\", \"city\": \"New York\"},\n * // {\"name\": \"John\", \"city\": \"New York\"}\n * // ],\n * // \"Rome\": [\n * // {\"name\": \"Mario\", \"city\": \"Rome\"}\n * // ],\n * // \"Unknown\": [\n * // {\"name\": \"Paolo\"}\n * // ]\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.groupBy|groupBy}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Object}\n */\n var group = _groupWith(invoker(\"concat\"), []);\n\n /**\n * Using the provided iteratee, and its optional context, builds a partial application\n * of {@link module:lamb.group|group} expecting the array-like object to act upon.\n * @example\n * var persons = [\n * {\"name\": \"Jane\", \"age\": 12},\n * {\"name\": \"John\", \"age\": 40},\n * {\"name\": \"Mario\", \"age\": 18},\n * {\"name\": \"Paolo\", \"age\": 15}\n * ];\n *\n * var getAgeStatus = function (person) { return person.age > 20 ? \"over 20\" : \"under 20\"; };\n * var groupByAgeStatus = _.groupBy(getAgeStatus);\n *\n * var personsByAgeStatus = groupByAgeStatus(persons);\n *\n * // \"personsByAgeStatus\" holds:\n * // {\n * // \"under 20\": [\n * // {\"name\": \"Jane\", \"age\": 12},\n * // {\"name\": \"Mario\", \"age\": 18},\n * // {\"name\": \"Paolo\", \"age\": 15}\n * // ],\n * // \"over 20\": [\n * // {\"name\": \"John\", \"age\": 40}\n * // ]\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.group|group}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.index|index}, {@link module:lamb.indexBy|indexBy}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function groupBy (iteratee, iterateeContext) {\n return partial(group, _, iteratee, iterateeContext);\n }\n\n /**\n * Similar to {@link module:lamb.group|group}, but the generated lookup table will have\n * only one element of the original array-like object for each value.
\n * Should be used only when you're sure that your iteratee won't produce\n * duplicate keys, otherwise only the last evaluated element will be in the result.\n * @example\n * var users = [\n * {id: 1, name: \"John\"},\n * {id: 2, name: \"Jane\"},\n * {id: 3, name: \"Mario\"},\n * {id: 4, name: \"John\"}\n * ];\n *\n * var indexedUsers = _.index(users, _.getKey(\"id\"));\n *\n * // \"indexedUsers\" holds:\n * // {\n * // \"1\": {id: 1, name: \"John\"},\n * // \"2\": {id: 2, name: \"Jane\"},\n * // \"3\": {id: 3, name: \"Mario\"},\n * // \"4\": {id: 4, name: \"John\"}\n * // }\n *\n * @example Result of an iteratee producing a duplicate key:\n * var users = [\n * {id: 1, name: \"John\"},\n * {id: 2, name: \"Jane\"},\n * {id: 3, name: \"Mario\"},\n * {id: 4, name: \"John\"}\n * ];\n *\n * var indexedUsers = _.index(users, _.getKey(\"name\"));\n *\n * // \"indexedUsers\" holds:\n * // {\n * // \"John\": {\"id\": 4, \"name\": \"John\"},\n * // \"Jane\": {\"id\": 2, \"name\": \"Jane\"},\n * // \"Mario\": {\"id\": 3, \"name\": \"Mario\"}\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.indexBy|indexBy}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @param {ArrayLike} arrayLike\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Object}\n */\n var index = _groupWith(getArgAt(1));\n\n /**\n * Using the provided iteratee, and its optional context, builds a partial application\n * of {@link module:lamb.index|index} expecting the array-like object to act upon.\n * @example\n * var users = [\n * {id: 1, name: \"John\"},\n * {id: 2, name: \"Jane\"},\n * {id: 3, name: \"Mario\"}\n * ];\n * var indexByID = _.indexBy(_.getKey(\"id\"));\n *\n * var indexedUsers = indexByID(users);\n *\n * // \"indexedUsers\" holds:\n * // {\n * // \"1\": {id: 1, name: \"John\"},\n * // \"2\": {id: 2, name: \"Jane\"},\n * // \"3\": {id: 3, name: \"Mario\"}\n * // }\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.index|index}\n * @see {@link module:lamb.count|count}, {@link module:lamb.countBy|countBy}\n * @see {@link module:lamb.group|group}, {@link module:lamb.groupBy|groupBy}\n * @param {ListIteratorCallback} iteratee\n * @param {Object} [iterateeContext]\n * @returns {Function}\n */\n function indexBy (iteratee, iterateeContext) {\n return partial(index, _, iteratee, iterateeContext);\n }\n\n lamb.count = count;\n lamb.countBy = countBy;\n lamb.group = group;\n lamb.groupBy = groupBy;\n lamb.index = index;\n lamb.indexBy = indexBy;\n\n\n function _comparer (a, b) {\n var result = 0;\n\n if (typeof a !== typeof b) {\n a = String(a);\n b = String(b);\n }\n\n if (!isSVZ(a, b)) {\n if (a > b || a !== a) {\n result = 1;\n } else if (a < b || b !== b) {\n result = -1;\n }\n }\n\n return result;\n }\n\n function _compareWith (criteria) {\n var len = criteria.length;\n\n return function (a, b) {\n var result = 0;\n var isDescSort;\n var criterion;\n\n for (var i = 0; i < len; i++) {\n criterion = criteria[i];\n result = criterion.compare(a.value, b.value);\n\n if (result !== 0) {\n isDescSort = criteria[i].isDescending;\n break;\n }\n }\n\n if (result === 0) {\n isDescSort = criteria[len - 1].isDescending;\n result = a.index - b.index;\n }\n\n return isDescSort ? -result : result;\n };\n }\n\n function _getInsertionIndex (array, element, comparer, start, end) {\n if (array.length === 0) {\n return 0;\n }\n\n var pivot = (start + end) >> 1;\n var result = comparer({\n value: element,\n index: pivot\n }, {\n value: array[pivot],\n index: pivot\n });\n\n if (end - start <= 1) {\n return result < 0 ? pivot : pivot + 1;\n } else if (result < 0) {\n return _getInsertionIndex(array, element, comparer, start, pivot);\n } else if (result === 0) {\n return pivot + 1;\n } else {\n return _getInsertionIndex(array, element, comparer, pivot, end);\n }\n }\n\n function _makeCriteria (sorters) {\n return sorters.length ? sorters.map(_makeCriterion) : [_sorter()];\n }\n\n function _makeCriterion (criterion) {\n return typeof Object(criterion).compare === \"function\" ? criterion : _sorter(criterion);\n }\n\n function _sorter (reader, isDescending, comparer) {\n return {\n isDescending: isDescending === true,\n compare: function (a, b) {\n if (typeof reader === \"function\" && reader !== identity) {\n a = reader(a);\n b = reader(b);\n }\n\n return (comparer || _comparer)(a, b);\n }\n };\n }\n\n /**\n * Returns a [stably]{@link https://en.wikipedia.org/wiki/Sorting_algorithm#Stability} sorted copy of an\n * array-like object using the given criteria.
\n * Sorting criteria are built using Lamb's {@link module:lamb.sorter|sorter} function, but you can also\n * pass simple \"reader\" functions and default ascending sorters will be built for you.
\n * A \"reader\" is a function that evaluates the array element and supplies the value to be used in the comparison.
\n * Please note that if the arguments received by the default comparer aren't of the same type, they will be compared as strings.\n *\n * @example Stable sort:\n * var persons = [\n * {\"name\": \"John\", \"surname\" :\"Doe\"},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\"},\n * {\"name\": \"John\", \"surname\" :\"Moe\"},\n * {\"name\": \"Jane\", \"surname\": \"Foe\"}\n * ];\n *\n * var personsByName = _.sort(persons, _.getKey(\"name\"));\n *\n * // personsByName holds:\n * // [\n * // {\"name\": \"Jane\", \"surname\": \"Foe\"},\n * // {\"name\": \"John\", \"surname\" :\"Doe\"},\n * // {\"name\": \"John\", \"surname\" :\"Moe\"},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * // ]\n *\n * @example Stable multi-sort:\n * var personsByNameAscSurnameDesc = _.sort(\n * persons,\n * _.getKey(\"name\"),\n * _.sorterDesc(_.getKey(\"surname\"))\n * );\n *\n * // personsByNameAscSurnameDesc holds:\n * // [\n * // {\"name\": \"Jane\", \"surname\": \"Foe\"},\n * // {\"name\": \"John\", \"surname\" :\"Moe\"},\n * // {\"name\": \"John\", \"surname\" :\"Doe\"},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * // ]\n *\n * @example Using custom comparers:\n * var localeSorter = new Intl.Collator(\"it\");\n * var chars = [\"a\", \"è\", \"à\", \"é\", \"c\", \"b\", \"e\"];\n *\n * _.sort(chars, localeSorter) // => [\"a\", \"à\", \"b\", \"c\", \"e\", \"é\", \"è\"]\n *\n * var localeSorterDesc = _.sorterDesc(_.identity, localeSorter.compare);\n *\n * _.sort(chars, localeSorterDesc) // => [\"è\", \"é\", \"e\", \"c\", \"b\", \"à\", \"a\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}\n * @param {ArrayLike} arrayLike\n * @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}]\n * @returns {Array}\n */\n function sort (arrayLike) {\n var criteria = _makeCriteria(slice(arguments, 1));\n var data = [];\n var result = [];\n var len = arrayLike.length;\n\n for (var i = 0; i < len; i++) {\n data.push({\n value: arrayLike[i],\n index: i\n });\n }\n\n data.sort(_compareWith(criteria));\n\n for (i = 0; i < len; i++) {\n result.push(data[i].value);\n }\n\n return result;\n }\n\n /**\n * Inserts an element in a copy of a sorted array respecting the sort order.\n * @example with simple values\n * _.sortedInsert([], 1) // => [1]\n * _.sortedInsert([2, 4, 6], 5) // => [2, 4, 5, 6]\n * _.sortedInsert([4, 2, 1], 3, _.sorterDesc()) // => [4, 3, 2, 1]\n *\n * @example with complex values\n * var persons = [\n * {\"name\": \"jane\", \"surname\": \"doe\"},\n * {\"name\": \"John\", \"surname\": \"Doe\"},\n * {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * ];\n *\n * var getLowerCaseName = _.compose(\n * _.invoker(\"toLowerCase\"),\n * _.getKey(\"name\")\n * );\n *\n * var result = _.sortedInsert(\n * persons,\n * {\"name\": \"marco\", \"surname\": \"Rossi\"},\n * getLowerCaseName\n * );\n *\n * // `result` holds:\n * // [\n * // {\"name\": \"jane\", \"surname\": \"doe\"},\n * // {\"name\": \"John\", \"surname\": \"Doe\"},\n * // {\"name\": \"marco\", \"surname\": \"Rossi\"},\n * // {\"name\": \"Mario\", \"surname\": \"Rossi\"}\n * // ]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}\n * @see {@link module:lamb.insert|insert}, {@link module:lamb.insertAt|insertAt} to insert the element at a specific index\n * @param {Array} array\n * @param {*} element\n * @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}] - The sorting criteria used to sort the array.\n * @returns {Array}\n */\n function sortedInsert (array, element) {\n var criteria = _makeCriteria(slice(arguments, 2));\n var result = array.concat();\n var idx = _getInsertionIndex(array, element, _compareWith(criteria), 0, array.length);\n\n result.splice(idx, 0, element);\n return result;\n }\n\n /**\n * Creates an ascending sort criterion with the provided reader and comparer.
\n * See {@link module:lamb.sort|sort} for various examples.\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorterDesc|sorterDesc}\n * @param {Function} [reader={@link module:lamb.identity|identity}] A function meant to generate a simple value from a complex one. The function should evaluate the array element and supply the value to be passed to the comparer.\n * @param {Function} [comparer] An optional custom comparer function.\n * @returns {Sorter}\n */\n var sorter = partial(_sorter, _, false, _);\n\n /**\n * Creates a descending sort criterion with the provided reader and comparer.
\n * See {@link module:lamb.sort|sort} for various examples.\n *\n * @memberof module:lamb\n * @category Array\n * @function\n * @see {@link module:lamb.sortedInsert|sortedInsert}\n * @see {@link module:lamb.sort|sort}, {@link module:lamb.sortWith|sortWith}\n * @see {@link module:lamb.sorter|sorter}\n * @param {Function} [reader={@link module:lamb.identity|identity}] A function meant to generate a simple value from a complex one. The function should evaluate the array element and supply the value to be passed to the comparer.\n * @param {Function} [comparer] An optional custom comparer function.\n * @returns {Sorter}\n */\n var sorterDesc = partial(_sorter, _, true, _);\n\n /**\n * Builds a partial application of {@link module:lamb.sort|sort} using the provided criteria. The returned\n * function expects the array-like object to sort.\n * As usual, sorting criteria are built using Lamb's {@link module:lamb.sorter|sorter} function, but you can also\n * pass simple \"reader\" functions and default ascending sorters will be built.
\n * A \"reader\" is a function that evaluates the array element and supplies the value to be used in the comparison.
\n * See {@link module:lamb.sort|sort} for more examples.\n *\n * @example\n * var sortAsNumbers = _.sortWith(parseFloat);\n * var weights = [\"2 Kg\", \"10 Kg\", \"1 Kg\", \"7 Kg\"];\n *\n * sortAsNumbers(weights) // => [\"1 Kg\", \"2 Kg\", \"7 Kg\", \"10 Kg\"]\n *\n * @memberof module:lamb\n * @category Array\n * @see {@link module:lamb.sort|sort}\n * @see {@link module:lamb.sorter|sorter}, {@link module:lamb.sorterDesc|sorterDesc}\n * @param {...(Sorter|Function)} [sorter={@link module:lamb.sorter|sorter()}]\n * @returns {Function}\n */\n function sortWith () {\n var sorters = slice(arguments);\n\n return function (arrayLike) {\n return sort.apply(null, [arrayLike].concat(sorters));\n };\n }\n\n lamb.sort = sort;\n lamb.sortedInsert = sortedInsert;\n lamb.sorter = sorter;\n lamb.sorterDesc = sorterDesc;\n lamb.sortWith = sortWith;\n\n\n function _currier (fn, arity, isRightCurry, slicer, argsHolder) {\n return function () {\n var args = argsHolder.concat(slicer(arguments));\n\n if (args.length >= arity) {\n return fn.apply(this, isRightCurry ? args.reverse() : args);\n } else {\n return _currier(fn, arity, isRightCurry, slicer, args);\n }\n };\n }\n\n function _curry (fn, arity, isRightCurry, isAutoCurry) {\n var slicer = isAutoCurry ? slice : function (a) {\n return a.length ? [a[0]] : [];\n };\n\n if ((arity >>> 0) !== arity) {\n arity = fn.length;\n }\n\n return _currier(fn, arity, isRightCurry, slicer, []);\n }\n\n /**\n * Applies the passed function to the given argument list.\n * @example\n * _.apply(_.add, [3, 4]) // => 7\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {ArrayLike} args\n * @returns {*}\n */\n function apply (fn, args) {\n return fn.apply(fn, slice(args));\n }\n\n /**\n * A curried version of {@link module:lamb.apply|apply}. Expects an array-like object to use as arguments\n * and builds a function waiting for the target of the application.\n * @example\n * var data = [3, 4];\n * var applyDataTo = _.applyArgs(data);\n *\n * applyDataTo(_.add) // => 7\n * applyDataTo(_.multiply) // => 12\n *\n * @memberof module:lamb\n * @category Function\n * @function\n * @param {ArrayLike} args\n * @returns {Function}\n */\n var applyArgs = _curry(apply, 2, true);\n\n /**\n * Builds a function that passes only the specified amount of arguments to the given function.
\n * See also {@link module:lamb.binary|binary} and {@link module:lamb.unary|unary} for common use\n * cases shortcuts.\n * @example\n * var data = [\"1-2\", \"13-5\", \"6-23\"];\n * var getDashIndex = _.invoker(\"indexOf\", \"-\");\n *\n * data.map(getDashIndex) // => [1, 2, -1]\n * data.map(_.aritize(getDashIndex, 1)) // = > [1, 2, 1]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} arity\n * @returns {Function}\n */\n function aritize (fn, arity) {\n return function () {\n return apply(fn, slice(arguments, 0, arity));\n };\n }\n\n /**\n * Builds a function that passes only two arguments to the given function.
\n * It's simply a shortcut for a common use case of {@link module:lamb.aritize|aritize},\n * exposed for convenience.
\n * See also {@link module:lamb.unary|unary}.\n * @example\n * _.list(1, 2, 3, 4, 5) // => [1, 2, 3, 4, 5]\n * _.binary(_.list)(1, 2, 3, 4, 5) // => [1, 2]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @returns {Function}\n */\n function binary (fn) {\n return function (a, b) {\n return fn(a, b);\n };\n }\n\n /**\n * Transforms the evaluation of the given function in the evaluation of a sequence of functions\n * expecting only one argument. Each function of the sequence is a partial application of the\n * original one, which will be applied when the specified (or derived) arity is consumed.
\n * Currying will start from the leftmost argument: use {@link module:lamb.curryRight|curryRight}\n * for right currying.
\n * See also {@link module:lamb.curryable|curryable}, {@link module:lamb.curryableRight|curryableRight}\n * and {@link module:lamb.partial|partial}.\n * @example\n * var multiplyBy = _.curry(_.multiply);\n * var multiplyBy10 = multiplyBy(10);\n *\n * multiplyBy10(5) // => 50\n * multiplyBy10()(5) // => 50\n * multiplyBy10()()(2) // => 20\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curry (fn, arity) {\n return _curry(fn, arity, false);\n }\n\n /**\n * Same as {@link module:lamb.curry|curry}, but currying starts from the rightmost argument.\n * @example\n * var divideBy = _.curryRight(_.divide);\n * var halve = divideBy(2);\n * halve(3) // => 1.5\n * halve(3, 7) // => 1.5\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curryRight (fn, arity) {\n return _curry(fn, arity, true);\n }\n\n /**\n * Builds an auto-curried function. The resulting function can be called multiple times with\n * any number of arguments, and the original function will be applied only when the specified\n * (or derived) arity is consumed.
\n * Currying will start from the leftmost argument: use {@link module:lamb.curryableRight|curryableRight}\n * for right currying.
\n * Note that you can pass undefined values as arguments explicitly, if you are so inclined, but empty\n * calls doesn't consume the arity.
\n * See also {@link module:lamb.curry|curry}, {@link module:lamb.curryRight|curryRight} and\n * {@link module:lamb.partial|partial}.\n * @example\n * var collectFourElements = _.curryable(_.list, 4);\n *\n * collectFourElements(2)(3)(4)(5) // => [2, 3, 4, 5]\n * collectFourElements(2)(3, 4)(5) // => [2, 3, 4, 5]\n * collectFourElements(2, 3, 4, 5) // => [2, 3, 4, 5]\n * collectFourElements()(2)()(3, 4, 5) // => [2, 3, 4, 5]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curryable (fn, arity) {\n return _curry(fn, arity, false, true);\n }\n\n /**\n * Same as {@link module:lamb.curryable|curryable}, but currying starts from the rightmost argument.\n * @example\n * var collectFourElements = _.curryableRight(_.list, 4);\n *\n * collectFourElements(2)(3)(4)(5) // => [5, 4, 3, 2]\n * collectFourElements(2)(3, 4)(5) // => [5, 4, 3, 2]\n * collectFourElements(2, 3, 4, 5) // => [5, 4, 3, 2]\n * collectFourElements()(2)()(3, 4, 5) // => [5, 4, 3, 2]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} [arity=fn.length]\n * @returns {Function}\n */\n function curryableRight (fn, arity) {\n return _curry(fn, arity, true, true);\n }\n\n /**\n * Returns a function that will execute the given function only if it stops being called for the specified timespan.
\n * See also {@link module:lamb.throttle|throttle} for a different behaviour where the first call happens immediately.\n * @example A common use case of debounce in a browser environment\n * var updateLayout = function () {\n * // some heavy DOM operations here\n * };\n *\n * window.addEventListener(\"resize\", _.debounce(updateLayout, 200), false);\n *\n * // The resize event is fired repeteadly until the user stops resizing the\n * // window, while the `updateLayout` function is called only once: 200 ms\n * // after he stopped.\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} timespan - Expressed in milliseconds\n * @returns {Function}\n */\n function debounce (fn, timespan) {\n var timeoutID;\n\n return function () {\n var context = this;\n var args = arguments;\n var debounced = function () {\n timeoutID = null;\n fn.apply(context, args);\n };\n\n clearTimeout(timeoutID);\n timeoutID = setTimeout(debounced, timespan);\n };\n }\n\n /**\n * Returns a function that applies its arguments to the original function in reverse order.\n * @example\n * _.list(1, 2, 3) // => [1, 2, 3]\n * _.flip(_.list)(1, 2, 3) // => [3, 2, 1]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @returns {Function}\n */\n function flip (fn) {\n return function () {\n var args = slice(arguments).reverse();\n return fn.apply(this, args);\n };\n }\n\n /**\n * Builds a function that returns the argument received at the given index.
\n * As with {@link module:lamb.getAt|getAt} negative indexes are allowed.
\n * The resulting function will return undefined if no arguments are\n * passed or if the index is out of bounds.\n * @example\n * var getFirstArg = getArgAt(0);\n * var getLastArg = getArgAt(-1);\n *\n * getFirstArg(1, 2, 3) // => 1\n * getLastArg(1, 2, 3) // => 3\n *\n * getArgAt()(1, 2, 3) // => undefined\n * getArgAt(6)(1, 2, 3) // => undefined\n * getArgAt(1)() // => undefined\n *\n * @memberof module:lamb\n * @category Function\n * @param {Number} index\n * @returns {Function}\n */\n function getArgAt (index) {\n return compose(getAt(index), list);\n }\n\n /**\n * Builds a function that will invoke the given method name on any received object and return\n * the result. If no method with such name is found the function will return undefined.\n * Along with the method name it's possible to supply some arguments that will be bound to the method call.
\n * Further arguments can also be passed when the function is actually called, and they will be concatenated\n * to the bound ones.
\n * If different objects share a method name it's possible to build polymorphic functions as you can see in\n * the example below.
\n * {@link module:lamb.condition|Condition} can be used to wrap invoker to avoid this behaviour\n * by adding a predicate, while {@link module:lamb.adapter|adapter} can build more complex polymorphic functions\n * without the need of homonymy.
\n * Returning undefined or checking for such value is meant to favor composition and interoperability\n * between the aforementioned functions: for a more standard behaviour see also {@link module:lamb.generic|generic}.\n * See also {@link module:lamb.invokerOn|invokerOn}.\n * @example Basic polymorphism with invoker\n * var polySlice = _.invoker(\"slice\");\n *\n * polySlice([1, 2, 3, 4, 5], 1, 3) // => [2, 3]\n * polySlice(\"Hello world\", 1, 3) // => \"el\"\n *\n * @example With bound arguments\n * var substrFrom2 = _.invoker(\"substr\", 2);\n * substrFrom2(\"Hello world\") // => \"llo world\"\n * substrFrom2(\"Hello world\", 5) // => \"llo w\"\n *\n * @memberof module:lamb\n * @category Function\n * @param {String} methodName\n * @param {...*} [boundArg]\n * @returns {Function}\n */\n function invoker (methodName) {\n var boundArgs = slice(arguments, 1);\n\n return function (target) {\n var args = slice(arguments, 1);\n var method = target[methodName];\n return type(method) === \"Function\" ? method.apply(target, boundArgs.concat(args)) : void 0;\n };\n }\n\n /**\n * Accepts an object and builds a function expecting a method name, and optionally arguments, to call on such object.\n * Like {@link module:lamb.invoker|invoker}, if no method with the given name is found the function will return undefined.\n * @example\n * var isEven = function (n) { return n % 2 === 0; };\n * var arr = [1, 2, 3, 4, 5];\n * var invokerOnArr = _.invokerOn(arr);\n *\n * invokerOnArr(\"filter\", isEven) // => [2, 4]\n * invokerOnArr(\"slice\", 1, 3) // => [2, 3]\n *\n * @memberof module:lamb\n * @category Function\n * @see {@link module:lamb.invoker|invoker}\n * @param {Object} target\n * @returns {Function}\n */\n function invokerOn (target) {\n return function (methodName) {\n var args = slice(arguments, 1);\n var method = target[methodName];\n return type(method) === \"Function\" ? method.apply(target, args) : void 0;\n };\n }\n\n /**\n * Builds a function that allows to map over the received arguments before applying them to the original one.\n * @example\n * var sumArray = _.reduceWith(_.add);\n * var sum = _.compose(sumArray, _.list);\n *\n * sum(1, 2, 3, 4, 5) // => 15\n *\n * var square = _.partial(Math.pow, _, 2);\n * var sumSquares = _.mapArgs(sum, square);\n *\n * sumSquares(1, 2, 3, 4, 5) // => 55\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {ListIteratorCallback} mapper\n * @returns {Function}\n */\n function mapArgs (fn, mapper) {\n return compose(partial(apply, fn), mapWith(mapper), list);\n }\n\n /**\n * Creates a pipeline of functions, where each function consumes the result of the previous one.
\n * See also {@link module:lamb.compose|compose}.\n * @example\n * var square = _.partial(Math.pow, _, 2);\n * var getMaxAndSquare = _.pipe(Math.max, square);\n *\n * getMaxAndSquare(3, 5) // => 25\n *\n * @memberof module:lamb\n * @category Function\n * @function\n * @param {...Function} fn\n * @returns {Function}\n */\n var pipe = flip(compose);\n\n /**\n * Builds a function that allows to \"tap\" into the arguments of the original one.\n * This allows to extract simple values from complex ones, transform arguments or simply intercept them.\n * If a \"tapper\" isn't found the argument is passed as it is.\n * @example\n * var someObject = {count: 5};\n * var someArrayData = [2, 3, 123, 5, 6, 7, 54, 65, 76, 0];\n * var getDataAmount = _.tapArgs(_.add, _.getKey(\"count\"), _.getKey(\"length\"));\n *\n * getDataAmount(someObject, someArrayData); // => 15\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {...?Function} [tapper]\n * @returns {Function}\n */\n function tapArgs (fn) {\n var tappers = slice(arguments, 1);\n\n return function () {\n var len = arguments.length;\n var args = [];\n\n for (var i = 0; i < len; i++) {\n args.push(tappers[i] ? tappers[i](arguments[i]) : arguments[i]);\n }\n\n return fn.apply(this, args);\n };\n }\n\n /**\n * Returns a function that will invoke the passed function at most once in the given timespan.
\n * The first call in this case happens as soon as the function is invoked; see also {@link module:lamb.debounce|debounce}\n * for a different behaviour where the first call is delayed.\n * @example\n * var log = _.throttle(console.log.bind(console), 5000);\n *\n * log(\"Hi\"); // console logs \"Hi\"\n * log(\"Hi again\"); // nothing happens\n * // after five seconds\n * log(\"Hello world\"); // console logs \"Hello world\"\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @param {Number} timespan - Expressed in milliseconds.\n * @returns {Function}\n */\n function throttle (fn, timespan) {\n var result;\n var lastCall = 0;\n\n return function () {\n var now = Date.now();\n\n if (now - lastCall >= timespan) {\n lastCall = now;\n result = fn.apply(this, arguments);\n }\n\n return result;\n };\n }\n\n /**\n * Builds a function that passes only one argument to the given function.
\n * It's simply a shortcut for a common use case of {@link module:lamb.aritize|aritize},\n * exposed for convenience.
\n * See also {@link module:lamb.binary|binary}.\n * @example\n * var weights = [\"2 Kg\", \"10 Kg\", \"1 Kg\", \"7 Kg\"];\n *\n * weights.map(_.unary(parseInt)) // => [2, 10, 1, 7]\n *\n * @memberof module:lamb\n * @category Function\n * @param {Function} fn\n * @returns {Function}\n */\n function unary (fn) {\n return function (a) {\n return fn(a);\n };\n }\n\n /**\n * Wraps the function fn inside a wrapper function.
\n * This allows to conditionally execute fn, to tamper with its arguments or return value\n * and to run code before and after its execution.
\n * Being this nothing more than a \"{@link module:lamb.flip|flipped}\" [partial application]{@link module:lamb.partial},\n * you can also easily build new functions from existent ones.\n * @example\n * var arrayMax = _.wrap(Math.max, _.apply);\n *\n * arrayMax([4, 5, 2, 6, 1]) // => 6\n *\n * @memberof module:lamb\n * @category Function\n * @function\n * @param {Function} fn\n * @param {Function} wrapper\n * @returns {Function}\n */\n var wrap = binary(flip(partial));\n\n lamb.apply = apply;\n lamb.applyArgs = applyArgs;\n lamb.aritize = aritize;\n lamb.binary = binary;\n lamb.curry = curry;\n lamb.curryRight = curryRight;\n lamb.curryable = curryable;\n lamb.curryableRight = curryableRight;\n lamb.debounce = debounce;\n lamb.flip = flip;\n lamb.getArgAt = getArgAt;\n lamb.invoker = invoker;\n lamb.invokerOn = invokerOn;\n lamb.mapArgs = mapArgs;\n lamb.pipe = pipe;\n lamb.tapArgs = tapArgs;\n lamb.throttle = throttle;\n lamb.unary = unary;\n lamb.wrap = wrap;\n\n\n function _immutable (obj, seen) {\n if (seen.indexOf(obj) === -1) {\n seen.push(Object.freeze(obj));\n\n Object.getOwnPropertyNames(obj).forEach(function (key) {\n var value = obj[key];\n\n if (typeof value === \"object\" && !isNull(value)) {\n _immutable(value, seen);\n }\n });\n }\n\n return obj;\n }\n\n function _keyToPair (key) {\n return [key, this[key]];\n }\n\n function _merge (getKeys) {\n return reduce(slice(arguments, 1), function (result, source) {\n forEach(getKeys(source), function (key) {\n result[key] = source[key];\n });\n\n return result;\n }, {});\n }\n\n var _pairsFrom = _curry(function (getKeys, obj) {\n return getKeys(obj).map(_keyToPair, obj);\n });\n\n function _safeEnumerables (obj) {\n var keys = [];\n\n for (var key in obj) {\n keys.push(key);\n }\n\n return keys;\n }\n\n var _safeKeys = compose(Object.keys, Object);\n\n var _tearFrom = _curry(function (getKeys, obj) {\n return getKeys(obj).reduce(function (result, key) {\n result[0].push(key);\n result[1].push(obj[key]);\n return result;\n }, [[], []]);\n });\n\n var _unsafeKeyListFrom = _curry(function (getKeys, obj) {\n return (isNil(obj) ? Object.keys : getKeys)(obj);\n });\n\n var _valuesFrom = _curry(function (getKeys, obj) {\n return getKeys(obj).map(partial(getIn, obj));\n });\n\n /**\n * Builds a checker function meant to be used with {@link module:lamb.validate|validate}.
\n * Note that the function accepts multiple keyPaths as a means to compare their values. In\n * other words all the received keyPaths will be passed as arguments to the predicate\n * to run the test.
\n * If you want to run the same single property check with multiple properties, you should build\n * multiple checkers and combine them with {@link module:lamb.validate|validate}.\n * @example\n * var user = {\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * username: \"jdoe\",\n * password: \"abc123\",\n * passwordConfirm: \"abc123\"\n * }\n * };\n * var pwdMatch = _.checker(\n * _.is,\n * \"Passwords don't match\",\n * [\"login.password\", \"login.passwordConfirm\"]\n * );\n *\n * pwdMatch(user) // => []\n *\n * var newUser = _.setPathIn(user, \"login.passwordConfirm\", \"avc123\");\n *\n * pwdMatch(newUser) // => [\"Passwords don't match\", [\"login.password\", \"login.passwordConfirm\"]]\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.validate|validate}, {@link module:lamb.validateWith|validateWith}\n * @param {Function} predicate - The predicate to test the object properties\n * @param {String} message - The error message\n * @param {String[]} keyPaths - The array of property names, or {@link module:lamb.getPathIn|paths}, to test.\n * @param {String} [pathSeparator=\".\"]\n * @returns {Array} An error in the form [\"message\", [\"propertyA\", \"propertyB\"]] or an empty array.\n */\n function checker (predicate, message, keyPaths, pathSeparator) {\n return function (obj) {\n var getValues = partial(getPathIn, obj, _, pathSeparator);\n return predicate.apply(obj, keyPaths.map(getValues)) ? [] : [message, keyPaths];\n };\n }\n\n /**\n * Creates an array with all the enumerable properties of the given object.\n * @example Showing the difference with {@link module:lamb.keys|keys}\n * var baseFoo = Object.create({a: 1}, {b: {value: 2}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3},\n * d: {value: 4, enumerable: true}\n * });\n *\n * _.keys(foo) // => [\"d\"]\n * _.enumerables(foo) // => [\"d\", \"a\"]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.keys|keys}\n * @param {Object} obj\n * @returns {String[]}\n */\n var enumerables = _unsafeKeyListFrom(_safeEnumerables);\n\n /**\n * Builds an object from a list of key / value pairs like the one\n * returned by [pairs]{@link module:lamb.pairs} or {@link module:lamb.ownPairs|ownPairs}.
\n * In case of duplicate keys the last key / value pair is used.\n * @example\n * _.fromPairs([[\"a\", 1], [\"b\", 2], [\"c\", 3]]) // => {\"a\": 1, \"b\": 2, \"c\": 3}\n * _.fromPairs([[\"a\", 1], [\"b\", 2], [\"a\", 3]]) // => {\"a\": 3, \"b\": 2}\n * _.fromPairs([[1], [void 0, 2], [null, 3]]) // => {\"1\": undefined, \"undefined\": 2, \"null\": 3}\n *\n * @memberof module:lamb\n * @category Object\n * @param {Array>} pairsList\n * @returns {Object}\n */\n function fromPairs (pairsList) {\n var result = {};\n\n pairsList.forEach(function (pair) {\n result[pair[0]] = pair[1];\n });\n\n return result;\n }\n\n /**\n * Verifies the existence of a property in an object.\n * @example\n * var user1 = {name: \"john\"};\n *\n * _.has(user1, \"name\") // => true\n * _.has(user1, \"surname\") // => false\n * _.has(user1, \"toString\") // => true\n *\n * var user2 = Object.create(null);\n *\n * // not inherited through the prototype chain\n * _.has(user2, \"toString\") // => false\n *\n * @memberof module:lamb\n * @category Object\n * @param {Object} obj\n * @param {String} key\n * @returns {Boolean}\n */\n function has (obj, key) {\n return key in obj;\n }\n\n /**\n * Curried version of {@link module:lamb.has|has}.
\n * Returns a function expecting the object to check against the given key.\n * @example\n * var user1 = {name: \"john\"};\n * var user2 = {};\n * var hasName = _.hasKey(\"name\");\n *\n * hasName(user1) // => true\n * hasName(user2) // => false\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {String} key\n * @returns {Function}\n */\n var hasKey = _curry(has, 2, true);\n\n /**\n * Builds a function expecting an object to check against the given key / value pair.\n * @example\n * var hasTheCorrectAnswer = _.hasKeyValue(\"answer\", 42);\n *\n * hasTheCorrectAnswer({answer: 2}) // false\n * hasTheCorrectAnswer({answer: 42}) // true\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {String} key\n * @param {*} value\n * @returns {Function}\n */\n var hasKeyValue = function (key, value) {\n return compose(partial(is, value), getKey(key));\n };\n\n /**\n * Verifies if an object has the specified property and that the property isn't inherited through\n * the prototype chain.
\n * @example Comparison with has.\n * var user = {name: \"john\"};\n *\n * _.has(user, \"name\") // => true\n * _.has(user, \"surname\") // => false\n * _.has(user, \"toString\") // => true\n *\n * _.hasOwn(user, \"name\") // => true\n * _.hasOwn(user, \"surname\") // => false\n * _.hasOwn(user, \"toString\") // => false\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @param {String} key\n * @returns {Boolean}\n */\n var hasOwn = generic(_objectProto.hasOwnProperty);\n\n /**\n * Curried version of {@link module:lamb.hasOwn|hasOwn}.
\n * Returns a function expecting the object to check against the given key.\n * @example\n * var user = {name: \"john\"};\n * var hasOwnName = _.hasOwnKey(\"name\");\n * var hasOwnToString = _.hasOwnToString(\"toString\");\n *\n * hasOwnName(user) // => true\n * hasOwnToString(user) // => false\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {String} key\n * @returns {Function}\n */\n var hasOwnKey = _curry(hasOwn, 2, true);\n\n /**\n * Makes an object immutable by recursively calling [Object.freeze]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/freeze}\n * on its members.
\n * Any attempt to extend or modify the object can throw a TypeError or fail silently,\n * depending on the environment and the [strict mode]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode} directive.\n * @example\n * var user = _.immutable({\n * name: \"John\",\n * surname: \"Doe\",\n * login: {\n * username: \"jdoe\",\n * password: \"abc123\"\n * },\n * luckyNumbers: [13, 17]\n * });\n *\n * // All of these statements will fail and possibly\n * // throw a TypeError (see the function description)\n * user.name = \"Joe\";\n * delete user.name;\n * user.newProperty = [];\n * user.login.password = \"foo\";\n * user.luckyNumbers.push(-13);\n *\n * @memberof module:lamb\n * @category Object\n * @param {Object} obj\n * @returns {Object}\n */\n function immutable (obj) {\n return _immutable(obj, []);\n }\n\n /**\n * Retrieves the list of the own enumerable properties of an object.
\n * Although [Object.keys]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/keys}\n * is already present in ECMAScript 5, its behaviour changed in the subsequent specifications\n * of the standard as you can read in the link above.
\n * This function shims the ECMAScript 6 version, by forcing a conversion to\n * object for any value but null and undefined.\n * @example Showing the difference with {@link module:lamb.enumerables|enumerables}\n * var baseFoo = Object.create({a: 1}, {b: {value: 2}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3},\n * d: {value: 4, enumerable: true}\n * });\n *\n * _.enumerables(foo) // => [\"d\", \"a\"]\n * _.keys(foo) // => [\"d\"]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.enumerables|enumerables}\n * @param {Object} obj\n * @returns {String[]}\n */\n var keys = _unsafeKeyListFrom(_safeKeys);\n\n /**\n * Builds an object from the two given lists, using the first one as keys and the last one as values.
\n * If the list of keys is longer than the values one, the keys will be created with undefined values.
\n * If more values than keys are supplied, the extra values will be ignored.
\n * See also {@link module:lamb.tear|tear} and {@link module:lamb.tearOwn|tearOwn} for the reverse operation.\n * @example\n * _.make([\"a\", \"b\", \"c\"], [1, 2, 3]) // => {a: 1, b: 2, c: 3}\n * _.make([\"a\", \"b\", \"c\"], [1, 2]) // => {a: 1, b: 2, c: undefined}\n * _.make([\"a\", \"b\"], [1, 2, 3]) // => {a: 1, b: 2}\n * _.make([null, void 0, 2], [1, 2, 3]) // => {\"null\": 1, \"undefined\": 2, \"2\": 3}\n *\n * @memberof module:lamb\n * @category Object\n * @param {String[]} keys\n * @param {Array} values\n * @returns {Object}\n */\n function make (keys, values) {\n var result = {};\n var valuesLen = values.length;\n\n for (var i = 0, len = keys.length; i < len; i++) {\n result[keys[i]] = i < valuesLen ? values[i] : void 0;\n }\n\n return result;\n }\n\n /**\n * Merges the enumerable properties of the provided sources into a new object.
\n * In case of key homonymy each source has precedence over the previous one.
\n * See also {@link module:lamb.mergeOwn|mergeOwn} for merging only own properties of\n * the given sources.\n * @example\n * _.merge({a: 1}, {b: 3, c: 4}, {b: 5}) // => {a: 1, b: 5, c: 4}\n *\n * @example Arrays or array-like objects will be transformed to objects with numbers as keys:\n * _.merge([1, 2], {a: 2}) // => {\"0\": 1, \"1\": 2, a: 2}\n * _.merge(\"foo\", {a: 2}) // => {\"0\": \"f\", \"1\": \"o\", \"2\": \"o\", a: 2}\n *\n * @example Every other value will be treated as an empty object:\n * _.merge({a: 2}, null, NaN) // => {a: 2}\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {...Object} source\n * @returns {Object}\n */\n var merge = partial(_merge, _safeEnumerables);\n\n /**\n * Same as {@link module:lamb.merge|merge}, but only the own properties of the sources are taken into account.\n * @example showing the difference with merge:\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * var bar = {d: 4};\n *\n * _.merge(foo, bar) // => {a: 1, b: 2, c: 3, d: 4}\n * _.mergeOwn(foo, bar) // => {c: 3, d: 4}\n *\n * @example Arrays or array-like objects will be transformed to objects with numbers as keys:\n * _.mergeOwn([1, 2], {a: 2}) // => {\"0\": 1, \"1\": 2, a: 2}\n * _.mergeOwn(\"foo\", {a: 2}) // => {\"0\": \"f\", \"1\": \"o\", \"2\": \"o\", a: 2}\n *\n * @example Every other value will be treated as an empty object:\n * _.mergeOwn({a: 2}, null, NaN) // => {a: 2}\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {...Object} source\n * @returns {Object}\n */\n var mergeOwn = partial(_merge, _safeKeys);\n\n /**\n * Same as {@link module:lamb.pairs|pairs}, but only the own enumerable properties of the object are\n * taken into account.
\n * See also {@link module:lamb.fromPairs|fromPairs} for the reverse operation.\n * @example showing the difference with pairs\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * _.pairs(foo) // => [[\"c\", 3], [\"b\", 2], [\"a\", 1]]\n * _.ownPairs(foo) // => [[\"c\", 3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array>}\n */\n var ownPairs = _pairsFrom(keys);\n\n /**\n * Same as {@link module:lamb.values|values}, but only the own enumerable properties of the object are\n * taken into account.
\n * @example showing the difference with values\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * _.values(foo) // => [3, 2, 1]\n * _.ownValues(foo) // => [3]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array}\n */\n var ownValues = _valuesFrom(keys);\n\n /**\n * Converts an object into an array of key / value pairs of its enumerable properties.
\n * See also {@link module:lamb.ownPairs|ownPairs} for picking only the own enumerable\n * properties and {@link module:lamb.fromPairs|fromPairs} for the reverse operation.\n * @example\n * _.pairs({a: 1, b: 2, c: 3}) // => [[\"a\", 1], [\"b\", 2], [\"c\", 3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array>}\n */\n var pairs = _pairsFrom(enumerables);\n\n /**\n * Returns an object containing only the specified properties of the given object.
\n * Non existent properties will be ignored.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n *\n * _.pick(user, [\"name\", \"age\"]) // => {\"name\": \"john\", \"age\": 30};\n * _.pick(user, [\"name\", \"email\"]) // => {\"name\": \"john\"}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.pickIf|pickIf}\n * @param {Object} source\n * @param {String[]} whitelist\n * @returns {Object}\n */\n function pick (source, whitelist) {\n var result = {};\n\n whitelist.forEach(function (key) {\n if (key in source) {\n result[key] = source[key];\n }\n });\n\n return result;\n }\n\n /**\n * Builds a function expecting an object whose properties will be checked against the given predicate.
\n * The properties satisfying the predicate will be included in the resulting object.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n * var pickIfIsString = _.pickIf(_.isType(\"String\"));\n *\n * pickIfIsString(user) // => {name: \"john\", surname: \"doe\"}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.pick|pick}\n * @param {ObjectIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function pickIf (predicate, predicateContext) {\n return function (source) {\n var result = {};\n\n for (var key in source) {\n if (predicate.call(predicateContext, source[key], key, source)) {\n result[key] = source[key];\n }\n }\n\n return result;\n };\n }\n\n /**\n * Creates a copy of the given object with its enumerable keys renamed as\n * indicated in the provided lookup table.\n * @example\n * var person = {\"firstName\": \"John\", \"lastName\": \"Doe\"};\n * var keysMap = {\"firstName\": \"name\", \"lastName\": \"surname\"};\n *\n * _.rename(person, keysMap) // => {\"name\": \"John\", \"surname\": \"Doe\"}\n *\n * @example It's safe using it to swap keys:\n * var keysMap = {\"firstName\": \"lastName\", \"lastName\": \"firstName\"};\n *\n * _.rename(person, keysMap) // => {\"lastName\": \"John\", \"firstName\": \"Doe\"}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.renameKeys|renameKeys}, {@link module:lamb.renameWith|renameWith}\n * @param {Object} source\n * @param {Object} keysMap\n * @returns {Object}\n */\n function rename (source, keysMap) {\n keysMap = Object(keysMap);\n var result = {};\n var oldKeys = enumerables(source);\n\n for (var prop in keysMap) {\n if (~oldKeys.indexOf(prop)) {\n result[keysMap[prop]] = source[prop];\n }\n }\n\n for (var i = 0, len = oldKeys.length, key; i < len; i++) {\n key = oldKeys[i];\n\n if (!(key in keysMap || key in result)) {\n result[key] = source[key];\n }\n }\n\n return result;\n }\n\n /**\n * A curried version of {@link module:lamb.rename|rename} expecting a\n * keysMap to build a function waiting for the object to act upon.\n * @example\n * var persons = [\n * {\"firstName\": \"John\", \"lastName\": \"Doe\"},\n * {\"first_name\": \"Mario\", \"last_name\": \"Rossi\"},\n * ];\n * var normalizeKeys = _.renameKeys({\n * \"firstName\": \"name\",\n * \"first_name\": \"name\",\n * \"lastName\": \"surname\",\n * \"last_name\": \"surname\"\n * });\n *\n * persons.map(normalizeKeys) // => [{\"name\": \"John\", \"surname\": \"Doe\"}, {\"name\": \"Mario\", \"surname\": \"Rossi\"}]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @see {@link module:lamb.rename|rename}, {@link module:lamb.renameWith|renameWith}\n * @param {Object} keysMap\n * @returns {Function}\n */\n var renameKeys = _curry(rename, 2, true);\n\n /**\n * Uses the provided function as a keysMap generator and returns\n * a function expecting the object whose keys we want to {@link module:lamb.rename|rename}.\n * @example\n * var person = {\"NAME\": \"John\", \"SURNAME\": \"Doe\"};\n * var makeLowerKeysMap = function (source) {\n * var sourceKeys = _.keys(source);\n * return _.make(sourceKeys, sourceKeys.map(_.invoker(\"toLowerCase\")));\n * };\n * var lowerKeysFor = _.renameWith(makeLowerKeysMap);\n *\n * lowerKeysFor(person) // => {\"name\": \"John\", \"surname\": \"doe\"};\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.rename|rename}, {@link module:lamb.renameKeys|renameKeys}\n * @param {Function} fn\n * @returns {Function}\n */\n function renameWith (fn) {\n return function (source) {\n return rename(source, fn(source));\n };\n }\n\n /**\n * Returns a copy of the source object without the specified properties.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n *\n * _.skip(user, [\"name\", \"age\"]) // => {surname: \"doe\"};\n * _.skip(user, [\"name\", \"email\"]) // => {surname: \"doe\", age: 30};\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.skipIf|skipIf}\n * @param {Object} source\n * @param {String[]} blacklist\n * @returns {Object}\n */\n function skip (source, blacklist) {\n var result = {};\n\n for (var key in source) {\n if (blacklist.indexOf(key) === -1) {\n result[key] = source[key];\n }\n }\n\n return result;\n }\n\n /**\n * Builds a function expecting an object whose properties will be checked against the given predicate.
\n * The properties satisfying the predicate will be omitted in the resulting object.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n * var skipIfIstring = _.skipIf(_.isType(\"String\"));\n *\n * skipIfIstring(user) // => {age: 30}\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.skip|skip}\n * @param {ObjectIteratorCallback} predicate\n * @param {Object} [predicateContext]\n * @returns {Function}\n */\n function skipIf (predicate, predicateContext) {\n return pickIf(not(predicate), predicateContext);\n }\n\n /**\n * Tears an object apart by transforming it in an array of two lists: one containing its enumerable keys,\n * the other containing the corresponding values.
\n * Although this \"tearing apart\" may sound as a rather violent process, the source object will be unharmed.
\n * See also {@link module:lamb.tearOwn|tearOwn} for picking only the own enumerable properties and\n * {@link module:lamb.make|make} for the reverse operation.\n * @example\n * _.tear({a: 1, b: 2, c: 3}) // => [[\"a\", \"b\", \"c\"], [1, 2, 3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array, Array<*>>}\n */\n var tear = _tearFrom(enumerables);\n\n /**\n * Same as {@link module:lamb.tear|tear}, but only the own properties of the object are taken into account.
\n * See also {@link module:lamb.make|make} for the reverse operation.\n * @example showing the difference with tear\n * var baseFoo = Object.create({a: 1}, {b: {value: 2, enumerable: true}, z: {value: 5}});\n * var foo = Object.create(baseFoo, {\n * c: {value: 3, enumerable: true}\n * });\n *\n * _.tear(foo) // => [[\"c\", \"b\", \"a\"], [3, 2, 1]]\n * _.tearOwn(foo) // => [[\"c\"], [3]]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array, Array<*>>}\n */\n var tearOwn = _tearFrom(keys);\n\n /**\n * Validates an object with the given list of {@link module:lamb.checker|checker} functions.\n * @example\n * var hasContent = function (s) { return s.trim().length > 0; };\n * var isAdult = function (age) { return age >= 18; };\n * var userCheckers = [\n * _.checker(hasContent, \"Name is required\", [\"name\"]),\n * _.checker(hasContent, \"Surname is required\", [\"surname\"]),\n * _.checker(isAdult, \"Must be at least 18 years old\", [\"age\"])\n * ];\n *\n * var user1 = {name: \"john\", surname: \"doe\", age: 30};\n * var user2 = {name: \"jane\", surname: \"\", age: 15};\n *\n * _.validate(user1, userCheckers) // => []\n * _.validate(user2, userCheckers) // => [[\"Surname is required\", [\"surname\"]], [\"Must be at least 18 years old\", [\"age\"]]]\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.validateWith|validateWith}\n * @see {@link module:lamb.checker|checker}\n * @param {Object} obj\n * @param {Function[]} checkers\n * @returns {Array>} An array of errors in the form returned by {@link module:lamb.checker|checker}, or an empty array.\n */\n function validate (obj, checkers) {\n return checkers.reduce(function (errors, checker) {\n var result = checker(obj);\n result.length && errors.push(result);\n return errors;\n }, []);\n }\n\n /**\n * A curried version of {@link module:lamb.validate|validate} accepting a list of {@link module:lamb.checker|checkers} and\n * returning a function expecting the object to validate.\n * @example\n * var hasContent = function (s) { return s.trim().length > 0; };\n * var isAdult = function (age) { return age >= 18; };\n * var userCheckers = [\n * _.checker(hasContent, \"Name is required\", [\"name\"]),\n * _.checker(hasContent, \"Surname is required\", [\"surname\"]),\n * _.checker(isAdult, \"Must be at least 18 years old\", [\"age\"])\n * ];\n * var validateUser = _.validateWith(userCheckers);\n *\n * var user1 = {name: \"john\", surname: \"doe\", age: 30};\n * var user2 = {name: \"jane\", surname: \"\", age: 15};\n *\n * validateUser(user1) // => []\n * validateUser(user2) // => [[\"Surname is required\", [\"surname\"]], [\"Must be at least 18 years old\", [\"age\"]]]\n *\n * @memberof module:lamb\n * @category Object\n * @see {@link module:lamb.validate|validate}\n * @see {@link module:lamb.checker|checker}\n * @function\n * @param {Function[]} checkers\n * @returns {Function}\n */\n var validateWith = _curry(validate, 2, true);\n\n /**\n * Generates an array with the values of the enumerable properties of the given object.
\n * See also {@link module:lamb.ownValues|ownValues} for picking only the own properties of the object.\n * @example\n * var user = {name: \"john\", surname: \"doe\", age: 30};\n *\n * _.values(user) // => [\"john\", \"doe\", 30]\n *\n * @memberof module:lamb\n * @category Object\n * @function\n * @param {Object} obj\n * @returns {Array}\n */\n var values = _valuesFrom(enumerables);\n\n lamb.checker = checker;\n lamb.enumerables = enumerables;\n lamb.fromPairs = fromPairs;\n lamb.has = has;\n lamb.hasKey = hasKey;\n lamb.hasKeyValue = hasKeyValue;\n lamb.hasOwn = hasOwn;\n lamb.hasOwnKey = hasOwnKey;\n lamb.immutable = immutable;\n lamb.keys = keys;\n lamb.make = make;\n lamb.merge = merge;\n lamb.mergeOwn = mergeOwn;\n lamb.ownPairs = ownPairs;\n lamb.ownValues = ownValues;\n lamb.pairs = pairs;\n lamb.pick = pick;\n lamb.pickIf = pickIf;\n lamb.rename = rename;\n lamb.renameKeys = renameKeys;\n lamb.renameWith = renameWith;\n lamb.skip = skip;\n lamb.skipIf = skipIf;\n lamb.tear = tear;\n lamb.tearOwn = tearOwn;\n lamb.validate = validate;\n lamb.validateWith = validateWith;\n lamb.values = values;\n\n\n function _getPadding (source, char, len) {\n return repeat(char[0] || \" \", Math.ceil(len - source.length));\n }\n\n /**\n * Pads a string to the desired length with the given char starting from the beginning of the string.\n * @example\n * _.padLeft(\"foo\", \"-\", 0) // => \"foo\"\n * _.padLeft(\"foo\", \"-\", -1) // => \"foo\"\n * _.padLeft(\"foo\", \"-\", 5) // => \"--foo\"\n * _.padLeft(\"foo\", \"-\", 3) // => \"foo\"\n * _.padLeft(\"foo\", \"ab\", 7) // => \"aaaafoo\"\n * _.padLeft(\"foo\", \"\", 5) // => \" foo\"\n * _.padLeft(\"\", \"-\", 5) // => \"-----\"\n *\n * @memberof module:lamb\n * @category String\n * @param {String} source\n * @param {String} [char=\" \"] - The padding char. If a string is passed only the first char is used.\n * @param {Number} len\n * @returns {String}\n */\n function padLeft (source, char, len) {\n return _getPadding(source, char, len) + source;\n }\n\n /**\n * Pads a string to the desired length with the given char starting from the end of the string.\n * @example\n * _.padRight(\"foo\", \"-\", 0) // => \"foo\"\n * _.padRight(\"foo\", \"-\", -1) // => \"foo\"\n * _.padRight(\"foo\", \"-\", 5) // => \"foo--\"\n * _.padRight(\"foo\", \"-\", 3) // => \"foo\"\n * _.padRight(\"foo\", \"ab\", 7) // => \"fooaaaa\"\n * _.padRight(\"foo\", \"\", 5) // => \"foo \"\n * _.padRight(\"\", \"-\", 5) // => \"-----\"\n *\n * @memberof module:lamb\n * @category String\n * @param {String} source\n * @param {String} [char=\" \"] - The padding char. If a string is passed only the first char is used.\n * @param {Number} len\n * @returns {String}\n */\n function padRight (source, char, len) {\n return source + _getPadding(source, char, len);\n }\n\n /**\n * Builds a new string by repeating the source string the desired amount of times.
\n * Note that unlike the current ES6 proposal for [String.prototype.repeat]{@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/repeat},\n * this function doesn't throw a RangeError if count is negative, but returns an empty string instead.\n * @example\n * _.repeat(\"Hello\", -1) // => \"\"\n * _.repeat(\"Hello\", 1) // => \"Hello\"\n * _.repeat(\"Hello\", 3) // => \"HelloHelloHello\"\n *\n * @memberof module:lamb\n * @category String\n * @param {String} source\n * @param {Number} count\n * @returns {String}\n */\n function repeat (source, count) {\n var result = \"\";\n\n for (var i = 0; i < count; i++) {\n result += source;\n }\n\n return result;\n }\n\n /**\n * Builds a predicate expecting a string to test against the given regular expression pattern.\n * @example\n * var hasNumbersOnly = _.testWith(/^\\d+$/);\n *\n * hasNumbersOnly(\"123\") // => true\n * hasNumbersOnly(\"123 Kg\") // => false\n *\n * @memberof module:lamb\n * @category String\n * @param {RegExp} pattern\n * @returns {Function}\n */\n function testWith (pattern) {\n return _reProto.test.bind(pattern);\n }\n\n lamb.padLeft = padLeft;\n lamb.padRight = padRight;\n lamb.repeat = repeat;\n lamb.testWith = testWith;\n\n /* istanbul ignore next */\n if (typeof exports === \"object\") {\n module.exports = lamb;\n } else if (typeof define === \"function\" && define.amd) {\n define(function() { return lamb; });\n } else {\n host.lamb = lamb;\n }\n}(this);\n\n/**\n * @callback AccumulatorCallback\n * @global\n * @param {*} previousValue The value returned it the last execution of the accumulator or, in the first iteration, the {@link module:lamb.reduce|initialValue} if supplied.\n * @param {*} currentValue The value being processed in the current iteration.\n * @param {Number} idx - The index of the element being processed.\n * @param {ArrayLike} arrayLike - The list being traversed.\n */\n\n/**\n * The built-in arguments object.\n * @typedef {arguments} arguments\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions/arguments|arguments} in Mozilla documentation.\n */\n\n/**\n * The built-in Array object.\n * @typedef {Array} Array\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array|Array} in Mozilla documentation.\n */\n\n/**\n * Any array-like object.\n * @typedef {Array|String|arguments|?} ArrayLike\n * @global\n */\n\n/**\n * The built-in Boolean object.\n * @typedef {Boolean} Boolean\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean|Boolean} in Mozilla documentation.\n */\n\n/**\n * The built-in Date object.\n * @typedef {Date} Date\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date|Date} in Mozilla documentation.\n */\n\n/**\n * The built-in Function object.\n * @typedef {Function} function\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function|Function} and\n * {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Functions|Functions} in Mozilla documentation.\n */\n\n/**\n * @callback ListIteratorCallback\n * @global\n * @param {*} element - The element being evaluated.\n * @param {Number} idx - The index of the element within the list.\n * @param {ArrayLike} arrayLike - The list being traversed.\n */\n\n/**\n * The built-in Number object.\n * @typedef {Number} Number\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number|Number} in Mozilla documentation.\n */\n\n/**\n * The built-in Object object.\n * @typedef {Object} Object\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object|Object} in Mozilla documentation.\n */\n\n/**\n * @callback ObjectIteratorCallback\n * @global\n * @param {*} value - The value of the current property.\n * @param {String} key - The property name.\n * @param {Object} source - The object being traversed.\n */\n\n/**\n * The built-in RegExp object.\n * @typedef {RegExp} RegExp\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RegExp|RegExp} in Mozilla documentation.\n */\n\n/**\n * Represent a sorting criteria used by {@link module:lamb.sortedInsert|sortedInsert}, {@link module:lamb.sort|sort} and {@link module:lamb.sortWith|sortWith},\n * and it's usually built using {@link module:lamb.sorter|sorter} and {@link module:lamb.sorterDesc|sorterDesc}.\n * @typedef {Sorter} Sorter\n * @global\n * @property {Boolean} isDescending\n * @property {Function} compare\n */\n\n/**\n * The built-in String object.\n * @typedef {String} String\n * @global\n * @see {@link https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String|String} in Mozilla documentation.\n */\n"],"sourceRoot":"/source/"} \ No newline at end of file diff --git a/package.json b/package.json index ae478ed..f556e35 100644 --- a/package.json +++ b/package.json @@ -31,7 +31,7 @@ "coveralls": "gulp coverage && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js && rm -rf ./coverage" }, "tonicExample": "var _ = require('lamb');", - "version": "0.27.0-alpha.3", + "version": "0.27.0", "devDependencies": { "coveralls": "^2.11.9", "gulp": "^3.9.1", diff --git a/src/function.js b/src/function.js index 97ffe49..70ad5c4 100644 --- a/src/function.js +++ b/src/function.js @@ -339,7 +339,7 @@ function invokerOn (target) { /** * Builds a function that allows to map over the received arguments before applying them to the original one. * @example - * var sumArray = _.invoker("reduce", _.add); + * var sumArray = _.reduceWith(_.add); * var sum = _.compose(sumArray, _.list); * * sum(1, 2, 3, 4, 5) // => 15