diff --git a/ajax/libs/underscore-contrib/0.1.4/underscore-contrib.js b/ajax/libs/underscore-contrib/0.1.4/underscore-contrib.js new file mode 100644 index 000000000..52b94f043 --- /dev/null +++ b/ajax/libs/underscore-contrib/0.1.4/underscore-contrib.js @@ -0,0 +1,1645 @@ +// underscore-contrib v0.1.4 +// ========================= + +// > https://github.com/documentcloud/underscore-contrib +// > (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// > underscore-contrib may be freely distributed under the MIT license. + +// Underscore-contrib (underscore.array.builders.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + // Create quick reference variables for speed access to core prototypes. + var slice = Array.prototype.slice, + concat = Array.prototype.concat; + + var existy = function(x) { return x != null; }; + + // Mixing in the array builders + // ---------------------------- + + _.mixin({ + // Concatenates one or more arrays given as arguments. If given objects and + // scalars as arguments `cat` will plop them down in place in the result + // array. If given an `arguments` object, `cat` will treat it like an array + // and concatenate it likewise. + cat: function() { + return _.reduce(arguments, function(acc, elem) { + if (_.isArguments(elem)) { + return concat.call(acc, slice.call(elem)); + } + else { + return concat.call(acc, elem); + } + }, []); + }, + + // 'Constructs' an array by putting an element at its front + cons: function(head, tail) { + return _.cat([head], tail); + }, + + // Takes an array and parititions it some number of times into + // sub-arrays of size n. Allows and optional padding array as + // the third argument to fill in the tail partition when n is + // not sufficient to build paritions of the same size. + partition: function(array, n, pad) { + var p = function(array) { + if (array == null) return []; + + var part = _.take(array, n); + + if (n === _.size(part)) { + return _.cons(part, p(_.drop(array, n))); + } + else { + return pad ? [_.take(_.cat(part, pad), n)] : []; + } + }; + + return p(array); + }, + + // Takes an array and parititions it some number of times into + // sub-arrays of size n. If the array given cannot fill the size + // needs of the final partition then a smaller partition is used + // for the last. + partitionAll: function(array, n, step) { + step = (step != null) ? step : n; + + var p = function(array, n, step) { + if (_.isEmpty(array)) return []; + + return _.cons(_.take(array, n), + p(_.drop(array, step), n, step)); + }; + + return p(array, n, step); + }, + + // Maps a function over an array and concatenates all of the results. + mapcat: function(array, fun) { + return _.cat.apply(null, _.map(array, fun)); + }, + + // Returns an array with some item between each element + // of a given array. + interpose: function(array, inter) { + if (!_.isArray(array)) throw new TypeError; + var sz = _.size(array); + if (sz === 0) return array; + if (sz === 1) return array; + + return slice.call(_.mapcat(array, function(elem) { + return _.cons(elem, [inter]); + }), 0, -1); + }, + + // Weaves two or more arrays together + weave: function(/* args */) { + if (!_.some(arguments)) return []; + + return _.filter(_.flatten(_.zip.apply(null, arguments), true), function(elem) { + return elem != null; + }); + }, + interleave: _.weave, + + // Returns an array of a value repeated a certain number of + // times. + repeat: function(t, elem) { + return _.times(t, function() { return elem; }); + }, + + // Returns an array built from the contents of a given array repeated + // a certain number of times. + cycle: function(t, elems) { + return _.flatten(_.times(t, function() { return elems; }), true); + }, + + // Returns an array with two internal arrays built from + // taking an original array and spliting it at an index. + splitAt: function(array, index) { + return [_.take(array, index), _.drop(array, index)]; + }, + + // Call a function recursively f(f(f(args))) until a second + // given function goes falsey. Expects a seed value to start. + iterateUntil: function(doit, checkit, seed) { + var ret = []; + var result = doit(seed); + + while (checkit(result)) { + ret.push(result); + result = doit(result); + } + + return ret; + }, + + // Takes every nth item from an array, returning an array of + // the results. + takeSkipping: function(array, n) { + var ret = []; + var sz = _.size(array); + + if (n <= 0) return []; + if (n === 1) return array; + + for(var index = 0; index < sz; index += n) { + ret.push(array[index]); + } + + return ret; + }, + + // Returns an array of each intermediate stage of a call to + // a `reduce`-like function. + reductions: function(array, fun, init) { + var ret = []; + var acc = init; + + _.each(array, function(v,k) { + acc = fun(acc, array[k]); + ret.push(acc); + }); + + return ret; + }, + + // Runs its given function on the index of the elements rather than + // the elements themselves, keeping all of the truthy values in the end. + keepIndexed: function(array, pred) { + return _.filter(_.map(_.range(_.size(array)), function(i) { + return pred(i, array[i]); + }), + existy); + } + }); + +})(this); + +// Underscore-contrib (underscore.array.selectors.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + // Create quick reference variables for speed access to core prototypes. + var slice = Array.prototype.slice, + concat = Array.prototype.concat; + + var existy = function(x) { return x != null; }; + var truthy = function(x) { return (x !== false) && existy(x); }; + var isSeq = function(x) { return (_.isArray(x)) || (_.isArguments(x)); }; + + // Mixing in the array selectors + // ---------------------------- + + _.mixin({ + // Returns the second element of an array. Passing **n** will return all but + // the first of the head N values in the array. The **guard** check allows it + // to work with `_.map`. + second: function(array, n, guard) { + if (array == null) return void 0; + return (n != null) && !guard ? slice.call(array, 1, n) : array[1]; + }, + + // A function to get at an index into an array + nth: function(array, index) { + if ((index < 0) || (index > array.length - 1)) throw Error("Attempting to index outside the bounds of the array."); + + return array[index]; + }, + + // Takes all items in an array while a given predicate returns truthy. + takeWhile: function(array, pred) { + if (!isSeq(array)) throw new TypeError; + + var sz = _.size(array); + + for (var index = 0; index < sz; index++) { + if(!truthy(pred(array[index]))) { + break; + } + } + + return _.take(array, index); + }, + + // Drops all items from an array while a given predicate returns truthy. + dropWhile: function(array, pred) { + if (!isSeq(array)) throw new TypeError; + + var sz = _.size(array); + + for (var index = 0; index < sz; index++) { + if(!truthy(pred(array[index]))) + break; + } + + return _.drop(array, index); + }, + + // Returns an array with two internal arrays built from + // taking an original array and spliting it at the index + // where a given function goes falsey. + splitWith: function(array, pred) { + return [_.takeWhile(pred, array), _.dropWhile(pred, array)]; + }, + + // Takes an array and partitions it as the given predicate changes + // truth sense. + partitionBy: function(array, fun){ + if (_.isEmpty(array) || !existy(array)) return []; + + var fst = _.first(array); + var fstVal = fun(fst); + var run = concat.call([fst], _.takeWhile(_.rest(array), function(e) { + return _.isEqual(fstVal, fun(e)); + })); + + return concat.call([run], _.partitionBy(_.drop(array, _.size(run)), fun)); + }, + + // Returns the 'best' value in an array based on the result of a + // given function. + best: function(array, fun) { + return _.reduce(array, function(x, y) { + return fun(x, y) ? x : y; + }); + }, + + // Returns an array of existy results of a function over an source array. + keep: function(array, fun) { + if (!isSeq(array)) throw new TypeError("expected an array as the first argument"); + + return _.filter(_.map(array, function(e) { + return fun(e); + }), existy); + } + }); + +})(this); + +// Underscore-contrib (underscore.collections.walk.js 0.0.1) +// (c) 2013 Patrick Dubroy +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + // An internal object that can be returned from a visitor function to + // prevent a top-down walk from walking subtrees of a node. + var breaker = {}; + + var notTreeError = 'Not a tree: same object found in two different branches'; + + // Walk the tree recursively beginning with `root`, calling `beforeFunc` + // before visiting an objects descendents, and `afterFunc` afterwards. + function walk(root, beforeFunc, afterFunc, context) { + var visited = []; + (function _walk(value, key, parent) { + if (beforeFunc && beforeFunc.call(context, value, key, parent) === breaker) + return; + + if (_.isObject(value) || _.isArray(value)) { + // Keep track of objects that have been visited, and throw an exception + // when trying to visit the same object twice. + if (visited.indexOf(value) >= 0) throw new TypeError(notTreeError); + visited.push(value); + + // Recursively walk this object's descendents. If it's a DOM node, walk + // its DOM children. + _.each(_.isElement(value) ? value.children : value, _walk, context); + } + + if (afterFunc) afterFunc.call(context, value, key, parent); + })(root); + } + + function pluck(obj, propertyName, recursive) { + var results = []; + _.walk.preorder(obj, function(value, key) { + if (key === propertyName) { + results[results.length] = value; + if (!recursive) return breaker; + } + }); + return results; + } + + // Add the `walk` namespace + // ------------------------ + + _.walk = walk; + _.extend(walk, { + // Recursively traverses `obj` in a depth-first fashion, invoking the + // `visitor` function for each object only after traversing its children. + postorder: function(obj, visitor, context) { + walk(obj, null, visitor, context); + }, + + // Recursively traverses `obj` in a depth-first fashion, invoking the + // `visitor` function for each object before traversing its children. + preorder: function(obj, visitor, context) { + walk(obj, visitor, null, context) + }, + + // Produces a new array of values by recursively traversing `obj` and + // mapping each value through the transformation function `visitor`. + // `strategy` is the traversal function to use, e.g. `preorder` or + // `postorder`. + map: function(obj, strategy, visitor, context) { + var results = []; + strategy.call(null, obj, function(value, key, parent) { + results[results.length] = visitor.call(context, value, key, parent); + }); + return results; + }, + + // Return the value of properties named `propertyName` reachable from the + // tree rooted at `obj`. Results are not recursively searched; use + // `pluckRec` for that. + pluck: function(obj, propertyName) { + return pluck(obj, propertyName, false); + }, + + // Version of `pluck` which recursively searches results for nested objects + // with a property named `propertyName`. + pluckRec: function(obj, propertyName) { + return pluck(obj, propertyName, true); + } + }); + _.walk.collect = _.walk.map; // Alias `map` as `collect`. +})(this); + +// Underscore-contrib (underscore.function.arity.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + function enforcesUnary (fn) { + return function mustBeUnary () { + if (arguments.length === 1) { + return fn.apply(this, arguments); + } + else throw new RangeError('Only a single argument may be accepted.'); + + } + } + + // Curry + // ------- + var curry = (function () { + function collectArgs(func, that, argCount, args, newArg, reverse) { + if (reverse == true) { + args.unshift(newArg); + } else { + args.push(newArg); + } + if (args.length == argCount) { + return func.apply(that, args); + } else { + return enforcesUnary(function () { + return collectArgs(func, that, argCount, args.slice(0), arguments[0], reverse); + }); + } + } + return function curry (func, reverse) { + var that = this; + return enforcesUnary(function () { + return collectArgs(func, that, func.length, [], arguments[0], reverse); + }); + }; + }()); + + // Enforce Arity + // -------------------- + var enforce = (function () { + var CACHE = []; + return function enforce (func) { + if (typeof func !== 'function') { + throw new Error('Argument 1 must be a function.'); + } + var funcLength = func.length; + if (CACHE[funcLength] === undefined) { + CACHE[funcLength] = function (enforceFunc) { + return function () { + if (arguments.length !== funcLength) { + throw new RangeError(funcLength + ' arguments must be applied.'); + } + return enforceFunc.apply(this, arguments); + }; + }; + } + return CACHE[funcLength](func); + }; + }()); + + // Mixing in the arity functions + // ----------------------------- + + _.mixin({ + // ### Fixed arguments + + // Fixes the arguments to a function based on the parameter template defined by + // the presence of values and the `_` placeholder. + fix: function(fun) { + var args = _.rest(arguments); + + var f = function() { + var arg = 0; + + for ( var i = 0; i < args.length && arg < arguments.length; i++ ) { + if ( args[i] === _ ) { + args[i] = arguments[arg++]; + } + } + + return fun.apply(null, args); + }; + + f._original = fun; + + return f; + }, + + unary: function (fun) { + return function unary (a) { + return fun.call(this, a); + }; + }, + + binary: function (fun) { + return function binary (a, b) { + return fun.call(this, a, b); + }; + }, + + ternary: function (fun) { + return function ternary (a, b, c) { + return fun.call(this, a, b, c); + }; + }, + + quaternary: function (fun) { + return function quaternary (a, b, c, d) { + return fun.call(this, a, b, c, d); + }; + }, + + // Flexible curry function with strict arity. + // Argument application left to right. + // source: https://github.com/eborden/js-curry + curry: curry, + + // Flexible right to left curry with strict arity. + rCurry: function (func) { + return curry.call(this, func, true); + }, + + + curry2: function (fun) { + return enforcesUnary(function curried (first) { + return enforcesUnary(function (last) { + return fun.call(this, first, last); + }); + }) + }, + + curry3: function (fun) { + return enforcesUnary(function (first) { + return enforcesUnary(function (second) { + return enforcesUnary(function (last) { + return fun.call(this, first, second, last); + }) + }) + }) + }, + + // reverse currying for functions taking two arguments. + rcurry2: function (fun) { + return enforcesUnary(function (last) { + return enforcesUnary(function (first) { + return fun.call(this, first, last); + }) + }) + }, + + rcurry3: function (fun) { + return enforcesUnary(function (last) { + return enforcesUnary(function (second) { + return enforcesUnary(function (first) { + return fun.call(this, first, second, last); + }) + }) + }) + }, + // Dynamic decorator to enforce function arity and defeat varargs. + enforce: enforce + }); + + _.arity = (function () { + var FUNCTIONS = {}; + return function arity (numberOfArgs, fun) { + if (FUNCTIONS[numberOfArgs] == null) { + var parameters = new Array(numberOfArgs); + for (var i = 0; i < numberOfArgs; ++i) { + parameters[i] = "__" + i; + } + var pstr = parameters.join(); + var code = "return function ("+pstr+") { return fun.apply(this, arguments); };"; + FUNCTIONS[numberOfArgs] = new Function(['fun'], code); + } + if (fun == null) { + return function (fun) { return arity(numberOfArgs, fun); }; + } + else return FUNCTIONS[numberOfArgs](fun); + }; + })(); + +})(this); + +// Underscore-contrib (underscore.function.combinators.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + var existy = function(x) { return x != null; }; + var truthy = function(x) { return (x !== false) && existy(x); }; + var __reverse = [].reverse; + var __slice = [].slice; + var __map = [].map; + var curry2 = function (fun) { + return function curried (first, optionalLast) { + if (arguments.length === 1) { + return function (last) { + return fun(first, last); + }; + } + else return fun(first, optionalLast); + }; + }; + + // n.b. depends on underscore.function.arity.js + + // Takes a target function and a mapping function. Returns a function + // that applies the mapper to its arguments before evaluating the body. + function baseMapArgs (fun, mapFun) { + return _.arity(fun.length, function () { + return fun.apply(this, __map.call(arguments, mapFun)); + }); + }; + + // Mixing in the combinator functions + // ---------------------------------- + + _.mixin({ + // Takes a value and returns a function that always returns + // said value. + always: function(value) { + return function() { return value; }; + }, + + // Takes some number of functions, either as an array or variadically + // and returns a function that takes some value as its first argument + // and runs it through a pipeline of the original functions given. + pipeline: function(/*, funs */){ + var funs = (_.isArray(arguments[0])) ? arguments[0] : arguments; + + return function(seed) { + return _.reduce(funs, + function(l,r) { return r(l); }, + seed); + }; + }, + + // Composes a bunch of predicates into a single predicate that + // checks all elements of an array for conformance to all of the + // original predicates. + conjoin: function(/* preds */) { + var preds = arguments; + + return function(array) { + return _.every(array, function(e) { + return _.every(preds, function(p) { + return p(e); + }); + }); + }; + }, + + // Composes a bunch of predicates into a single predicate that + // checks all elements of an array for conformance to any of the + // original predicates. + disjoin: function(/* preds */) { + var preds = arguments; + + return function(array) { + return _.some(array, function(e) { + return _.some(preds, function(p) { + return p(e); + }); + }); + }; + }, + + // Takes a predicate-like and returns a comparator (-1,0,1). + comparator: function(fun) { + return function(x, y) { + if (truthy(fun(x, y))) + return -1; + else if (truthy(fun(y, x))) + return 1; + else + return 0; + }; + }, + + // Returns a function that reverses the sense of a given predicate-like. + complement: function(pred) { + return function() { + return !pred.apply(null, arguments); + }; + }, + + // Takes a function expecting varargs and + // returns a function that takes an array and + // uses its elements as the args to the original + // function + splat: function(fun) { + return function(array) { + return fun.apply(null, array); + }; + }, + + // Takes a function expecting an array and returns + // a function that takes varargs and wraps all + // in an array that is passed to the original function. + unsplat: function(fun) { + var funLength = fun.length; + + if (funLength < 1) { + return fun; + } + else if (funLength === 1) { + return function () { + return fun.call(this, __slice.call(arguments, 0)); + }; + } + else { + return function () { + var numberOfArgs = arguments.length, + namedArgs = __slice.call(arguments, 0, funLength - 1), + numberOfMissingNamedArgs = Math.max(funLength - numberOfArgs - 1, 0), + argPadding = new Array(numberOfMissingNamedArgs), + variadicArgs = __slice.call(arguments, fun.length - 1); + + return fun.apply(this, namedArgs.concat(argPadding).concat([variadicArgs])); + }; + } + }, + + // Same as unsplat, but the rest of the arguments are collected in the + // first parameter, e.g. unsplatl( function (args, callback) { ... ]}) + unsplatl: function(fun) { + var funLength = fun.length; + + if (funLength < 1) { + return fun; + } + else if (funLength === 1) { + return function () { + return fun.call(this, __slice.call(arguments, 0)) + }; + } + else { + return function () { + var numberOfArgs = arguments.length, + namedArgs = __slice.call(arguments, Math.max(numberOfArgs - funLength + 1, 0)), + variadicArgs = __slice.call(arguments, 0, Math.max(numberOfArgs - funLength + 1, 0)); + + return fun.apply(this, [variadicArgs].concat(namedArgs)); + }; + } + }, + + // map the arguments of a function + mapArgs: curry2(baseMapArgs), + + // Returns a function that returns an array of the calls to each + // given function for some arguments. + juxt: function(/* funs */) { + var funs = arguments; + + return function(/* args */) { + var args = arguments; + return _.map(funs, function(f) { + return f.apply(null, args); + }); + }; + }, + + // Returns a function that protects a given function from receiving + // non-existy values. Each subsequent value provided to `fnull` acts + // as the default to the original function should a call receive non-existy + // values in the defaulted arg slots. + fnull: function(fun /*, defaults */) { + var defaults = _.rest(arguments); + + return function(/*args*/) { + var args = _.toArray(arguments); + var sz = _.size(defaults); + + for(var i = 0; i < sz; i++) { + if (!existy(args[i])) + args[i] = defaults[i]; + } + + return fun.apply(null, args); + }; + }, + + // Flips the first two args of a function + flip2: function(fun) { + return function(/* args */) { + var tmp = arguments[0]; + arguments[0] = arguments[1]; + arguments[1] = tmp; + + return fun.apply(null, arguments); + }; + }, + + // Flips an arbitrary number of args of a function + flip: function(fun) { + return function(/* args */) { + var reversed = __reverse.call(arguments); + + return fun.apply(null, reversed); + }; + }, + + k: _.always, + t: _.pipeline + }); + + _.unsplatr = _.unsplat; + + // map the arguments of a function, takes the mapping function + // first so it can be used as a combinator + _.mapArgsWith = curry2(_.flip(baseMapArgs)); + + // Returns function property of object by name, bound to object + _.bound = function(obj, fname) { + var fn = obj[fname]; + if (!_.isFunction(fn)) + throw new TypeError("Expected property to be a function"); + return _.bind(fn, obj); + }; + +})(this); + +// Underscore-contrib (underscore.function.iterators.js 0.0.1) +// (c) 2013 Michael Fogus and DocumentCloud Inc. +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + var HASNTBEENRUN = {}; + + function unary (fun) { + return function (first) { + return fun.call(this, first); + }; + } + + function binary (fun) { + return function (first, second) { + return fun.call(this, first, second); + }; + } + + var undefined = void 0; + + + // Mixing in the iterator functions + // -------------------------------- + + function foldl (iter, binaryFn, seed) { + var state, element; + if (seed !== void 0) { + state = seed; + } + else { + state = iter(); + } + element = iter(); + while (element != null) { + state = binaryFn.call(element, state, element); + element = iter(); + } + return state; + }; + + function unfold (seed, unaryFn) { + var state = HASNTBEENRUN; + return function () { + if (state === HASNTBEENRUN) { + return (state = seed); + } + else if (state != null) { + return (state = unaryFn.call(state, state)); + } + else return state; + }; + }; + + // note that the unfoldWithReturn behaves differently than + // unfold with respect to the first value returned + function unfoldWithReturn (seed, unaryFn) { + var state = seed, + pair, + value; + return function () { + if (state != null) { + pair = unaryFn.call(state, state); + value = pair[1]; + state = value != null + ? pair[0] + : void 0; + return value; + } + else return void 0; + }; + }; + + function accumulate (iter, binaryFn, initial) { + var state = initial; + return function () { + element = iter(); + if (element == null) { + return element; + } + else { + if (state === void 0) { + return (state = element); + } + else return (state = binaryFn.call(element, state, element)); + } + }; + }; + + function accumulateWithReturn (iter, binaryFn, initial) { + var state = initial, + stateAndReturnValue; + return function () { + element = iter(); + if (element == null) { + return element; + } + else { + if (state === void 0) { + return (state = element); + } + else { + stateAndReturnValue = binaryFn.call(element, state, element); + state = stateAndReturnValue[0]; + return stateAndReturnValue[1]; + } + } + }; + }; + + function map (iter, unaryFn) { + return function() { + var element; + element = iter(); + if (element != null) { + return unaryFn.call(element, element); + } else { + return void 0; + } + }; + }; + + function select (iter, unaryPredicateFn) { + return function() { + var element; + element = iter(); + while (element != null) { + if (unaryPredicateFn.call(element, element)) { + return element; + } + element = iter(); + } + return void 0; + }; + }; + + function reject (iter, unaryPredicateFn) { + return select(iter, function (something) { + return !unaryPredicateFn(something); + }); + }; + + function find (iter, unaryPredicateFn) { + return select(iter, unaryPredicateFn)(); + } + + function slice (iter, numberToDrop, numberToTake) { + var count = 0; + while (numberToDrop-- > 0) { + iter(); + } + if (numberToTake != null) { + return function() { + if (++count <= numberToTake) { + return iter(); + } else { + return void 0; + } + }; + } + else return iter; + }; + + function drop (iter, numberToDrop) { + return slice(iter, numberToDrop == null ? 1 : numberToDrop); + } + + function take (iter, numberToTake) { + return slice(iter, 0, numberToTake == null ? 1 : numberToTake); + } + + function List (array) { + var index = 0; + return function() { + return array[index++]; + }; + }; + + function Tree (array) { + var index, myself, state; + index = 0; + state = []; + myself = function() { + var element, tempState; + element = array[index++]; + if (element instanceof Array) { + state.push({ + array: array, + index: index + }); + array = element; + index = 0; + return myself(); + } else if (element === void 0) { + if (state.length > 0) { + tempState = state.pop(), array = tempState.array, index = tempState.index; + return myself(); + } else { + return void 0; + } + } else { + return element; + } + }; + return myself; + }; + + function K (value) { + return function () { + return value; + }; + }; + + function upRange (from, to, by) { + return function () { + var was; + + if (from > to) { + return void 0; + } + else { + was = from; + from = from + by; + return was; + } + } + }; + + function downRange (from, to, by) { + return function () { + var was; + + if (from < to) { + return void 0; + } + else { + was = from; + from = from - by; + return was; + } + }; + }; + + function range (from, to, by) { + if (from == null) { + return upRange(1, Infinity, 1); + } + else if (to == null) { + return upRange(from, Infinity, 1); + } + else if (by == null) { + if (from <= to) { + return upRange(from, to, 1); + } + else return downRange(from, to, 1) + } + else if (by > 0) { + return upRange(from, to, by); + } + else if (by < 0) { + return downRange(from, to, Math.abs(by)) + } + else return k(from); + }; + + var numbers = unary(range); + + _.iterators = { + accumulate: accumulate, + accumulateWithReturn: accumulateWithReturn, + foldl: foldl, + reduce: foldl, + unfold: unfold, + unfoldWithReturn: unfoldWithReturn, + map: map, + select: select, + reject: reject, + filter: select, + find: find, + slice: slice, + drop: drop, + take: take, + List: List, + Tree: Tree, + constant: K, + K: K, + numbers: numbers, + range: range + }; + +})(this); + +// Underscore-contrib (underscore.function.predicates.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + + // Mixing in the predicate functions + // --------------------------------- + + _.mixin({ + // A wrapper around instanceof + isInstanceOf: function(x, t) { return (x instanceof t); }, + + // An associative object is one where its elements are + // accessed via a key or index. (i.e. array and object) + isAssociative: function(x) { return _.isArray(x) || _.isObject(x) || _.isArguments(x); }, + + // An indexed object is anything that allows numerical index for + // accessing its elements (e.g. arrays and strings). NOTE: Underscore + // does not support cross-browser consistent use of strings as array-like + // objects, so be wary in IE 8 when using String objects and IE<8. + // on string literals & objects. + isIndexed: function(x) { return _.isArray(x) || _.isString(x) || _.isArguments(x); }, + + // A seq is something considered a sequential composite type (i.e. arrays and `arguments`). + isSequential: function(x) { return (_.isArray(x)) || (_.isArguments(x)); }, + + // These do what you think that they do + isZero: function(x) { return 0 === x; }, + isEven: function(x) { return _.isFinite(x) && (x & 1) === 0; }, + isOdd: function(x) { return _.isFinite(x) && !_.isEven(x); }, + isPositive: function(x) { return x > 0; }, + isNegative: function(x) { return x < 0; }, + isValidDate: function(x) { return _.isDate(x) && !_.isNaN(x.getTime()); }, + + // A numeric is a variable that contains a numeric value, regardless its type + // It can be a String containing a numeric value, exponential notation, or a Number object + // See here for more discussion: http://stackoverflow.com/questions/18082/validate-numbers-in-javascript-isnumeric/1830844#1830844 + isNumeric: function(n) { + return !isNaN(parseFloat(n)) && isFinite(n); + }, + + // An integer contains an optional minus sign to begin and only the digits 0-9 + // Objects that can be parsed that way are also considered ints, e.g. "123" + // Floats that are mathematically equal to integers are considered integers, e.g. 1.0 + // See here for more discussion: http://stackoverflow.com/questions/1019515/javascript-test-for-an-integer + isInteger: function(i) { + return _.isNumeric(i) && i % 1 === 0; + }, + + // A float is a numbr that is not an integer. + isFloat: function(n) { + return _.isNumeric(n) && !_.isInteger(n); + }, + + // Returns true if its arguments are monotonically + // increaing values; false otherwise. + isIncreasing: function() { + var count = _.size(arguments); + if (count === 1) return true; + if (count === 2) return arguments[0] < arguments[1]; + + for (var i = 1; i < count; i++) { + if (arguments[i-1] >= arguments[i]) { + return false; + } + } + + return true; + }, + + // Returns true if its arguments are monotonically + // decreaing values; false otherwise. + isDecreasing: function() { + var count = _.size(arguments); + if (count === 1) return true; + if (count === 2) return arguments[0] > arguments[1]; + + for (var i = 1; i < count; i++) { + if (arguments[i-1] <= arguments[i]) { + return false; + } + } + + return true; + } + }); + +})(this); + +// Underscore-contrib (underscore.object.builders.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + // Create quick reference variables for speed access to core prototypes. + var slice = Array.prototype.slice, + concat = Array.prototype.concat; + + var existy = function(x) { return x != null; }; + var truthy = function(x) { return (x !== false) && existy(x); }; + var isAssociative = function(x) { return _.isArray(x) || _.isObject(x); }; + var curry2 = function(fun) { + return function(last) { + return function(first) { + return fun(first, last); + }; + }; + }; + + // Mixing in the object builders + // ---------------------------- + + _.mixin({ + // Merges two or more objects starting with the left-most and + // applying the keys right-word + // {any:any}* -> {any:any} + merge: function(/* objs */){ + var dest = _.some(arguments) ? {} : null; + + if (truthy(dest)) { + _.extend.apply(null, concat.call([dest], _.toArray(arguments))); + } + + return dest; + }, + + // Takes an object and another object of strings to strings where the second + // object describes the key renaming to occur in the first object. + renameKeys: function(obj, kobj) { + return _.reduce(kobj, function(o, nu, old) { + if (existy(obj[old])) { + o[nu] = obj[old]; + return o; + } + else + return o; + }, + _.omit.apply(null, concat.call([obj], _.keys(kobj)))); + }, + + // Snapshots an object deeply. Based on the version by + // [Keith Devens](http://keithdevens.com/weblog/archive/2007/Jun/07/javascript.clone) + // until we can find a more efficient and robust way to do it. + snapshot: function(obj) { + if(obj == null || typeof(obj) != 'object') { + return obj; + } + + var temp = new obj.constructor(); + + for(var key in obj) { + temp[key] = _.snapshot(obj[key]); + } + + return temp; + }, + + // Updates the value at any depth in a nested object based on the + // path described by the keys given. The function provided is supplied + // the current value and is expected to return a value for use as the + // new value. If no keys are provided, then the object itself is presented + // to the given function. + updatePath: function(obj, fun, ks) { + if (!isAssociative(obj)) throw new TypeError("Attempted to update a non-associative object."); + if (!existy(ks)) return fun(obj); + + var deepness = _.isArray(ks); + var keys = deepness ? ks : [ks]; + var ret = deepness ? _.snapshot(obj) : _.clone(obj); + var lastKey = _.last(keys); + var target = ret; + + _.each(_.initial(keys), function(key) { + target = target[key]; + }); + + target[lastKey] = fun(target[lastKey]); + return ret; + }, + + // Sets the value at any depth in a nested object based on the + // path described by the keys given. + setPath: function(obj, value, ks) { + if (!existy(ks)) throw new TypeError("Attempted to set a property at a null path."); + + return _.updatePath(obj, function() { return value; }, ks); + }, + + // Returns an object where each element of an array is keyed to + // the number of times that it occurred in said array. + frequencies: curry2(_.countBy)(_.identity) + }); + +})(this); + +// Underscore-contrib (underscore.object.selectors.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + // Create quick reference variables for speed access to core prototypes. + var concat = Array.prototype.concat; + + // Mixing in the object selectors + // ------------------------------ + + _.mixin({ + // Returns a function that will attempt to look up a named field + // in any object that it's given. + accessor: function(field) { + return function(obj) { + return (obj && obj[field]); + }; + }, + + // Given an object, returns a function that will attempt to look up a field + // that it's given. + dictionary: function (obj) { + return function(field) { + return (obj && field && obj[field]); + }; + }, + + // Like `_.pick` except that it takes an array of keys to pick. + selectKeys: function (obj, ks) { + return _.pick.apply(null, concat.call([obj], ks)); + }, + + // Returns the key/value pair for a given property in an object, undefined if not found. + kv: function(obj, key) { + if (_.has(obj, key)) { + return [key, obj[key]]; + } + + return void 0; + }, + + // Gets the value at any depth in a nested object based on the + // path described by the keys given. + getPath: function getPath (obj, ks) { + // If we have reached an undefined property + // then stop executing and return undefined + if (obj === undefined) return void 0; + + // If the path array has no more elements, we've reached + // the intended property and return its value + if (ks.length === 0) return obj; + + // If we still have elements in the path array and the current + // value is null, stop executing and return undefined + if (obj === null) return void 0; + + return getPath(obj[_.first(ks)], _.rest(ks)); + }, + + // Returns a boolean indicating whether there is a property + // at the path described by the keys given + hasPath: function hasPath (obj, ks) { + var numKeys = ks.length; + + if (obj == null && numKeys > 0) return false; + + if (!(ks[0] in obj)) return false; + + if (numKeys === 1) return true; + + return hasPath(obj[_.first(ks)], _.rest(ks)); + } + }); + +})(this); + +// Underscore-contrib (underscore.util.existential.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + + // Mixing in the truthiness + // ------------------------ + + _.mixin({ + exists: function(x) { return x != null; }, + truthy: function(x) { return (x !== false) && _.exists(x); }, + falsey: function(x) { return !_.truthy(x); }, + not: function(b) { return !b; } + }); + +})(this); + +// Underscore-contrib (underscore.function.arity.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Mixing in the operator functions + // ----------------------------- + + _.mixin({ + add: function(x, y) { + return x + y; + }, + sub: function(x, y) { + return x - y; + }, + mul: function(x, y) { + return x * y; + }, + div: function(x, y) { + return x / y; + }, + mod: function(x, y) { + return x % y; + }, + inc: function(x) { + return ++x; + }, + dec: function(x) { + return --x; + }, + neg: function(x) { + return -x; + }, + eq: function(x, y) { + return x == y; + }, + seq: function(x, y) { + return x === y; + }, + neq: function(x, y) { + return x != y; + }, + sneq: function(x, y) { + return x !== y; + }, + not: function(x) { + return !x; + }, + gt: function(x, y) { + return x > y; + }, + lt: function(x, y) { + return x < y; + }, + gte: function(x, y) { + return x >= y; + }, + lte: function(x, y) { + return x <= y; + }, + bitwiseAnd: function(x, y) { + return x & y; + }, + bitwiseOr: function(x, y) { + return x | y; + }, + bitwiseXor: function(x, y) { + return x ^ y; + }, + bitwiseNot: function(x) { + return ~x; + }, + bitwiseLeft: function(x, y) { + return x << y; + }, + bitwiseRight: function(x, y) { + return x >> y; + }, + bitwiseZ: function(x, y) { + return x >>> y; + } + }); +})(this); + +// Underscore-contrib (underscore.util.strings.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + // Mixing in the string utils + // ---------------------------- + + _.mixin({ + // Explodes a string into an array of chars + explode: function(s) { + return s.split(''); + }, + + // Implodes and array of chars into a string + implode: function(a) { + return a.join(''); + } + }); +})(this); + +// Underscore-contrib (underscore.util.trampolines.js 0.0.1) +// (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// Underscore-contrib may be freely distributed under the MIT license. + +(function(root) { + + // Baseline setup + // -------------- + + // Establish the root object, `window` in the browser, or `global` on the server. + var _ = root._ || require('underscore'); + + // Helpers + // ------- + + + // Mixing in the truthiness + // ------------------------ + + _.mixin({ + done: function(value) { + var ret = _(value); + ret.stopTrampoline = true; + return ret; + }, + + trampoline: function(fun /*, args */) { + var result = fun.apply(fun, _.rest(arguments)); + + while (_.isFunction(result)) { + result = result(); + if ((result instanceof _) && (result.stopTrampoline)) break; + } + + return result.value(); + } + }); + +})(this); diff --git a/ajax/libs/underscore-contrib/0.1.4/underscore-contrib.min.js b/ajax/libs/underscore-contrib/0.1.4/underscore-contrib.min.js new file mode 100644 index 000000000..7da65bb8c --- /dev/null +++ b/ajax/libs/underscore-contrib/0.1.4/underscore-contrib.min.js @@ -0,0 +1,8 @@ +// underscore-contrib v0.1.4 +// ========================= + +// > https://github.com/documentcloud/underscore-contrib +// > (c) 2013 Michael Fogus, DocumentCloud and Investigative Reporters & Editors +// > underscore-contrib may be freely distributed under the MIT license. + +(function(n){var r=n._||require("underscore"),t=Array.prototype.slice,e=Array.prototype.concat,u=function(n){return null!=n};r.mixin({cat:function(){return r.reduce(arguments,function(n,u){return r.isArguments(u)?e.call(n,t.call(u)):e.call(n,u)},[])},cons:function(n,t){return r.cat([n],t)},partition:function(n,t,e){var u=function(n){if(null==n)return[];var i=r.take(n,t);return t===r.size(i)?r.cons(i,u(r.drop(n,t))):e?[r.take(r.cat(i,e),t)]:[]};return u(n)},partitionAll:function(n,t,e){e=null!=e?e:t;var u=function(n,t,e){return r.isEmpty(n)?[]:r.cons(r.take(n,t),u(r.drop(n,e),t,e))};return u(n,t,e)},mapcat:function(n,t){return r.cat.apply(null,r.map(n,t))},interpose:function(n,e){if(!r.isArray(n))throw new TypeError;var u=r.size(n);return 0===u?n:1===u?n:t.call(r.mapcat(n,function(n){return r.cons(n,[e])}),0,-1)},weave:function(){return r.some(arguments)?r.filter(r.flatten(r.zip.apply(null,arguments),!0),function(n){return null!=n}):[]},interleave:r.weave,repeat:function(n,t){return r.times(n,function(){return t})},cycle:function(n,t){return r.flatten(r.times(n,function(){return t}),!0)},splitAt:function(n,t){return[r.take(n,t),r.drop(n,t)]},iterateUntil:function(n,r,t){for(var e=[],u=n(t);r(u);)e.push(u),u=n(u);return e},takeSkipping:function(n,t){var e=[],u=r.size(n);if(0>=t)return[];if(1===t)return n;for(var i=0;u>i;i+=t)e.push(n[i]);return e},reductions:function(n,t,e){var u=[],i=e;return r.each(n,function(r,e){i=t(i,n[e]),u.push(i)}),u},keepIndexed:function(n,t){return r.filter(r.map(r.range(r.size(n)),function(r){return t(r,n[r])}),u)}})})(this),function(n){var r=n._||require("underscore"),t=Array.prototype.slice,e=Array.prototype.concat,u=function(n){return null!=n},i=function(n){return n!==!1&&u(n)},o=function(n){return r.isArray(n)||r.isArguments(n)};r.mixin({second:function(n,r,e){return null==n?void 0:null==r||e?n[1]:t.call(n,1,r)},nth:function(n,r){if(0>r||r>n.length-1)throw Error("Attempting to index outside the bounds of the array.");return n[r]},takeWhile:function(n,t){if(!o(n))throw new TypeError;for(var e=r.size(n),u=0;e>u&&i(t(n[u]));u++);return r.take(n,u)},dropWhile:function(n,t){if(!o(n))throw new TypeError;for(var e=r.size(n),u=0;e>u&&i(t(n[u]));u++);return r.drop(n,u)},splitWith:function(n,t){return[r.takeWhile(t,n),r.dropWhile(t,n)]},partitionBy:function(n,t){if(r.isEmpty(n)||!u(n))return[];var i=r.first(n),o=t(i),c=e.call([i],r.takeWhile(r.rest(n),function(n){return r.isEqual(o,t(n))}));return e.call([c],r.partitionBy(r.drop(n,r.size(c)),t))},best:function(n,t){return r.reduce(n,function(n,r){return t(n,r)?n:r})},keep:function(n,t){if(!o(n))throw new TypeError("expected an array as the first argument");return r.filter(r.map(n,function(n){return t(n)}),u)}})}(this),function(n){function r(n,r,t,o){var c=[];(function a(n,f,l){if(!r||r.call(o,n,f,l)!==u){if(e.isObject(n)||e.isArray(n)){if(c.indexOf(n)>=0)throw new TypeError(i);c.push(n),e.each(e.isElement(n)?n.children:n,a,o)}t&&t.call(o,n,f,l)}})(n)}function t(n,r,t){var i=[];return e.walk.preorder(n,function(n,e){return e!==r||(i[i.length]=n,t)?void 0:u}),i}var e=n._||require("underscore"),u={},i="Not a tree: same object found in two different branches";e.walk=r,e.extend(r,{postorder:function(n,t,e){r(n,null,t,e)},preorder:function(n,t,e){r(n,t,null,e)},map:function(n,r,t,e){var u=[];return r.call(null,n,function(n,r,i){u[u.length]=t.call(e,n,r,i)}),u},pluck:function(n,r){return t(n,r,!1)},pluckRec:function(n,r){return t(n,r,!0)}}),e.walk.collect=e.walk.map}(this),function(n){function r(n){return function(){if(1===arguments.length)return n.apply(this,arguments);throw new RangeError("Only a single argument may be accepted.")}}var t=n._||require("underscore"),e=function(){function n(t,e,u,i,o,c){return 1==c?i.unshift(o):i.push(o),i.length==u?t.apply(e,i):r(function(){return n(t,e,u,i.slice(0),arguments[0],c)})}return function(t,e){var u=this;return r(function(){return n(t,u,t.length,[],arguments[0],e)})}}(),u=function(){var n=[];return function(r){if("function"!=typeof r)throw Error("Argument 1 must be a function.");var t=r.length;return void 0===n[t]&&(n[t]=function(n){return function(){if(arguments.length!==t)throw new RangeError(t+" arguments must be applied.");return n.apply(this,arguments)}}),n[t](r)}}();t.mixin({fix:function(n){var r=t.rest(arguments),e=function(){for(var e=0,u=0;r.length>u&&arguments.length>e;u++)r[u]===t&&(r[u]=arguments[e++]);return n.apply(null,r)};return e._original=n,e},unary:function(n){return function(r){return n.call(this,r)}},binary:function(n){return function(r,t){return n.call(this,r,t)}},ternary:function(n){return function(r,t,e){return n.call(this,r,t,e)}},quaternary:function(n){return function(r,t,e,u){return n.call(this,r,t,e,u)}},curry:e,rCurry:function(n){return e.call(this,n,!0)},curry2:function(n){return r(function(t){return r(function(r){return n.call(this,t,r)})})},curry3:function(n){return r(function(t){return r(function(e){return r(function(r){return n.call(this,t,e,r)})})})},rcurry2:function(n){return r(function(t){return r(function(r){return n.call(this,r,t)})})},rcurry3:function(n){return r(function(t){return r(function(e){return r(function(r){return n.call(this,r,e,t)})})})},enforce:u}),t.arity=function(){var n={};return function r(t,e){if(null==n[t]){for(var u=Array(t),i=0;t>i;++i)u[i]="__"+i;var o=u.join(),c="return function ("+o+") { return fun.apply(this, arguments); };";n[t]=Function(["fun"],c)}return null==e?function(n){return r(t,n)}:n[t](e)}}()}(this),function(n){function r(n,r){return t.arity(n.length,function(){return n.apply(this,c.call(arguments,r))})}var t=n._||require("underscore"),e=function(n){return null!=n},u=function(n){return n!==!1&&e(n)},i=[].reverse,o=[].slice,c=[].map,a=function(n){return function(r,t){return 1===arguments.length?function(t){return n(r,t)}:n(r,t)}};t.mixin({always:function(n){return function(){return n}},pipeline:function(){var n=t.isArray(arguments[0])?arguments[0]:arguments;return function(r){return t.reduce(n,function(n,r){return r(n)},r)}},conjoin:function(){var n=arguments;return function(r){return t.every(r,function(r){return t.every(n,function(n){return n(r)})})}},disjoin:function(){var n=arguments;return function(r){return t.some(r,function(r){return t.some(n,function(n){return n(r)})})}},comparator:function(n){return function(r,t){return u(n(r,t))?-1:u(n(t,r))?1:0}},complement:function(n){return function(){return!n.apply(null,arguments)}},splat:function(n){return function(r){return n.apply(null,r)}},unsplat:function(n){var r=n.length;return 1>r?n:1===r?function(){return n.call(this,o.call(arguments,0))}:function(){var t=arguments.length,e=o.call(arguments,0,r-1),u=Math.max(r-t-1,0),i=Array(u),c=o.call(arguments,n.length-1);return n.apply(this,e.concat(i).concat([c]))}},unsplatl:function(n){var r=n.length;return 1>r?n:1===r?function(){return n.call(this,o.call(arguments,0))}:function(){var t=arguments.length,e=o.call(arguments,Math.max(t-r+1,0)),u=o.call(arguments,0,Math.max(t-r+1,0));return n.apply(this,[u].concat(e))}},mapArgs:a(r),juxt:function(){var n=arguments;return function(){var r=arguments;return t.map(n,function(n){return n.apply(null,r)})}},fnull:function(n){var r=t.rest(arguments);return function(){for(var u=t.toArray(arguments),i=t.size(r),o=0;i>o;o++)e(u[o])||(u[o]=r[o]);return n.apply(null,u)}},flip2:function(n){return function(){var r=arguments[0];return arguments[0]=arguments[1],arguments[1]=r,n.apply(null,arguments)}},flip:function(n){return function(){var r=i.call(arguments);return n.apply(null,r)}},k:t.always,t:t.pipeline}),t.unsplatr=t.unsplat,t.mapArgsWith=a(t.flip(r)),t.bound=function(n,r){var e=n[r];if(!t.isFunction(e))throw new TypeError("Expected property to be a function");return t.bind(e,n)}}(this),function(n){function r(n){return function(r){return n.call(this,r)}}function t(n,r,t){var e,u;for(e=t!==void 0?t:n(),u=n();null!=u;)e=r.call(u,e,u),u=n();return e}function e(n,r){var t=x;return function(){return t===x?t=n:null!=t?t=r.call(t,t):t}}function u(n,r){var t,e,u=n;return function(){return null!=u?(t=r.call(u,u),e=t[1],u=null!=e?t[0]:void 0,e):void 0}}function i(n,r,t){var e=t;return function(){return element=n(),null==element?element:e=e===void 0?element:r.call(element,e,element)}}function o(n,r,t){var e,u=t;return function(){return element=n(),null==element?element:u===void 0?u=element:(e=r.call(element,u,element),u=e[0],e[1])}}function c(n,r){return function(){var t;return t=n(),null!=t?r.call(t,t):void 0}}function a(n,r){return function(){var t;for(t=n();null!=t;){if(r.call(t,t))return t;t=n()}return void 0}}function f(n,r){return a(n,function(n){return!r(n)})}function l(n,r){return a(n,r)()}function s(n,r,t){for(var e=0;r-->0;)n();return null!=t?function(){return t>=++e?n():void 0}:n}function p(n,r){return s(n,null==r?1:r)}function m(n,r){return s(n,0,null==r?1:r)}function h(n){var r=0;return function(){return n[r++]}}function v(n){var r,t,e;return r=0,e=[],t=function(){var u,i;return u=n[r++],u instanceof Array?(e.push({array:n,index:r}),n=u,r=0,t()):u===void 0?e.length>0?(i=e.pop(),n=i.array,r=i.index,t()):void 0:u}}function g(n){return function(){return n}}function y(n,r,t){return function(){var e;return n>r?void 0:(e=n,n+=t,e)}}function d(n,r,t){return function(){var e;return r>n?void 0:(e=n,n-=t,e)}}function w(n,r,t){return null==n?y(1,1/0,1):null==r?y(n,1/0,1):null==t?r>=n?y(n,r,1):d(n,r,1):t>0?y(n,r,t):0>t?d(n,r,Math.abs(t)):k(n)}var A=n._||require("underscore"),x={},b=r(w);A.iterators={accumulate:i,accumulateWithReturn:o,foldl:t,reduce:t,unfold:e,unfoldWithReturn:u,map:c,select:a,reject:f,filter:a,find:l,slice:s,drop:p,take:m,List:h,Tree:v,constant:g,K:g,numbers:b,range:w}}(this),function(n){var r=n._||require("underscore");r.mixin({isInstanceOf:function(n,r){return n instanceof r},isAssociative:function(n){return r.isArray(n)||r.isObject(n)||r.isArguments(n)},isIndexed:function(n){return r.isArray(n)||r.isString(n)||r.isArguments(n)},isSequential:function(n){return r.isArray(n)||r.isArguments(n)},isZero:function(n){return 0===n},isEven:function(n){return r.isFinite(n)&&0===(1&n)},isOdd:function(n){return r.isFinite(n)&&!r.isEven(n)},isPositive:function(n){return n>0},isNegative:function(n){return 0>n},isValidDate:function(n){return r.isDate(n)&&!r.isNaN(n.getTime())},isNumeric:function(n){return!isNaN(parseFloat(n))&&isFinite(n)},isInteger:function(n){return r.isNumeric(n)&&0===n%1},isFloat:function(n){return r.isNumeric(n)&&!r.isInteger(n)},isIncreasing:function(){var n=r.size(arguments);if(1===n)return!0;if(2===n)return arguments[0]t;t++)if(arguments[t-1]>=arguments[t])return!1;return!0},isDecreasing:function(){var n=r.size(arguments);if(1===n)return!0;if(2===n)return arguments[0]>arguments[1];for(var t=1;n>t;t++)if(arguments[t-1]<=arguments[t])return!1;return!0}})}(this),function(n){var r=n._||require("underscore"),t=(Array.prototype.slice,Array.prototype.concat),e=function(n){return null!=n},u=function(n){return n!==!1&&e(n)},i=function(n){return r.isArray(n)||r.isObject(n)},o=function(n){return function(r){return function(t){return n(t,r)}}};r.mixin({merge:function(){var n=r.some(arguments)?{}:null;return u(n)&&r.extend.apply(null,t.call([n],r.toArray(arguments))),n},renameKeys:function(n,u){return r.reduce(u,function(r,t,u){return e(n[u])?(r[t]=n[u],r):r},r.omit.apply(null,t.call([n],r.keys(u))))},snapshot:function(n){if(null==n||"object"!=typeof n)return n;var t=new n.constructor;for(var e in n)t[e]=r.snapshot(n[e]);return t},updatePath:function(n,t,u){if(!i(n))throw new TypeError("Attempted to update a non-associative object.");if(!e(u))return t(n);var o=r.isArray(u),c=o?u:[u],a=o?r.snapshot(n):r.clone(n),f=r.last(c),l=a;return r.each(r.initial(c),function(n){l=l[n]}),l[f]=t(l[f]),a},setPath:function(n,t,u){if(!e(u))throw new TypeError("Attempted to set a property at a null path.");return r.updatePath(n,function(){return t},u)},frequencies:o(r.countBy)(r.identity)})}(this),function(n){var r=n._||require("underscore"),t=Array.prototype.concat;r.mixin({accessor:function(n){return function(r){return r&&r[n]}},dictionary:function(n){return function(r){return n&&r&&n[r]}},selectKeys:function(n,e){return r.pick.apply(null,t.call([n],e))},kv:function(n,t){return r.has(n,t)?[t,n[t]]:void 0},getPath:function e(n,t){return void 0===n?void 0:0===t.length?n:null===n?void 0:e(n[r.first(t)],r.rest(t))},hasPath:function u(n,t){var e=t.length;return null==n&&e>0?!1:t[0]in n?1===e?!0:u(n[r.first(t)],r.rest(t)):!1}})}(this),function(n){var r=n._||require("underscore");r.mixin({exists:function(n){return null!=n},truthy:function(n){return n!==!1&&r.exists(n)},falsey:function(n){return!r.truthy(n)},not:function(n){return!n}})}(this),function(n){var r=n._||require("underscore");r.mixin({add:function(n,r){return n+r},sub:function(n,r){return n-r},mul:function(n,r){return n*r},div:function(n,r){return n/r},mod:function(n,r){return n%r},inc:function(n){return++n},dec:function(n){return--n},neg:function(n){return-n},eq:function(n,r){return n==r},seq:function(n,r){return n===r},neq:function(n,r){return n!=r},sneq:function(n,r){return n!==r},not:function(n){return!n},gt:function(n,r){return n>r},lt:function(n,r){return r>n},gte:function(n,r){return n>=r},lte:function(n,r){return r>=n},bitwiseAnd:function(n,r){return n&r},bitwiseOr:function(n,r){return n|r},bitwiseXor:function(n,r){return n^r},bitwiseNot:function(n){return~n},bitwiseLeft:function(n,r){return n<>r},bitwiseZ:function(n,r){return n>>>r}})}(this),function(n){var r=n._||require("underscore");r.mixin({explode:function(n){return n.split("")},implode:function(n){return n.join("")}})}(this),function(n){var r=n._||require("underscore");r.mixin({done:function(n){var t=r(n);return t.stopTrampoline=!0,t},trampoline:function(n){for(var t=n.apply(n,r.rest(arguments));r.isFunction(t)&&(t=t(),!(t instanceof r&&t.stopTrampoline)););return t.value()}})}(this); \ No newline at end of file