lodash-contrib
Version:
The brass buckles on lodash's utility belt
1 lines • 20 kB
JavaScript
!function a(b,c,d){function e(g,h){if(!c[g]){if(!b[g]){var i="function"==typeof require&&require;if(!h&&i)return i(g,!0);if(f)return f(g,!0);var j=new Error("Cannot find module '"+g+"'");throw j.code="MODULE_NOT_FOUND",j}var k=c[g]={exports:{}};b[g][0].call(k.exports,function(a){var c=b[g][1][a];return e(c?c:a)},k,k.exports,a,b,c,d)}return c[g].exports}for(var f="function"==typeof require&&require,g=0;g<d.length;g++)e(d[g]);return e}({1:[function(a,b,c){b.exports=function(a){var b=Array.prototype.slice,c=Array.prototype.concat,d=Array.prototype.sort,e=function(a){return null!=a};a.mixin({cat:function(){return a.reduce(arguments,function(d,e){return a.isArguments(e)?c.call(d,b.call(e)):c.call(d,e)},[])},cons:function(b,c){return a.cat([b],c)},chunkContrib:function(b,c,d){var e=arguments,f=function(b){if(null==b)return[];var g=a.take(b,c);return c===a.size(g)?a.cons(g,f(a.drop(b,c))):3===e.length?(d=a.isArray(d)?d:a.repeatContrib(c,d),[a.take(a.cat(g,d),c)]):[]};return f(b)},chunkAll:function(b,c,d){d=null!=d?d:c;var e=function(b,c,d){return a.isEmpty(b)?[]:a.cons(a.take(b,c),e(a.drop(b,d),c,d))};return e(b,c,d)},mapcat:function(b,c){return a.cat.apply(null,a.map(b,c))},interpose:function(c,d){if(!a.isArray(c))throw new TypeError;var e=a.size(c);return 0===e?c:1===e?c:b.call(a.mapcat(c,function(b){return a.cons(b,[d])}),0,-1)},weave:function(){return a.some(arguments)?1==arguments.length?arguments[0]:a.filter(a.flatten(a.zip.apply(null,arguments),!1),function(a){return null!=a}):[]},interleave:a.weave,repeatContrib:function(b,c){return a.times(b,function(){return c})},cycle:function(b,c){return a.flatten(a.times(b,function(){return c}),!0)},splitAt:function(b,c){return[a.take(b,c),a.drop(b,c)]},iterateUntil:function(a,b,c){for(var d=[],e=a(c);b(e);)d.push(e),e=a(e);return d},takeSkipping:function(b,c){var d=[],e=a.size(b);if(0>=c)return[];if(1===c)return b;for(var f=0;e>f;f+=c)d.push(b[f]);return d},reductions:function(b,c,d){var e=[],f=d;return a.each(b,function(a,d){f=c(f,b[d]),e.push(f)}),e},keepIndexed:function(b,c){return a.filter(a.map(a.range(a.size(b)),function(a){return c(a,b[a])}),e)},reverseOrder:function(a){if("string"==typeof a)throw new TypeError("Strings cannot be reversed by _.reverseOrder");return b.call(a).reverse()},collate:function(b,c,f){if(!a.isArray(b))throw new TypeError("expected an array as the first argument");if(!a.isArray(c))throw new TypeError("expected an array as the second argument");return d.call(b,function(b,d){a.isFunction(f)?(valA=f.call(b),valB=f.call(d)):e(f)?(valA=b[f],valB=d[f]):(valA=b,valB=d);var g=a.indexOf(c,valA),h=a.indexOf(c,valB);return-1===g?1:-1===h?-1:g-h})}})}},{}],2:[function(a,b,c){b.exports=function(a){function b(d,e){return null!=d?f(e)?a(e).map(function(a){return d[a]}).valueOf():b(d,c.call(arguments,1)):void 0}var c=Array.prototype.slice,d=Array.prototype.concat,e=function(a){return null!=a},f=function(b){return a.isArray(b)||a.isArguments(b)};a.mixin({second:function(a,b,d){return null!=a?null==b||d?a[1]:c.call(a,1,b):void 0},third:function(a,b,d){return null!=a?null==b||d?a[2]:c.call(a,2,b):void 0},nth:function(a,b,c){return null==b||c?void 0:a[b]},nths:b,valuesAt:b,binPick:function g(b,d){return null!=b?f(d)?a.nths(b,a.range(d.length).filter(function(a){return d[a]})):g(b,c.call(arguments,1)):void 0},splitWith:function(b,c){return[a.takeWhile(b,c),a.dropWhile(b,c)]},partitionBy:function(b,c){if(a.isEmpty(b)||!e(b))return[];var f=a.first(b),g=c(f),h=d.call([f],a.takeWhile(a.rest(b),function(b){return a.isEqual(g,c(b))}));return d.call([h],a.partitionBy(a.drop(b,a.size(h)),c))},best:function(b,c){return a.reduce(b,function(a,b){return c(a,b)?a:b})},keep:function(b,c){if(!f(b))throw new TypeError("expected an array as the first argument");return a.filter(a.map(b,function(a){return c(a)}),e)}})}},{}],3:[function(a,b,c){b.exports=function(a){function b(b){return a.isElement(b)?b.children:b}function c(b,c,d,e,i,j){var k=[];return function l(b,m,n){if(a.isObject(b)){if(k.indexOf(b)>=0)throw new TypeError(h);k.push(b)}if(d){var o=d.call(i,b,m,n);if(o===g)return g;if(o===f)return}var p,q=c(b);if(a.isObject(q)&&!a.isEmpty(q)){j&&(p=a.isArray(b)?[]:{});var r=a.any(q,function(a,c){var d=l(a,c,b);return d===g?!0:void(p&&(p[c]=d))});if(r)return g}return e?e.call(i,b,m,n,p):void 0}(b)}function d(b,c,d){var e=[];return this.preorder(b,function(b,g){return d||g!=c?void(a.has(b,c)&&(e[e.length]=b[c])):f}),e}function e(c){var d=a.clone(i);return a.bindAll.apply(null,[d].concat(a.keys(d))),d._traversalStrategy=c||b,d}var f={},g={},h="Not a tree: same object found in two different branches",i={find:function(a,b,c){var d;return this.preorder(a,function(a,e,f){return b.call(c,a,e,f)?(d=a,g):void 0},c),d},filter:function(a,b,c,d){var e=[];return null==a?e:(b(a,function(a,b,f){c.call(d,a,b,f)&&e.push(a)},null,this._traversalStrategy),e)},reject:function(a,b,c,d){return this.filter(a,b,function(a,b,e){return!c.call(d,a,b,e)})},map:function(a,b,c,d){var e=[];return b(a,function(a,b,f){e[e.length]=c.call(d,a,b,f)},null,this._traversalStrategy),e},pluck:function(a,b){return d.call(this,a,b,!1)},pluckRec:function(a,b){return d.call(this,a,b,!0)},postorder:function(a,b,d,e){e=e||this._traversalStrategy,c(a,e,null,b,d)},preorder:function(a,b,d,e){e=e||this._traversalStrategy,c(a,e,b,null,d)},reduce:function(a,b,d,e){var f=function(a,c,e,f){return b(f||d,a,c,e)};return c(a,this._traversalStrategy,null,f,e,!0)}};i.collect=i.map,i.detect=i.find,i.select=i.filter,a.extend(e,e()),a.mixin({walk:e})}},{}],4:[function(a,b,c){b.exports=function(a){function b(a){return function(){if(1===arguments.length)return a.apply(this,arguments);throw new RangeError("Only a single argument may be accepted.")}}var c=function(){function a(c,d,e,f,g,h){return h===!0?f.unshift(g):f.push(g),f.length==e?c.apply(d,f):b(function(){return a(c,d,e,f.slice(0),arguments[0],h)})}return function(c,d){var e=this;return b(function(){return a(c,e,c.length,[],arguments[0],d)})}}(),d=function(){var a=[];return function(b){if("function"!=typeof b)throw new Error("Argument 1 must be a function.");var c=b.length;return void 0===a[c]&&(a[c]=function(a){return function(){if(arguments.length!==c)throw new RangeError(c+" arguments must be applied.");return a.apply(this,arguments)}}),a[c](b)}}(),e=function(a){return c.call(this,a,!0)},f=function(a){return b(function(c){return b(function(b){return a.call(this,b,c)})})},g=function(a){return b(function(c){return b(function(d){return b(function(b){return a.call(this,b,d,c)})})})};a.mixin({fix:function(b){var c=a.tail(arguments),d=function(){for(var d=c.slice(),e=0,f=0;f<(d.length||e<arguments.length);f++)d[f]===a&&(d[f]=arguments[e++]);return b.apply(null,d)};return d._original=b,d},unary:function(a){return function(b){return a.call(this,b)}},binary:function(a){return function(b,c){return a.call(this,b,c)}},ternary:function(a){return function(b,c,d){return a.call(this,b,c,d)}},quaternary:function(a){return function(b,c,d,e){return a.call(this,b,c,d,e)}},rCurry:e,curry2:function(a){return b(function(c){return b(function(b){return a.call(this,c,b)})})},curry3:function(a){return b(function(c){return b(function(d){return b(function(b){return a.call(this,c,d,b)})})})},curryRight2:f,rcurry2:f,curryRight3:g,rcurry3:g,enforce:d,arity:function(){var a={};return function b(c,d){if(null==a[c]){for(var e=new Array(c),f=0;c>f;++f)e[f]="__"+f;var g=e.join(),h="return function ("+g+") { return fun.apply(this, arguments); };";a[c]=new Function(["fun"],h)}return null==d?function(a){return b(c,a)}:a[c](d)}}()})}},{}],5:[function(a,b,c){b.exports=function(a){function b(b,c){return a.arity(b.length,function(){return b.apply(this,g.call(arguments,c))})}var c=function(a){return null!=a},d=function(a){return a!==!1&&c(a)},e=[].reverse,f=[].slice,g=[].map,h=function(a){return function(b,c){return 1===arguments.length?function(c){return a(b,c)}:a(b,c)}};a.mixin({always:a.constant,pipeline:function(){var b=a.isArray(arguments[0])?arguments[0]:arguments;return function(c){return a.reduce(b,function(a,b){return b(a)},c)}},composeRight:a.pipeline,conjoin:function(){var b=arguments;return function(c){return a.every(c,function(c){return a.every(b,function(a){return a(c)})})}},disjoin:function(){var b=arguments;return function(c){return a.some(c,function(c){return a.some(b,function(a){return a(c)})})}},comparator:function(a){return function(b,c){return d(a(b,c))?-1:d(a(c,b))?1:0}},complement:function(a){return function(){return!a.apply(this,arguments)}},splat:function(a){return function(b){return a.apply(this,b)}},unsplat:function(a){var b=a.length;return 1>b?a:1===b?function(){return a.call(this,f.call(arguments,0))}:function(){var c=arguments.length,d=f.call(arguments,0,b-1),e=Math.max(b-c-1,0),g=new Array(e),h=f.call(arguments,a.length-1);return a.apply(this,d.concat(g).concat([h]))}},unsplatl:function(a){var b=a.length;return 1>b?a:1===b?function(){return a.call(this,f.call(arguments,0))}:function(){var c=arguments.length,d=f.call(arguments,Math.max(c-b+1,0)),e=f.call(arguments,0,Math.max(c-b+1,0));return a.apply(this,[e].concat(d))}},mapArgs:h(b),juxt:function(){var b=arguments;return function(){var c=arguments;return a.map(b,function(a){return a.apply(this,c)},this)}},fnull:function(b){var d=a.rest(arguments);return function(){for(var e=a.toArray(arguments),f=a.size(d),g=0;f>g;g++)c(e[g])||(e[g]=d[g]);return b.apply(this,e)}},flip2:function(a){return function(){var b=f.call(arguments);return b[0]=arguments[1],b[1]=arguments[0],a.apply(this,b)}},flip:function(a){return function(){var b=e.call(arguments);return a.apply(this,b)}},functionalize:function(b){return function(c){return b.apply(c,a.rest(arguments))}},methodize:function(b){return function(){return b.apply(null,a.cons(this,arguments))}},k:a.always,t:a.pipeline}),a.unsplatr=a.unsplat,a.mapArgsWith=h(a.flip(b)),a.bound=function(b,c){var d=b[c];if(!a.isFunction(d))throw new TypeError("Expected property to be a function");return a.bind(d,b)}}},{}],6:[function(a,b,c){b.exports=function(a){function b(a){return function(b){return a.call(this,b)}}function c(a,b,c){var d,e;for(d=void 0!==c?c:a(),e=a();null!=e;)d=b.call(e,d,e),e=a();return d}function d(a,b){var c=w;return function(){return c===w?c=a:null!=c&&(c=b.call(c,c)),c}}function e(a,b){var c,d,e=a;return function(){return null!=e?(c=b.call(e,e),d=c[1],e=null!=d?c[0]:void 0,d):void 0}}function f(a,b,c){var d=c;return function(){var c=a();return null==c?c:d=void 0===d?c:b.call(c,d,c)}}function g(a,b,c){var d,e,f=c;return function(){return e=a(),null==e?e:void 0===f?f=e:(d=b.call(e,f,e),f=d[0],d[1])}}function h(a,b){return function(){var c;return c=a(),null!=c?b.call(c,c):void 0}}function i(a,b){var c=null;return function(){var d,e;if(null==c){if(e=a(),null==e)return void(c=null);c=b.call(e,e)}for(;null==d;)if(d=c(),null==d){if(e=a(),null==e)return void(c=null);c=b.call(e,e)}return d}}function j(a,b){return function(){var c;for(c=a();null!=c;){if(b.call(c,c))return c;c=a()}}}function l(a,b){return j(a,function(a){return!b(a)})}function m(a,b){return j(a,b)()}function n(a,b,c){for(var d=0;b-- >0;)a();return null!=c?function(){return++d<=c?a():void 0}:a}function o(a,b){return n(a,null==b?1:b)}function p(a,b){return n(a,0,null==b?1:b)}function q(a){var b=0;return function(){return a[b++]}}function r(a){var b,c,d;return b=0,d=[],c=function(){var e,f;return e=a[b++],e instanceof Array?(d.push({array:a,index:b}),a=e,b=0,c()):void 0===e?d.length>0?(f=d.pop(),a=f.array,b=f.index,c()):void 0:e}}function s(a){return function(){return a}}function t(a,b,c){return function(){var d;return a>b?void 0:(d=a,a+=c,d)}}function u(a,b,c){return function(){var d;return b>a?void 0:(d=a,a-=c,d)}}function v(a,b,c){return null==a?t(1,1/0,1):null==b?t(a,1/0,1):null==c?b>=a?t(a,b,1):u(a,b,1):c>0?t(a,b,c):0>c?u(a,b,Math.abs(c)):k(a)}var w={},x=b(v);a.iterators={accumulate:f,accumulateWithReturn:g,foldl:c,reduce:c,unfold:d,unfoldWithReturn:e,map:h,mapcat:i,select:j,reject:l,filter:j,find:m,slice:n,drop:o,take:p,List:q,Tree:r,constant:s,K:s,numbers:x,range:v}}},{}],7:[function(a,b,c){b.exports=function(a){a.mixin({isInstanceOf:function(a,b){return a instanceof b},isAssociative:function(b){return a.isArray(b)||a.isObject(b)||a.isArguments(b)},isIndexed:function(b){return a.isArray(b)||a.isString(b)||a.isArguments(b)},isSequential:function(b){return a.isArray(b)||a.isArguments(b)},isZero:function(a){return 0===a},isEven:function(b){return a.isFinite(b)&&0===(1&b)},isOdd:function(b){return a.isFinite(b)&&!a.isEven(b)},isPositive:function(a){return a>0},isNegative:function(a){return 0>a},isValidDate:function(b){return a.isDate(b)&&!a.isNaN(b.getTime())},isNumeric:function(a){return!isNaN(parseFloat(a))&&isFinite(a)},isInteger:function(b){return a.isNumeric(b)&&b%1===0},isFloat:function(b){return a.isNumeric(b)&&!a.isInteger(b)},isJSON:function(a){try{JSON.parse(a)}catch(b){return!1}return!0},isIncreasing:function(){var b=a.size(arguments);if(1===b)return!0;if(2===b)return arguments[0]<arguments[1];for(var c=1;b>c;c++)if(arguments[c-1]>=arguments[c])return!1;return!0},isDecreasing:function(){var b=a.size(arguments);if(1===b)return!0;if(2===b)return arguments[0]>arguments[1];for(var c=1;b>c;c++)if(arguments[c-1]<=arguments[c])return!1;return!0}})}},{}],8:[function(a,b,c){b.exports=function(a){var b=(Array.prototype.slice,Array.prototype.concat),c=function(a){return null!=a},d=function(b){return a.isArray(b)||a.isObject(b)},e=function(a){return function(b){return function(c){return a(c,b)}}};a.mixin({renameKeys:function(d,e){return a.reduce(e,function(a,b,e){return c(d[e])?(a[b]=d[e],a):a},a.omit.apply(null,b.call([d],a.keys(e))))},snapshot:function(b){if(null==b||"object"!=typeof b)return b;var c=new b.constructor;for(var d in b)b.hasOwnProperty(d)&&(c[d]=a.snapshot(b[d]));return c},updatePath:function(b,e,f,g){if(!d(b))throw new TypeError("Attempted to update a non-associative object.");if(!c(f))return e(b);var h=a.isArray(f),i=h?f:[f],j=h?a.snapshot(b):a.clone(b),k=a.last(i),l=j;return a.each(a.initial(i),function(b){g&&!a.has(l,b)&&(l[b]=a.clone(g)),l=l[b]}),l[k]=e(l[k]),j},setPath:function(b,d,e,f){if(!c(e))throw new TypeError("Attempted to set a property at a null path.");return a.updatePath(b,function(){return d},e,f)},frequencies:e(a.countBy)(a.identity)})}},{}],9:[function(a,b,c){b.exports=function(a){var b=Array.prototype.concat,c=Array.prototype;c.slice;a.mixin({accessor:function(a){return function(b){return b&&b[a]}},dictionary:function(a){return function(b){return a&&b&&a[b]}},selectKeys:function(c,d){return a.pick.apply(null,b.call([c],d))},kv:function(b,c){return a.has(b,c)?[c,b[c]]:void 0},getPath:function d(b,c){if("string"==typeof c&&(c=c.split(".")),void 0!==b){if(0===c.length)return b;if(null!==b)return d(b[a.first(c)],a.rest(c))}},hasPath:function e(b,c){"string"==typeof c&&(c=c.split("."));var d=c.length;return null==b&&d>0?!1:a.contains(["boolean","string","number"],typeof b)?!1:c[0]in b?1===d?!0:e(b[a.first(c)],a.rest(c)):!1},pickWhen:function(b,c){var d={};return a.each(b,function(a,e){c(b[e])&&(d[e]=b[e])}),d},omitWhen:function(b,c){return a.pickWhen(b,function(a){return!c(a)})}})}},{}],10:[function(a,b,c){b.exports=function(a){a.mixin({exists:function(a){return null!=a},truthy:function(b){return b!==!1&&a.exists(b)},falsey:function(b){return!a.truthy(b)},not:function(a){return!a},existsAll:function(){return a.every(arguments,a.exists)},truthyAll:function(){return a.every(arguments,a.truthy)},falseyAll:function(){return a.every(arguments,a.falsey)},firstExisting:function(){for(var b=0;b<arguments.length;b++)if(a.exists(arguments[b]))return arguments[b]}})}},{}],11:[function(a,b,c){b.exports=function(a){function b(b){return function(){return a.reduce(arguments,b)}}function c(a){return function(){for(var b,c=0;c<arguments.length-1;c++)if(b=a(arguments[c],arguments[c+1]),b===!1)return b;return b}}function d(a){return function(){return!a.apply(this,arguments)}}function e(a,b){return a+b}function f(a,b){return a-b}function g(a,b){return a*b}function h(a,b){return a/b}function i(a,b){return a%b}function j(a){return++a}function k(a){return--a}function l(a){return-a}function m(a,b){return a&b}function n(a,b){return a|b}function o(a,b){return a^b}function p(a,b){return a<<b}function q(a,b){return a>>b}function r(a,b){return a>>>b}function s(a){return~a}function t(a,b){return a==b}function u(a,b){return a===b}function v(a){return!a}function w(a,b){return a>b}function x(a,b){return b>a}function y(a,b){return a>=b}function z(a,b){return b>=a}a.mixin({addContrib:b(e),sub:b(f),mul:b(g),div:b(h),mod:i,inc:j,dec:k,neg:l,eqContrib:c(t),seq:c(u),neq:d(c(t)),sneq:d(c(u)),not:v,gtContrib:c(w),ltContrib:c(x),gteContrib:c(y),lteContrib:c(z),bitwiseAnd:b(m),bitwiseOr:b(n),bitwiseXor:b(o),bitwiseNot:s,bitwiseLeft:b(p),bitwiseRight:b(q),bitwiseZ:b(r)})}},{}],12:[function(a,b,c){b.exports=function(a){var b={boundary:/(\b.)/g,bracket:/(?:([^\[]+))|(?:\[(.*?)\])/g,capitalLetters:/([A-Z])/g,dot:/\./g,htmlTags:/<\/?[^<>]*>/gi,lowerThenUpper:/([a-z])([A-Z])/g,nonCamelCase:/[-_\s](\w)/g,plus:/\+/g,regex:/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g,space:/ /g,underscore:/_/g,upperThenLower:/\b([A-Z]+)([A-Z])([a-z])/g},c=function(a){return decodeURIComponent(a.replace(b.plus,"%20"))},d=function(b,c,e){return a.isUndefined(e)&&(e=!0),a.isArray(c)?a.map(c,function(a,c){return d(e?c:b+"[]",a,!1)}).join("&"):a.isObject(c)?a.map(c,function(a,c){return d(e?c:b+"["+c+"]",a,!1)}).join("&"):encodeURIComponent(b)+"="+encodeURIComponent(c)};a.mixin({explode:function(a){return a.split("")},fromQuery:function(d){var e,f,g,h,i,j=d.split("&"),k={};return a.each(j,function(d){for(d=d.split("="),e=c(d[0]),g=e,i=k,b.bracket.lastIndex=0;null!==(f=b.bracket.exec(e));)a.isUndefined(f[1])?(h=f[2],i[g]=i[g]||(h?{}:[]),i=i[g]):h=f[1],g=h||a.size(i);i[g]=c(d[1])}),k},implode:function(a){return a.join("")},toDash:function(a){return a=a.replace(b.capitalLetters,function(a){return"-"+a.toLowerCase()}),"-"==a.charAt(0)?a.substr(1):a},toQuery:function(a){return d("",a)},strContains:function(a,b){if("string"!=typeof a)throw new TypeError("First argument to strContains must be a string");return-1!=a.indexOf(b)},titleCase:function(a){return a.replace(b.boundary,function(a){return a.toUpperCase()})},slugify:function(a){return a.replace(b.lowerThenUpper,"$1-$2").replace(b.space,"-").replace(b.dot,"-").toLowerCase()},humanize:function(c){return a.capitalize(c.replace(b.underscore," ").replace(b.lowerThenUpper,"$1 $2").replace(b.upperThenLower,"$1 $2$3"))},stripTags:function(a){var c=a.replace(b.htmlTags,"");return c}})}},{}],13:[function(a,b,c){b.exports=function(a){a.mixin({done:function(b){var c=a(b);return c.stopTrampoline=!0,c},trampoline:function(b){for(var c=b.apply(b,a.rest(arguments));a.isFunction(c)&&(c=c(),!(c instanceof a&&c.stopTrampoline)););return c.value()}})}},{}],14:[function(a,b,c){a("../common-js/_.array.builders.js")(_),a("../common-js/_.array.selectors.js")(_),a("../common-js/_.collections.walk.js")(_),a("../common-js/_.function.arity.js")(_),a("../common-js/_.function.combinators.js")(_),a("../common-js/_.function.iterators.js")(_),a("../common-js/_.function.predicates.js")(_),a("../common-js/_.object.builders.js")(_),a("../common-js/_.object.selectors.js")(_),a("../common-js/_.util.existential.js")(_),a("../common-js/_.util.operators.js")(_),a("../common-js/_.util.strings.js")(_),a("../common-js/_.util.trampolines.js")(_)},{"../common-js/_.array.builders.js":1,"../common-js/_.array.selectors.js":2,"../common-js/_.collections.walk.js":3,"../common-js/_.function.arity.js":4,"../common-js/_.function.combinators.js":5,"../common-js/_.function.iterators.js":6,"../common-js/_.function.predicates.js":7,"../common-js/_.object.builders.js":8,"../common-js/_.object.selectors.js":9,"../common-js/_.util.existential.js":10,"../common-js/_.util.operators.js":11,"../common-js/_.util.strings.js":12,"../common-js/_.util.trampolines.js":13}]},{},[14]);