[
  {
    "path": ".gitignore",
    "content": ".DS_Store\n"
  },
  {
    "path": "Gruntfile.coffee",
    "content": "module.exports = (grunt) ->\n\n  grunt.initConfig \n    pkg: grunt.file.readJSON('package.json'),\n    uglify:\n      options:\n        banner: '/*! http://github.com/raganwald/<%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today(\"yyyy-mm-dd\") %> (c) 2012-2013 Reg Braithwaite MIT Licensed */\\n'\n      build:\n        src: 'lib/<%= pkg.name %>.js',\n        dest: 'lib/<%= pkg.name %>.min.js'\n\n  grunt.loadNpmTasks('grunt-contrib-uglify')\n\n  grunt.registerTask('default', ['uglify'])"
  },
  {
    "path": "README.md",
    "content": "# `allong.es`\n\nThe `allong.es` library is a collection of functions designed to facilitate writing JavaScript and/or CoffeeScript with functions as first-class values. The emphasis in `allong.es` is on composing and decomposing functions using combinators and decorators. `allong.es` is designed to complement libraries like [Underscore](http://underscorejs.org), not compete with them.\n\n## Currying and Partial Application\n\nAt the heart of `allong.es` are the functions that curry and partially apply other functions. The two most important to understand are `call` and `apply`. They work very much like the `.call` and `.apply` methods that every JavaScript function implements:\n\n```javascript\nfunction greet (how, whom) {\n  return '' + how + ', ' + whom + '!';\n};\n  \ncall(greet, 'Hello', 'Tom')\n  //=> 'Hello, Tom!'\n  \napply(greet, ['Hello', 'Tom'])\n  //=> 'Hello, Tom!'\n```\n\nTheir \"special sauce\" is that they automatically *curry* the supplied function, so if you provide fewer or no arguments, you get back a partially applied or curried function:\n\n```javascript\ncall(greet)('Hello')('Tom')\n  //=> 'Hello, Tom!'\n  \ncall(greet, 'Hello')('Tom')\n  //=> 'Hello, Tom!'\n  \napply(greet, [])('Hello')('Tom')\n  //=> 'Hello, Tom!'\n  \napply(greet, ['Hello'])('Tom')\n  //=> 'Hello, Tom!'\n```\n\n### immediate application\n\nIf you don't want the currying/partial application behaviour, there is an immediate application version named (appropriately), `callNow` (and also another named `applyNow`, not shown):\n\n```javascript\ncallNow(greet, 'Hello', 'Tom')\n  //=> 'Hello, Tom!'\n  \ncallNow(greet, 'Hello')\n  //=> 'Hello, undefined!'\n```\n\n### variations on the order of applying the arguments\n\n`callRight` applies any arguments supplied to the right. If you supply all the arguments, it's the same as `call`, but if you supply fewer arguments, you get a right partial application:\n\n```javascript\ncallRight(greet, 'Hello', 'Tom')\n  //=> 'Hello, Tom!'\n  \ncallRight(greet, 'Hello')('Tom')\n  //=> 'Tom, Hello!'\n```\n\n`callFlipped` applies the arguments backwards, even when curried:\n\n```javascript\ncallFlipped(greet, 'Hello', 'Tom')\n  //=> 'Tom, Hello!'\n  \ncallFlipped(greet, 'Hello')('Tom')\n  //=> 'Tom, Hello!'\n  \ncallFlipped(greet)('Hello')('Tom')\n  //=> 'Tom, Hello!'\n```\n\n### more partial application\n\n`callLeft` is actually synonymous with `call`: It applies arguments given to the left. We've seen `callRight` above. Both are *variadic*: You can supply as many arguments as you want.\n\n`callFirst` and `callLast` are just like `callLeft` and `callRight`, but they are *binary* functions: They accept a function and exactly one argument. This is sometimes useful when combining functions together.\n\n`callFirst` and `callLast` both have \"flipped and curried\" versions (`callFirstWith` and `callLastWith`). `callLastWith` is especially useful for working with functions written in \"collection - operation\" style. Here we take advantage of the fact that they are \"automatically curried\" to implement the popular `pluck` function.\n\n### currying\n\n`allong.es` does support the `curry` function, it is implemented as the unary form of `call`:\n\n```javascript\nvar curry = unary(call);\n```\n\n### with\n\n`splat` was present in earlier versions of `allong.es` but has been deprecated as being too cryptic. Instead, there is a general naming convention that works as follows. Many binary functions such as `map` and `filter` are historically written to take a noun or collection as the first argument and a verb as the second.\n\nHowever, reversing and currying these functions is super-useful as it makes composeable functions out of them. That's why `callFlipped` is so important. But to save you the trouble of writing `callFlipped map` everywhere, many such functions in `allong.es` have a clipped version pre-defined and named with the suffix `With`:\n\n```\nmap(list, function)       <=> mapWith(function, list)\nfilter(list, function)    <=> filterWith(function, list)\nget(object, propertyName) <=> getWith(propertyName, object)\npluck(list, propertyName) <=> pluckWith(propertyName, list)\n```\n\nSo you \"map\" a list, but \"mapWith\" a function. And of course, they are all curried. For example:\n\n```\nmap(list)(function)       <=> mapWith(function)(list)\ndeepMap(list)(function)   <=> deepMapWith(function)(list)\nfilter(list)(function)    <=> filterWith(function)(list)\nget(object)(propertyName) <=> getWith(propertyName)(object)\npluck(list)(propertyName) <=> pluckWith(propertyName)(list)\n```\n\nThus if you have a collection such as:\n\n```javascript\nvar users = [\n  { name: 'Huey' },\n  { name: 'Dewey' },\n  { name: 'Louie' }\n]\n```\n\nYou can get the names with either:\n\n```javascript\npluck(users, 'name')\n  //=> ['Huey', 'Dewey', 'Louie']\n```\n\nOr:\n\n```javascript\npluckWith('name', users)\n  //=> ['Huey', 'Dewey', 'Louie']\n```\n\nThe latter is interesting because `pluck` and `pluckWith` are both automatically curried (like almost everything that isn't named \"now\"). Thus, we could also write:\n\n```javascript\nvar namesOf = pluckWith('name');\n\n// ...\nnamesOf(users)\n  //=> ['Huey', 'Dewey', 'Louie']\n```\n\n## Arity Function Decorators\n\n### variadic\n\nMakes a function into a variadic (accepts any number of arguments). The last named parameter will be given an array of arguments.\n\n```javascript\nvar variadic = require('allong.es').allong.es.variadic;\n\nvar fn = variadic(function (a) { return a })\n\nfn()\n  //=> []\nfn(1, 2, 3)\n  //=> [1,2,3]\n\nfn = variadic(function (a,b) { return { a: a, b: b } })\n\nfn()\n  //=> { a: undefined, b: [] }\nfn(1)\n  //=> { a: 1, b: [] }\nfn(1,2,3)\n  //=> { a: 1, b: [2, 3] }\n```\n\n### variadic, part ii\n\nWhen given just the function, `variadic` returns a function with an arity of zero. This is consistent with JavaScript programming practice. There are times when you wish to report an arity, meaning that you want the returned function to have its `length` getibute set.\n\nYou do this by prefacing the function argument with a length:\n\n```javascript\nfn = variadic(function (a,b) { return { a: a, b: b } });\n\nfn.length\n  //=> 0\n  \nfn2 = variadic(1, function (a,b) { return { a: a, b: b } }); \n\nfn2.length\n  //=> 1\n```\n\n### unary, binary, and ternary\n\nSometimes, you have a function that takes multiple arguments, but you only want it to accept one, or two, or maybe three arguments and ignore the rest. For example, `parseInt` takes a radix as an optional second parameter. And that is havoc if you try to use it with `Array.map`:\n\n```javascript\n['1', '2', '3', '4', '5'].map(parseInt)\n  //=> [ 1,\n  //     NaN,\n  //     NaN,\n  //     NaN,\n  //     NaN ]\n```\n\nUse `unary(parseInt)` to solve the problem:\n\n```javascript\n['1', '2', '3', '4', '5'].map(unary(parseInt))\n  //=> [ 1, 2, 3, 4, 5 ]\n```\n\n`binary` has similar uses when working with `Array.reduce` and its habit of passing three parameters to your supplied function.\n\n## Miscellaneous Combinators\n\n### bound\n\n```javascript\nvar bound = require('allong.es').allong.es.bound;\n    \nbound(fn, args...)(obj)\n  //=> fn.bind(obj, args...)\n```\n\n### getWith\n\n```javascript\nvar getWith = require('allong.es').allong.es.getWith;\n    \narray.map(getWith('property'))\n  //=> array.map(function (element) {\n  //               return element['property']\n  //             })\n```\n\n## Functional Composition\n\n```javascript\nvar compose = require('allong.es').allong.es.compose,\n    sequence = require('allong.es').allong.es.sequence;\n    \ncompose(a, b, c)\n  //=> function (x) {\n  //     return a(b(c(x)))\n  //   }\n \nsequence(a, b, c)\n  //=> function (x) {\n  //     return c(b(a(x)))\n  //   }\n```\n\n## List Combinators\n\n### mapWith and deepMapWith\n\n```javascript\nvar mapWith = require('allong.es').allong.es.mapWith,\n    deepMapWith = require('allong.es').allong.es.deepMapWith;\n    \nvar squareList = mapWith(function (x) { return x * x })\n\nsquareList([1, 2, 3, 4])\n  //=> [1, 4, 9, 16]\n  \nvar squareTree = deepMapWith(function (x) { return x * x })\n\nsquareTree([1, 2, [3, 4]])\n  //=> [1, 4, [9, 16]]\n```\n\n## Function/Method Decorators\n\n### maybe\n\n```javascript\nvar maybe = require('allong.es').allong.es.maybe;\n    \nvar safeFirst = maybe(function (arr) { return arr[0] })\n\nsafeFirst([1, 2, 3])\n  //=> 1\nsafeFirst(null)\n  //=> null\n```\n\n### tap\n\n```javascript\nvar tap = require('allong.es').allong.es.tap;\n    \ntap([1, 2, 3, 4, 5], send('pop'))\n  //=> [1, 2, 3, 4]\n```\n\n### fluent\n\n```javascript\nvar fluent = require('allong.es').allong.es.fluent;\n    \nRole = function () {}\n\nRole.prototype.set = fluent( function (property, name) { \n  this[property] = name \n})\n\nvar doomed = new Role()\n  .set('name', \"Fredo\")\n  .set('relationship', 'brother')\n  .set('parts', ['I', 'II'])\n```\n\n### once\n\n```javascript\nvar once = require('allong.es').allong.es.once;\n    \nvar message = once( function () { console.log(\"Hello, it's me\") })\n\nmessage()\n  //=> \"Hello, it's me\"\nmessage()\n  //=>\nmessage()\n  //=>\nmessage()\n  //=>\n```\n\n## Decorating Classes/Constructors\n\n```javascript\nvar mixin = require('allong.es').allong.es.mixin,\n    classDecorator = require('allong.es').allong.es.classDecorator;\n    \nfunction Todo (name) {\n  var self = this instanceof Todo\n             ? this\n             : new Todo();\n  self.name = name || 'Untitled';\n  self.done = false;\n};\n\nTodo.prototype.do = fluent( function () {\n  this.done = true;\n});\n\nTodo.prototype.undo = fluent( function () {\n  this.done = false;\n});\n\nvar AddLocation = mixin({\n      setLocation: fluent( function (location) {\n        this.location = location;\n      }),\n      getLocation: function () { return this.location; }\n    });\n\nAddLocation.call(Todo.prototype);\n// Or use AddLocation(Todo.prototype)\n\nnew Todo(\"Vacuum\").setLocation('Home');\n  //=> { name: 'Vacuum',\n  //     done: false,\n  //     location: 'Home' }\n\nvar AndColourCoded = classDecorator({\n  setColourRGB: fluent( function (r, g, b) {\n    this.colourCode = { r: r, g: g, b: b };\n  }),\n  getColourRGB: function () {\n    return this.colourCode;\n  }\n});\n\nvar ColourTodo = AndColourCoded(Todo);\n\nnew ColourTodo('Use More Decorators').setColourRGB(0, 255, 0);\n  //=> { name: 'Use More Decorators',\n  //     done: false,\n  //     colourCode: { r: 0, g: 255, b: 0 } }\n```\n\nNote: `classDecorator` works with JavaScript constructors that have a default implementation (they work properly with no arguments), and are new-agnostic (they can be called with new or as a normal function). `Todo` above has both properties.\n\n## Functional Iterators\n\nFunctional iterators are stateful functions that \"iterate over\" the values in some ordered data set. You call the iterator repeatedly to obtain the values, and it will either never stop returning values (an infinite data set) or return `undefined` when there are no more values to return.\n\nThe functional iterators utilities are all namespaced:\n\n```javascript\nvar iterators = require('allong.es').allong.es.iterators;\n```\n\n### FlatArrayIterator and RecursiveArrayIterator\n\nMaking functional iterators from arrays:\n\n```javascript\nvar FlatArrayIterator = iterators.FlatArrayIterator,\n    RecursiveArrayIterator = iterators.RecursiveArrayIterator;\n    \nvar i = FlatArrayIterator([1, 2, 3, 4, 5]);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n    \nvar i = FlatArrayIterator([1, [2, 3, 4], 5]);\n\ni();\n  //=> 1\ni();\n  //=> [2, 3, 4]\ni();\n  //=> 5\ni();\n  //=> undefined\n    \nvar i = RecursiveArrayIterator([1, [2, 3, 4], 5]);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n```\n\n### range and numbers\n\n```javascript\nvar range = iterators.range,\n    numbers = iterators.numbers;\n\nvar i = range(1, 5);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n\nvar i = range(1, 5, 2);\n\ni();\n  //=> 1\ni();\n  //=> 3\ni();\n  //=> 5\ni();\n  //=> undefined\n\nvar i = range(5, 1);\n\ni();\n  //=> 5\ni();\n  //=> 4\ni();\n  //=> 3\ni();\n  //=> 2\ni();\n  //=> 1\ni();\n  //=> undefined\n\nvar i = range(1);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n\nvar i = numbers();\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n\nvar i = numbers(0);\n\ni();\n  //=> 0\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n```\n\n### unfold and unfoldWithReturn\n\nUnfold makes an iterator out of a seed by successively applying a function to the seed value. Here's an example duplicating the \"numbers\" feature:\n\n```javascript\nvar unfold = iterators.unfold,\n    unfoldWithReturn = iterators.unfoldWithReturn;\n    \nvar i = unfold(1, function (n) { return n + 1; });\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n    \nvar i = unfoldWithReturn(1, function (n) { \n  return [n + 1, n + n]; \n});\n\ni();\n  //=> 2\ni();\n  //=> 4\ni();\n  //=> 6\n// ...\n```\n\nA richer example of `unfoldWithReturn`:\n\n```javaascript\nvar cards = ['A', 2, 3, 4, 5, 6, 7, 8, 9, '10', 'J', 'Q', 'K'];\n\nfunction pickCard (deck) {\n  var position;\n  \n  if (deck.length === 0) {\n    return [[], void 0];\n  }\n  else {\n    position = Math.floor(Math.random() * deck.length);\n    return [\n      deck.slice(0, position).concat(deck.slice(position + 1)),\n      deck[position]\n    ];\n  }\n};\n\nvar i = unfoldWithReturn(cards, pickCard);\n\ni();\n  //=> 5\ni();\n  //=> 4\ni();\n  //=> 2\ni();\n  //=> J\n  \n// ...\n```\n\n### map\n\nStateless mapping of an iterator to another iterator:\n\n```javascript\nvar map = iterators.map;\n    \nvar squares = map(numbers, function (n) { return n * n; });\n\nsquares();\n  //=> 1\nsquares();\n  //=> 4\nsquares();\n  //=> 9\n// ...\n```\n\n### accumulate\n\nAccumulating an iterator to another iterator, a/k/a stateful mapping, with an optional seed:\n\n```javascript\nvar accumulate = iterators.accumulate;\n    \nvar runningTotal = accumulate(numbers, function (accumulation, n) { \n      return accumulation + n; \n    });\n\nrunningTotal();\n  //=> 1\nrunningTotal();\n  //=> 3\nrunningTotal();\n  //=> 6\nrunningTotal();\n  //=> 10\nrunningTotal();\n  //=> 15\n// ...\n\nvar runningTotal = accumulate(numbers, function (accumulation, n) { \n      return accumulation + n; \n    }, 5);\n\nrunningTotal();\n  //=> 6\nrunningTotal();\n  //=> 8\nrunningTotal();\n  //=> 11\nrunningTotal();\n  //=> 15\nrunningTotal();\n  //=> 20\n// ...\n```\n\n### accumulateWithReturn\n\nThis code transforms filters duplicates out of an iterator of numbers by turning them into \"false.\" It consumes space proportional to the time it runs and the size of the set of possible numbers in its iterator.\n\n```javascript\nvar accumulateWithReturn = iterators.accumulateWithReturn;\n    \nvar randomNumbers = function () {\n  return Math.floor(Math.random() * 10);\n};\n\nrandomNumbers();\n  //=> 7\nrandomNumbers();\n  //=> 0\nrandomNumbers();\n  //=> 1\nrandomNumbers();\n  //=> 1\nrandomNumbers();\n  //=> 6\n// ...\n\nvar uniques = accumulateWithReturn(randomNumbers, function (alreadySeen, number) {\n  var key = number.toString();\n  \n  if (alreadySeen[key]) {\n    return [alreadySeen, false];\n  }\n  else {\n    alreadySeen[key] = true;\n    return [alreadySeen, number];\n  }\n}, {});\n\nuniques();\n  //=> 7\nuniques();\n  //=> 5\nuniques();\n  //=> 1\nuniques();\n  //=> false\nuniques();\n  //=> 9\nuniques();\n  //=> 4\nuniques();\n  //=> false\n// ...\n```\n\n### select and reject\n\n```javascript\nvar select = iterators.select,\n    reject = iterators.reject;\n\nfunction isEven (number) {\n  return number === 0 || !isEven(number - 1);\n};\n\nvar evens = select(randomNumbers, isEven);\n\nevens();\n  //=> 0\nevens();\n  //=> 6\nevens();\n  //=> 0\nevens();\n  //=> 2\nevens();\n  //=> 4\n// ...\n\nvar odds = reject(randomNumbers, isEven);\n\nodds();\n  //=> 3\nodds();\n  //=> 1\nodds();\n  //=> 7\nodds();\n  //=> 9\nodds();\n  //=> 9\n// ...\n```\n\nNote: `select` and `reject` will enter an \"infinite loop\" if the iterator does not terminate and also does not have any elements matching the condition.\n\n### slice\n\n```javascript\nvar slice = iterators.slice,\n    numbers = unfold(1, function (n) { return n + 1; });\n\nvar i = slice(numbers, 3);\n\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> 6\n\ni = slice(numbers, 3, 2);\n\ni();\n  //=> 10\ni();\n  //=> 11\ni();\n  //=> undefined\n```\n\n### take\n\n```javascript\nvar take = iterators.take,\n    numbers = unfold(1, function (n) { return n + 1; });\n\nvar i = take(numbers);\n\ni();\n  //=> 1\ni();\n  //=> undefined\n\nvar i = take(numbers);\n\ni();\n  //=> 2\ni();\n  //=> undefined\n\nvar i = take(numbers, 3);\n\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n// ...\n```\n\n### drop\n\n```javascript\nvar drop = iterators.drop,\n    numbers = unfold(1, function (n) { return n + 1; });\n\ndrop(numbers);\n\nnumbers();\n  //=> 2\nnumbers();\n  //=> 3\nnumbers();\n  //=> 4\n\ndrop(numbers);\n\nnumbers();\n  //=> 6\nnumbers();\n  //=> 7\n\ndrop(numbers, 3);\n\nnumbers();\n  //=> 11\nnumbers();\n  //=> 12\n// ...\n```\n\n## Trampolining\n\n```\nvar trampoline = require('allong.es').allong.es.trampoline,\n    tailCall = require('allong.es').allong.es.tailCall;\n    \nfunction factorial (n) {\n  var _factorial = trampoline( function myself (acc, n) {\n    return n > 0\n      ? tailCall(myself, acc * n, n - 1)\n      : acc\n  });\n  \n  return _factorial(1, n);\n};\n\nfactorial(10);\n  //=> 3628800\n```\n"
  },
  {
    "path": "_site/Gruntfile.coffee",
    "content": "module.exports = (grunt) ->\n\n  grunt.initConfig \n    pkg: grunt.file.readJSON('package.json'),\n    uglify:\n      options:\n        banner: '/*! http://github.com/raganwald/<%= pkg.name %> v<%= pkg.version %> <%= grunt.template.today(\"yyyy-mm-dd\") %> (c) 2012-2013 Reg Braithwaite MIT Licensed */\\n'\n      build:\n        src: 'lib/<%= pkg.name %>.js',\n        dest: 'lib/<%= pkg.name %>.min.js'\n\n  grunt.loadNpmTasks('grunt-contrib-uglify')\n\n  grunt.registerTask('default', ['uglify'])"
  },
  {
    "path": "_site/README.md",
    "content": "# `allong.es`\n\nThe `allong.es` library is a collection of functions designed to facilitate writing JavaScript and/or CoffeeScript with functions as first-class values. The emphasis in `allong.es` is on composing and decomposing functions using combinators and decorators. `allong.es` is designed to complement libraries like [Underscore](http://underscorejs.org), not compete with them.\n\n## Currying and Partial Application\n\nAt the heart of `allong.es` are the functions that curry and partially apply other functions. The two most important to understand are `call` and `apply`. They work very much like the `.call` and `.apply` methods that every JavaScript function implements:\n\n```javascript\nfunction greet (how, whom) {\n  return '' + how + ', ' + whom + '!';\n};\n  \ncall(greet, 'Hello', 'Tom')\n  //=> 'Hello, Tom!'\n  \napply(greet, ['Hello', 'Tom'])\n  //=> 'Hello, Tom!'\n```\n\nTheir \"special sauce\" is that they automatically *curry* the supplied function, so if you provide fewer or no arguments, you get back a partially applied or curried function:\n\n```javascript\ncall(greet)('Hello')('Tom')\n  //=> 'Hello, Tom!'\n  \ncall(greet, 'Hello')('Tom'])\n  //=> 'Hello, Tom!'\n  \napply(greet, [])('Hello')('Tom')\n  //=> 'Hello, Tom!'\n  \napply(greet, ['Hello'])('Tom'])\n  //=> 'Hello, Tom!'\n```\n\n### immediate application\n\nIf you don't want the currying/partial application behaviour, there is an immediate application version named (appropriately), `callNow` (and also another named `applyNow`, not shown):\n\n```javascript\ncallNow(greet, 'Hello', 'Tom')\n  //=> 'Hello, Tom!'\n  \ncallNow(greet, 'Hello')\n  //=> 'Hello, undefined!'\n```\n\n### variations on the order of applying the arguments\n\n`callRight` applies any arguments supplied to the right. If you supply all the arguments, it's the same as `call`, but if you supply fewer arguments, you get a right partial application:\n\n```javascript\ncallRight(greet, 'Hello', 'Tom')\n  //=> 'Hello, Tom!'\n  \ncallRight(greet, 'Hello')('Tom')\n  //=> 'Tom, Hello!'\n```\n\n`callFlipped` applies the arguments backwards, even when curried:\n\n```javascript\ncallFlipped(greet, 'Hello', 'Tom')\n  //=> 'Tom, Hello!'\n  \ncallFlipped(greet, 'Hello')('Tom')\n  //=> 'Tom, Hello!'\n  \ncallFlipped(greet)('Hello')('Tom')\n  //=> 'Tom, Hello!'\n```\n\n### more partial application\n\n`callLeft` is actually synonymous with `call`: It applies arguments given to the left. We've seen `callRight` above. Both are *variadic*: You can supply as many arguments as you want.\n\n`callFirst` and `callLast` are just like `callLeft` and `callRight`, but they are *binary* functions: They accept a function and exactly one argument. This is sometimes useful when combining functions together.\n\n`callFirst` and `callLast` both have \"flipped and curried\" versions (`callFirstWith` and `callLastWith`). `callLastWith` is especially useful for working with functions written in \"collection - operation\" style. Here we take advantage of the fact that they are \"automatically curried\" to implement the popular `pluck` function.\n\n### currying\n\n`allong.es` does support the `curry` function, it is implemented as the unary form of `call`:\n\n```javascript\nvar curry = unary(call);\n```\n\n### with\n\n`splat` was present in earlier versions of `allong.es` but has been deprecated as being too cryptic. Instead, there is a general naming convention that works as follows. Many binary functions such as `map` and `filter` are historically written to take a noun or collection as the first argument and a verb as the second.\n\nHowever, reversing and currying these functions is super-useful as it makes composeable functions out of them. That's why `callFlipped` is so important. But to save you the trouble of writing `callFlipped map` everywhere, many such functions in `allong.es` have a clipped version pre-defined and named with the suffix `With`:\n\n```\nmap(list, function)       <=> mapWith(function, list)\nfilter(list, function)    <=> filterWith(function, list)\nget(object, propertyName) <=> getWith(propertyName, object)\npluck(list, propertyName) <=> pluckWith(propertyName, list)\n```\n\nSo you \"map\" a list, but \"mapWith\" a function. And of course, they are all curried. For example:\n\n```\nmap(list)(function)       <=> mapWith(function)(list)\ndeepMap(list)(function)   <=> deepMapWith(function)(list)\nfilter(list)(function)    <=> filterWith(function)(list)\nget(object)(propertyName) <=> getWith(propertyName)(object)\npluck(list)(propertyName) <=> pluckWith(propertyName)(list)\n```\n\nThus if you have a collection such as:\n\n```javascript\nvar users = [\n  { name: 'Huey' },\n  { name: 'Dewey' },\n  { name: 'Louie' }\n]\n```\n\nYou can get the names with either:\n\n```javascript\npluck(users, 'name')\n  //=> ['Huey', 'Dewey', 'Louie']\n```\n\nOr:\n\n```javascript\npluckWith('name', users)\n  //=> ['Huey', 'Dewey', 'Louie']\n```\n\nThe latter is interesting because `pluck` and `pluckWith` are both automatically curried (like almost everything that isn't named \"now\"). Thus, we could also write:\n\n```javascript\nvar namesOf = pluckWith('name');\n\n// ...\nnamesOf(users)\n  //=> ['Huey', 'Dewey', 'Louie']\n```\n\n## Arity Function Decorators\n\n### variadic\n\nMakes a function into a variadic (accepts any number of arguments). The last named parameter will be given an array of arguments.\n\n```javascript\nvar variadic = require('allong.es').allong.es.variadic;\n\nvar fn = variadic(function (a) { return a })\n\nfn()\n  //=> []\nfn(1, 2, 3)\n  //=> [1,2,3]\n\nfn = variadic(function (a,b) { return { a: a, b: b } })\n\nfn()\n  //=> { a: undefined, b: [] }\nfn(1)\n  //=> { a: 1, b: [] }\nfn(1,2,3)\n  //=> { a: 1, b: [2, 3] }\n```\n\n### variadic, part ii\n\nWhen given just the function, `variadic` returns a function with an arity of zero. This is consistent with JavaScript programming practice. There are times when you wish to report an arity, meaning that you want the returned function to have its `length` getibute set.\n\nYou do this by prefacing the function argument with a length:\n\n```javascript\nfn = variadic(function (a,b) { return { a: a, b: b } });\n\nfn.length\n  //=> 0\n  \nfn2 = variadic(1, function (a,b) { return { a: a, b: b } }); \n\nfn2.length\n  //=> 1\n```\n\n### unary, binary, and ternary\n\nSometimes, you have a function that takes multiple arguments, but you only want it to accept one, or two, or maybe three arguments and ignore the rest. For example, `parseInt` takes a radix as an optional second parameter. And that is havoc if you try to use it with `Array.map`:\n\n```javascript\n['1', '2', '3', '4', '5'].map(parseInt)\n  //=> [ 1,\n  //     NaN,\n  //     NaN,\n  //     NaN,\n  //     NaN ]\n```\n\nUse `unary(parseInt)` to solve the problem:\n\n```javascript\n['1', '2', '3', '4', '5'].map(unary(parseInt))\n  //=> [ 1, 2, 3, 4, 5 ]\n```\n\n`binary` has similar uses when working with `Array.reduce` and its habit of passing three parameters to your supplied function.\n\n## Miscellaneous Combinators\n\n### bound\n\n```javascript\nvar bound = require('allong.es').allong.es.bound;\n    \nbound(fn, args...)(obj)\n  //=> fn.bind(obj, args...)\n```\n\n### getWith\n\n```javascript\nvar getWith = require('allong.es').allong.es.getWith;\n    \narray.map(getWith('property'))\n  //=> array.map(function (element) {\n  //               return element['property']\n  //             })\n```\n\n## Functional Composition\n\n```javascript\nvar compose = require('allong.es').allong.es.compose,\n    sequence = require('allong.es').allong.es.sequence;\n    \ncompose(a, b, c)\n  //=> function (x) {\n  //     return a(b(c(x)))\n  //   }\n \nsequence(a, b, c)\n  //=> function (x) {\n  //     return c(b(a(x)))\n  //   }\n```\n\n## List Combinators\n\n### mapWith and deepMapWith\n\n```javascript\nvar mapWith = require('allong.es').allong.es.mapWith,\n    deepMapWith = require('allong.es').allong.es.deepMapWith;\n    \nvar squareList = mapWith(function (x) { return x * x })\n\nsquareList([1, 2, 3, 4])\n  //=> [1, 4, 9, 16]\n  \nvar squareTree = deepMapWith(function (x) { return x * x })\n\nsquareTree([1, 2, [3, 4]])\n  //=> [1, 4, [9, 16]]\n```\n\n## Function/Method Decorators\n\n### maybe\n\n```javascript\nvar maybe = require('allong.es').allong.es.maybe;\n    \nvar safeFirst = maybe(function (arr) { return arr[0] })\n\nsafeFirst([1, 2, 3])\n  //=> 1\nsafeFirst(null)\n  //=> null\n```\n\n### tap\n\n```javascript\nvar tap = require('allong.es').allong.es.tap;\n    \ntap([1, 2, 3, 4, 5], send('pop'))\n  //=> [1, 2, 3, 4]\n```\n\n### fluent\n\n```javascript\nvar fluent = require('allong.es').allong.es.fluent;\n    \nRole = function () {}\n\nRole.prototype.set = fluent( function (property, name) { \n  this[property] = name \n})\n\nvar doomed = new Role()\n  .set('name', \"Fredo\")\n  .set('relationship', 'brother')\n  .set('parts', ['I', 'II'])\n```\n\n### once\n\n```javascript\nvar once = require('allong.es').allong.es.once;\n    \nvar message = once( function () { console.log(\"Hello, it's me\") })\n\nmessage()\n  //=> \"Hello, it's me\"\nmessage()\n  //=>\nmessage()\n  //=>\nmessage()\n  //=>\n```\n\n## Decorating Classes/Constructors\n\n```javascript\nvar mixin = require('allong.es').allong.es.mixin,\n    classDecorator = require('allong.es').allong.es.classDecorator;\n    \nfunction Todo (name) {\n  var self = this instanceof Todo\n             ? this\n             : new Todo();\n  self.name = name || 'Untitled';\n  self.done = false;\n};\n\nTodo.prototype.do = fluent( function () {\n  this.done = true;\n});\n\nTodo.prototype.undo = fluent( function () {\n  this.done = false;\n});\n\nvar AddLocation = mixin({\n      setLocation: fluent( function (location) {\n        this.location = location;\n      }),\n      getLocation: function () { return this.location; }\n    });\n\nAddLocation.call(Todo.prototype);\n// Or use AddLocation(Todo.prototype)\n\nnew Todo(\"Vacuum\").setLocation('Home');\n  //=> { name: 'Vacuum',\n  //     done: false,\n  //     location: 'Home' }\n\nvar AndColourCoded = classDecorator({\n  setColourRGB: fluent( function (r, g, b) {\n    this.colourCode = { r: r, g: g, b: b };\n  }),\n  getColourRGB: function () {\n    return this.colourCode;\n  }\n});\n\nvar ColourTodo = AndColourCoded(Todo);\n\nnew ColourTodo('Use More Decorators').setColourRGB(0, 255, 0);\n  //=> { name: 'Use More Decorators',\n  //     done: false,\n  //     colourCode: { r: 0, g: 255, b: 0 } }\n```\n\nNote: `classDecorator` works with JavaScript constructors that have a default implementation (they work properly with no arguments), and are new-agnostic (they can be called with new or as a normal function). `Todo` above has both properties.\n\n## Functional Iterators\n\nFunctional iterators are stateful functions that \"iterate over\" the values in some ordered data set. You call the iterator repeatedly to obtain the values, and it will either never stop returning values (an infinite data set) or return `undefined` when there are no more values to return.\n\nThe functional iterators utilities are all namespaced:\n\n```javascript\nvar iterators = require('allong.es').allong.es.iterators;\n```\n\n### FlatArrayIterator and RecursiveArrayIterator\n\nMaking functional iterators from arrays:\n\n```javascript\nvar FlatArrayIterator = iterators.FlatArrayIterator,\n    RecursiveArrayIterator = iterators.RecursiveArrayIterator;\n    \nvar i = FlatArrayIterator([1, 2, 3, 4, 5]);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n    \nvar i = FlatArrayIterator([1, [2, 3, 4], 5]);\n\ni();\n  //=> 1\ni();\n  //=> [2, 3, 4]\ni();\n  //=> 5\ni();\n  //=> undefined\n    \nvar i = RecursiveArrayIterator([1, [2, 3, 4], 5]);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n```\n\n### range and numbers\n\n```javascript\nvar range = iterators.range,\n    numbers = iterators.numbers;\n\nvar i = range(1, 5);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n\nvar i = range(1, 5, 2);\n\ni();\n  //=> 1\ni();\n  //=> 3\ni();\n  //=> 5\ni();\n  //=> undefined\n\nvar i = range(5, 1);\n\ni();\n  //=> 5\ni();\n  //=> 4\ni();\n  //=> 3\ni();\n  //=> 2\ni();\n  //=> 1\ni();\n  //=> undefined\n\nvar i = range(1);\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n\nvar i = numbers();\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n\nvar i = numbers(0);\n\ni();\n  //=> 0\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n```\n\n### unfold and unfoldWithReturn\n\nUnfold makes an iterator out of a seed by successively applying a function to the seed value. Here's an example duplicating the \"numbers\" feature:\n\n```javascript\nvar unfold = iterators.unfold,\n    unfoldWithReturn = iterators.unfoldWithReturn;\n    \nvar i = unfold(1, function (n) { return n + 1; });\n\ni();\n  //=> 1\ni();\n  //=> 2\ni();\n  //=> 3\n// ...\n    \nvar i = unfoldWithReturn(1, function (n) { \n  return [n + 1, n + n]; \n});\n\ni();\n  //=> 2\ni();\n  //=> 4\ni();\n  //=> 6\n// ...\n```\n\nA richer example of `unfoldWithReturn`:\n\n```javaascript\nvar cards = ['A', 2, 3, 4, 5, 6, 7, 8, 9, '10', 'J', 'Q', 'K'];\n\nfunction pickCard (deck) {\n  var position;\n  \n  if (deck.length === 0) {\n    return [[], void 0];\n  }\n  else {\n    position = Math.floor(Math.random() * deck.length);\n    return [\n      deck.slice(0, position).concat(deck.slice(position + 1)),\n      deck[position]\n    ];\n  }\n};\n\nvar i = unfoldWithReturn(cards, pickCard);\n\ni();\n  //=> 5\ni();\n  //=> 4\ni();\n  //=> 2\ni();\n  //=> J\n  \n// ...\n```\n\n### map\n\nStateless mapping of an iterator to another iterator:\n\n```javascript\nvar map = iterators.map;\n    \nvar squares = map(numbers, function (n) { return n * n; });\n\nsquares();\n  //=> 1\nsquares();\n  //=> 4\nsquares();\n  //=> 9\n// ...\n```\n\n### accumulate\n\nAccumulating an iterator to another iterator, a/k/a stateful mapping, with an optional seed:\n\n```javascript\nvar accumulate = iterators.accumulate;\n    \nvar runningTotal = accumulate(numbers, function (accumulation, n) { \n      return accumulation + n; \n    });\n\nrunningTotal();\n  //=> 1\nrunningTotal();\n  //=> 3\nrunningTotal();\n  //=> 6\nrunningTotal();\n  //=> 10\nrunningTotal();\n  //=> 15\n// ...\n\nvar runningTotal = accumulate(numbers, function (accumulation, n) { \n      return accumulation + n; \n    }, 5);\n\nrunningTotal();\n  //=> 6\nrunningTotal();\n  //=> 8\nrunningTotal();\n  //=> 11\nrunningTotal();\n  //=> 15\nrunningTotal();\n  //=> 20\n// ...\n```\n\n### accumulateWithReturn\n\nThis code transforms filters duplicates out of an iterator of numbers by turning them into \"false.\" It consumes space proportional to the time it runs and the size of the set of possible numbers in its iterator.\n\n```javascript\nvar accumulateWithReturn = iterators.accumulateWithReturn;\n    \nvar randomNumbers = function () {\n  return Math.floor(Math.random() * 10);\n};\n\nrandomNumbers();\n  //=> 7\nrandomNumbers();\n  //=> 0\nrandomNumbers();\n  //=> 1\nrandomNumbers();\n  //=> 1\nrandomNumbers();\n  //=> 6\n// ...\n\nvar uniques = accumulateWithReturn(randomNumbers, function (alreadySeen, number) {\n  var key = number.toString();\n  \n  if (alreadySeen[key]) {\n    return [alreadySeen, false];\n  }\n  else {\n    alreadySeen[key] = true;\n    return [alreadySeen, number];\n  }\n}, {});\n\nuniques();\n  //=> 7\nuniques();\n  //=> 5\nuniques();\n  //=> 1\nuniques();\n  //=> false\nuniques();\n  //=> 9\nuniques();\n  //=> 4\nuniques();\n  //=> false\n// ...\n```\n\n### select and reject\n\n```javascript\nvar select = iterators.select,\n    reject = iterators.reject;\n\nfunction isEven (number) {\n  return number === 0 || !isEven(number - 1);\n};\n\nvar evens = select(randomNumbers, isEven);\n\nevens();\n  //=> 0\nevens();\n  //=> 6\nevens();\n  //=> 0\nevens();\n  //=> 2\nevens();\n  //=> 4\n// ...\n\nvar odds = reject(randomNumbers, isEven);\n\nodds();\n  //=> 3\nodds();\n  //=> 1\nodds();\n  //=> 7\nodds();\n  //=> 9\nodds();\n  //=> 9\n// ...\n```\n\nNote: `select` and `reject` will enter an \"infinite loop\" if the iterator does not terminate and also does not have any elements matching the condition.\n\n### slice\n\n```javascript\nvar slice = iterators.slice,\n    numbers = unfold(1, function (n) { return n + 1; });\n\nvar i = slice(numbers, 3);\n\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> 6\n\ni = slice(numbers, 3, 2);\n\ni();\n  //=> 10\ni();\n  //=> 11\ni();\n  //=> undefined\n```\n\n### take\n\n```javascript\nvar take = iterators.take,\n    numbers = unfold(1, function (n) { return n + 1; });\n\nvar i = take(numbers);\n\ni();\n  //=> 1\ni();\n  //=> undefined\n\nvar i = take(numbers);\n\ni();\n  //=> 2\ni();\n  //=> undefined\n\nvar i = take(numbers, 3);\n\ni();\n  //=> 3\ni();\n  //=> 4\ni();\n  //=> 5\ni();\n  //=> undefined\n// ...\n```\n\n### drop\n\n```javascript\nvar drop = iterators.drop,\n    numbers = unfold(1, function (n) { return n + 1; });\n\ndrop(numbers);\n\nnumbers();\n  //=> 2\nnumbers();\n  //=> 3\nnumbers();\n  //=> 4\n\ndrop(numbers);\n\nnumbers();\n  //=> 6\nnumbers();\n  //=> 7\n\ndrop(numbers, 3);\n\nnumbers();\n  //=> 11\nnumbers();\n  //=> 12\n// ...\n```\n\n## Trampolining\n\n```\nvar trampoline = require('allong.es').allong.es.trampoline,\n    tailCall = require('allong.es').allong.es.tailCall;\n    \nfunction factorial (n) {\n  var _factorial = trampoline( function myself (acc, n) {\n    return n > 0\n      ? tailCall(myself, acc * n, n - 1)\n      : acc\n  });\n  \n  return _factorial(1, n);\n};\n\nfactorial(10);\n  //=> 3628800\n```\n"
  },
  {
    "path": "_site/functions.txt",
    "content": "{ variadic: [Function],\n  unvariadic: [Function: unvariadic],\n  curryWithLeftAndRight: [Function: curryWithLeftAndRight],\n  unary: [Function: unary],\n  binary: [Function: binary],\n  ternary: [Function: ternary],\n  quaternary: [Function: quaternary],\n  selfCurrying: [Function: selfCurrying],\n  compose: [Function],\n  sequence: [Function],\n  callFlipped: \n   { [Function]\n     unary: [Function: unary],\n     binary: [Function: binary],\n     ternary: [Function: ternary],\n     quaternary: [Function: quaternary],\n     callWithLeftFlipped: [Function: callWithLeftFlipped] },\n  flip: [Function: myself],\n  applyNow: [Function: myself],\n  callNow: \n   { [Function]\n     unary: [Function: unary],\n     binary: [Function: binary],\n     ternary: [Function: ternary],\n     quaternary: [Function: quaternary] },\n  call: [Function],\n  callLeft: [Function],\n  callRight: [Function],\n  applyN: [Function: myself],\n  applyLeftNow: [Function: myself],\n  callLeftNow: [Function],\n  applyLeftNowWith: [Function: myself],\n  applyRightNow: [Function: myself],\n  callRightNow: [Function],\n  applyRightNowWith: [Function: myself],\n  callFirst: [Function: myself],\n  callLast: [Function: myself],\n  callFirstWith: [Function: myself],\n  callLastWith: [Function: myself],\n  bound: [Function],\n  defaults: [Function],\n  args: [Function: args],\n  curry: [Function: myself],\n  map: [Function: myself],\n  mapWith: [Function: myself],\n  filterWith: [Function: filterWith],\n  deepMap: [Function: myself],\n  deepMapWith: [Function: myself],\n  maybe: [Function: maybe],\n  tap: [Function: tap],\n  fluent: [Function: fluent],\n  returnFirst: [Function],\n  tee: [Function: tee],\n  once: [Function: once],\n  memoized: [Function: memoized],\n  mixin: [Function: mixin],\n  classDecorator: [Function: classDecorator],\n  bind: [Function: bind],\n  unbind: [Function: unbind],\n  invoke: [Function: invoke],\n  get: [Function: get],\n  getWith: [Function: getWith],\n  send: [Function],\n  pluckWith: [Function],\n  pluck: [Function: myself],\n  trampoline: [Function: trampoline],\n  tailCall: [Function],\n  Thunk: [Function: Thunk],\n  iterators: \n   { accumulate: [Function: accumulate],\n     accumulateWithReturn: [Function: accumulateWithReturn],\n     fold: [Function: fold],\n     unfold: [Function: unfold],\n     unfoldWithReturn: [Function: unfoldWithReturn],\n     map: [Function: map],\n     select: [Function: select],\n     reject: [Function: reject],\n     filter: [Function: select],\n     find: [Function: find],\n     slice: [Function: slice],\n     drop: [Function],\n     take: [Function: take],\n     FlatArrayIterator: [Function: FlatArrayIterator],\n     RecursiveArrayIterator: [Function: RecursiveArrayIterator],\n     constant: [Function: K],\n     K: [Function: K],\n     numbers: [Function: myself],\n     range: [Function: range] } }"
  },
  {
    "path": "_site/lib/allong.es.js",
    "content": "/*! http://github.com/raganwald/allong.es (c) 2012-2013 Reg Braithwaite MIT Licensed */\n(function (root) {\n  \n  // Setup\n  // -----\n\n  // Establish the root object, `window` in the browser, or `global` on the server.\n  // *taken from [Underscore.js](http://underscorejs.org/)*\n\n  var root = this;\n  \n  var __slice = Array.prototype.slice,\n      __map = Array.prototype.map,\n      __hasProp = Array.prototype.hasOwnProperty,\n      __filter = Array.prototype.filter;\n  \n  // here's our export object\n  var allong = { es: {} };\n\n  // ## Functionalizing\n  //\n  // The utility functions operate on other functions. They can also operate on string\n  // abbreviations for functions by calling `functionalzie(...)` on their inputs.\n\n  // SHIM\n  if ('ab'.split(/a*/).length < 2) {\n    if (typeof console !== \"undefined\" && console !== null) {\n      console.log(\"Warning: IE6 split is not ECMAScript-compliant.  This breaks '->1'\");\n    }\n  }\n\n  // on the fence about whether to export this?\n  function to_function (str) {\n    var expr, leftSection, params, rightSection, sections, v, vars, _i, _len;\n    params = [];\n    expr = str;\n    sections = expr.split(/\\s*->\\s*/m);\n    if (sections.length > 1) {\n      while (sections.length) {\n        expr = sections.pop();\n        params = sections.pop().split(/\\s*,\\s*|\\s+/m);\n        sections.length && sections.push('(function(' + params + '){return (' + expr + ')})');\n      }\n    } else if (expr.match(/\\b_\\b/)) {\n      params = '_';\n    } else {\n      leftSection = expr.match(/^\\s*(?:[+*\\/%&|\\^\\.=<>]|!=)/m);\n      rightSection = expr.match(/[+\\-*\\/%&|\\^\\.=<>!]\\s*$/m);\n      if (leftSection || rightSection) {\n        if (leftSection) {\n          params.push('$1');\n          expr = '$1' + expr;\n        }\n        if (rightSection) {\n          params.push('$2');\n          expr = expr + '$2';\n        }\n      } else {\n        vars = str.replace(/(?:\\b[A-Z]|\\.[a-zA-Z_$])[a-zA-Z_$\\d]*|[a-zA-Z_$][a-zA-Z_$\\d]*\\s*:|this|arguments|'(?:[^'\\\\]|\\\\.)*'|\"(?:[^\"\\\\]|\\\\.)*\"/g, '').match(/([a-z_$][a-z_$\\d]*)/gi) || [];\n        for (_i = 0, _len = vars.length; _i < _len; _i++) {\n          v = vars[_i];\n          params.indexOf(v) >= 0 || params.push(v);\n        }\n      }\n    }\n    return new Function(params, 'return (' + expr + ')');\n  };\n\n  function functionalize (fn) {\n    if (typeof fn === 'function') {\n      return fn;\n    } else if (typeof fn === 'string' && /^[_a-zA-Z]\\w*$/.test(fn)) {\n      return function() {\n        var args, receiver, _ref;\n        receiver = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];\n        return (_ref = receiver[fn]).call.apply(_ref, [receiver].concat(__slice.call(args)));\n      };\n    } else if (typeof fn === 'string') {\n      return to_function(fn);\n    } else if (typeof fn.lambda === 'function') {\n      return fn.lambda();\n    } else if (typeof fn.toFunction === 'function') {\n      return fn.toFunction();\n    }\n  };\n\n  function extend () {\n    var consumer = arguments[0],\n        providers = __slice.call(arguments, 1),\n        key,\n        i,\n        provider,\n        except;\n\n    for (i = 0; i < providers.length; ++i) {\n      provider = providers[i];\n      except = provider['except'] || [];\n      except.push('except');\n      for (key in provider) {\n        if (except.indexOf(key) < 0 && provider.hasOwnProperty(key)) {\n          consumer[key] = provider[key];\n        };\n      };\n    };\n    return consumer;\n  };\n      \n  function rotate (array, n) {\n    var copy = array.slice(0),\n        i, \n        pull, \n        push;\n    \n    if (n !== 0) {\n      n || (n = 1);\n      if (n > 0) {\n        pull = 'shift';\n        push = 'push';\n      }\n      else {\n        n = -n;\n        pull = 'pop';\n        push = 'unshift'\n      }\n      for (i = 0; i < n; ++i) {\n        copy[push](copy[pull]());\n      }\n    }\n    \n    return copy;\n  };\n  \n  function reverse (array) {\n    return array.reduce(function (acc, element) {\n      acc.unshift(element);\n      return acc;\n    }, []);\n  };\n  \n  // # ARITY\n  \n  function invokeImmediately (fn) { return fn(); };\n\n  // ### \"Variadic\"\n  //\n  //    fn = variadic(function (args) { return args })\n  //\n  //    fn()        //=> []\n  //    fn(1)       //=> [1]\n  //    fn(1, 2)    //=> [1, 2]\n  //    fn(1, 2, 3) //=> [1, 2, 3]\n  //\n  //    fn = variadic(function (first, rest) { return [first, rest]})\n  //\n  //    fn()        //=> [undefined, []]\n  //    fn(1)       //=> [1, []]\n  //    fn(1, 2)    //=> [1, [2]]\n  //    fn(1, 2, 3) //=> [1, [2, 3]]\n  //\n  //    fn = variadic(function (first, second, rest) { return [first, second, rest]})\n  //\n  //    fn()        //=> [undefined, undefined, []]\n  //    fn(1)       //=> [1, undefined, []]\n  //    fn(1, 2)    //=> [1, 2, []]\n  //    fn(1, 2, 3) //=> [1, 2, [3]]\n  var variadic = function () {\n    var FUNCTIONS = {};\n    function oldVariadic (fn) {\n      var fnLength = fn.length;\n\n      if (fnLength < 1) {\n        return fn;\n      }\n      else if (fnLength === 1)  {\n        return function () {\n          return fn.call(this, __slice.call(arguments, 0))\n        }\n      }\n      else {\n        return function () {\n          var numberOfArgs = arguments.length,\n              namedArgs = __slice.call(arguments, 0, fnLength - 1),\n              numberOfMissingNamedArgs = Math.max(fnLength - numberOfArgs - 1, 0),\n              argPadding = new Array(numberOfMissingNamedArgs),\n              variadicArgs = __slice.call(arguments, fn.length - 1);\n\n          return fn.apply(this, namedArgs.concat(argPadding).concat([variadicArgs]))\n        }\n      }\n    };\n    return function (arity, fn) {\n      if (fn == null) {\n        fn = functionalize(arity);\n        arity = 0;\n      }\n      else fn = functionalize(fn);\n      var fnLength = fn.length;\n      if (arity === 0) {\n        return oldVariadic(fn);\n      }\n      else if (fnLength <= arity) {\n        var fixedParams = fnLength - 1;\n        var index = '' + arity + '-' + fixedParams;\n        var code;\n      \n        if (FUNCTIONS[index] == null) {\n          var parameters = new Array(arity);\n          for (var i = 0; i < arity; ++i) {\n            parameters[i] = \"__\" + i;\n          }\n          var pstr = parameters.join();\n          if (fnLength > 1) {\n            var cstr = parameters.slice(0, fnLength - 1).join();\n            code = \"return function (\"+pstr+\") { return fn.call(\"+cstr+\", [].slice.call(arguments,\"+(fnLength - 1)+\")); };\";\n          }\n          else code = \"return function (\"+pstr+\") { return fn.call(this, [].slice.call(arguments, 0)); };\";\n          FUNCTIONS[index] = new Function(['fn'], code);\n        }\n        return FUNCTIONS[index](fn);\n      }\n      else throw 'not supported yet'\n    };\n  }();\n  \n  // sets a fixed arity for a function, without currying\n  var unvariadic = (function () {\n    var FUNCTIONS = {};\n    return function unvariadic (arity, fn) {\n      if (FUNCTIONS[arity] == null) {\n        var parameters = new Array(arity);\n        for (var i = 0; i < arity; ++i) {\n          parameters[i] = \"__\" + i;\n        }\n        var pstr = parameters.join();\n        var code = \"return function (\"+pstr+\") { return fn.apply(this, arguments); };\";\n        FUNCTIONS[arity] = new Function(['fn'], code);\n      }\n      if (fn == null) {\n        return function (fn) { return unvariadic(arity, fn); };\n      }\n      else return FUNCTIONS[arity](functionalize(fn));\n    };\n  })();\n\n  // a kind of optional semantics: unary(f)(value) === f(value), unary(f)() === unary(f)\n  function unary (fn) {\n    return function unary (a) {\n      if (a == null) {\n        return unary;\n      }\n      else return fn(a);\n    }\n  };\n\n  function binary (fn) {\n    return function binary (a, b) {\n      if (a == null) {\n        return binary;\n      }\n      else if (b == null) {\n        return unary(function (b) { return fn(a, b); });\n      }\n      else return fn(a, b);\n    }\n  };\n\n  function ternary (fn) {\n    return function ternary (a, b, c) {\n      if (a == null) {\n        return ternary;\n      }\n      else if (b == null) {\n        return binary(function (b, c) { return fn(a, b, c); });\n      }\n      else if (c == null) {\n        return unary(function (c) { return fn(a, b, c); });\n      }\n      else return fn(a, b, c);\n    }\n  };\n\n  function quaternary (fn) {\n    return function quaternary (a, b, c, d) {\n      if (a == null) {\n        return quaternary;\n      }\n      else if (b == null) {\n        return ternary(function (b, c, d) { return fn(a, b, c, d); });\n      }\n      else if (c == null) {\n        return binary(function (c, d) { return fn(a, b, c, d); });\n      }\n      else if (d == null) {\n        return unary(function (d) { return fn(a, b, c, d); });\n      }\n      else return fn(a, b, c, d);\n    }\n  };\n  \n  var byArity = [\n        invokeImmediately,\n        unary,\n        binary,\n        ternary,\n        quaternary\n      ],\n      byArityLength = byArity.length;\n  \n  function curryWithLeftAndRight (fn, leftArgs, rightArgs) {\n    leftArgs || (leftArgs = []);\n    rightArgs || (rightArgs = []);\n    var fnLength = fn.length,\n        remainingLength = fnLength - leftArgs.length - rightArgs.length;\n    \n    if (remainingLength < byArityLength) {\n      return byArity[remainingLength](handleRemaining);\n    }\n    else return unvariadic(remainingLength, handleRemaining);\n        \n    function handleRemaining () {\n      var params = __slice.call(arguments, 0, arguments.length),\n          numParams = ((params.indexOf(void 0) >= 0)\n            ? params.indexOf(void 0)\n            : params.length),\n          newLeft = leftArgs.concat(params.slice(0, numParams)),\n          args = newLeft.concat(rightArgs),\n          argsLength = args.length,\n          remainingLength = fnLength - argsLength;\n      \n      if (remainingLength <= 0) {\n        return fn.apply(this, args);\n      }\n      else return curryWithLeftAndRight(fn, newLeft, rightArgs);\n    };\n  };\n  \n  extend(allong.es, { curryWithLeftAndRight: curryWithLeftAndRight });\n  \n  // TODO: Deprecate\n  function selfCurrying(fn) {\n    fn = functionalize(fn);\n    var fnLength = fn.length;\n    \n    if (fn.length > 0) {\n      return variadic(fnLength, function (args) {\n        if (args.length === 0) {\n          return curry(fn)\n        }\n        else return fn.apply(this, args);\n      });\n    }\n    else return fn;\n  };\n  \n  extend(allong.es, {\n    variadic: variadic,\n    unvariadic: unvariadic,\n    unary: unary,\n    binary: binary,\n    ternary: ternary,\n    quaternary: quaternary\n  });\n\n  // ### Composition\n\n  //    compose(a, b, c)\n  //      //=> function (x) {\n  //        return a(b(c(x)))\n  //      }\n  var compose = variadic( function compose (fns) {\n    fns = fns.map(functionalize);\n    \n    var first, firstLength, second, rest;\n    \n    if (fns.length === 0) {\n      return function () {};\n    }\n    else if (fns.length === 1) {\n      return fns[0];\n    }\n    else if (fns.length === 2) {\n      first = fns[0];\n      firstLength = first.length;\n      second = fns[1];\n      \n      if (firstLength === 1) {\n        return function (a) { return first(second(a)); };\n      }\n      else if (firstLength === 2) {\n        return function (a, b) { return first(second(a), b); };\n      }\n      else if (firstLength === 3) {\n        return function (a, b, c) { return first(second(a), b, c); };\n      }\n      else return variadic( function (a, rest) {\n        first.apply(this, [second(a)].concat(rest))\n      });\n    }\n    else {\n      var first = fns[0],\n          butFirst = __slice.call(fns, 1);\n\n      return compose.call(this, first, compose.apply(this, butFirst));\n    }\n  });\n\n  extend(allong.es, {\n    compose: compose\n  });\n  \n  // # CALL_FLIPPED\n  \n  var callFlipped = (function () {\n    \n    function nullary (fn) {\n      return variadic( function (args) {\n        return fn.apply(this, reverse(args));\n      });\n    };\n  \n    // a kind of optional semantics: unary(f)(value) === f(value), unary(f)() === unary(f)\n    function unary (fn) {\n      return function unary (a) {\n        if (a == null) {\n          return unary;\n        }\n        else return fn(a);\n      }\n    };\n\n    function binary (fn) {\n      return function binary (a, b) {\n        if (a == null) {\n          return binary;\n        }\n        else if (b == null) {\n          return unary(function (b) { return fn(b, a); });\n        }\n        else return fn(b, a);\n      }\n    };\n\n    function ternary (fn) {\n      return function ternary (a, b, c) {\n        if (a == null) {\n          return ternary;\n        }\n        else if (b == null) {\n          return binary(function (c, b) { return fn(c, b, a); });\n        }\n        else if (c == null) {\n          return unary(function (c) { return fn(c, b, a); });\n        }\n        else return fn(c, b, a);\n      }\n    };\n\n    function quaternary (fn) {\n      return function quaternary (a, b, c, d) {\n        if (a == null) {\n          return quaternary;\n        }\n        else if (b == null) {\n          return ternary(function (d, c, b) { return fn(d, c, b, a); });\n        }\n        else if (c == null) {\n          return binary(function (d, c) { return fn(d, c, b, a); });\n        }\n        else if (d == null) {\n          return unary(function (d) { return fn(d, c, b, a); });\n        }\n        else return fn(d, c, b, a);\n      }\n    };\n  \n    var byArity = [\n          nullary,\n          unary,\n          binary,\n          ternary,\n          quaternary\n        ],\n        byArityLength = byArity.length;\n\n    function callWithLeftFlipped (fn, leftArgs) {\n      leftArgs || ( leftArgs = []);\n      var fnLength = fn.length,\n          remainingLength = fnLength - leftArgs.length;\n    \n      if (remainingLength < byArityLength) {\n        return byArity[remainingLength](handleRemaining);\n      }\n      else return unvariadic(remainingLength, handleRemaining);\n        \n      function handleRemaining () {\n        var params = __slice.call(arguments, 0, arguments.length),\n            numParams = (params.indexOf(void 0) >= 0)\n              ? params.indexOf(void 0)\n              : params.length\n            args = leftArgs.concat(params.slice(0, numParams));\n            argsLength = args.length,\n            remainingLength = fnLength - argsLength;\n      \n        if (remainingLength <= 0) {\n          return fn.apply(this, reverse(args));\n        }\n        else return callWithLeftFlipped(fn, args);\n      };\n    };\n  \n    return extend( variadic( function callFlipped (fn, args) {\n      fn = functionalize(fn);\n      var fnLength = fn.length,\n          flipped = (fnLength < byArityLength)\n            ? byArity[fnLength](fn)\n            : callWithLeftFlipped(fn);\n    \n      if (args.length === 0) {\n        return flipped;\n      }\n      else return flipped.apply(this, args);\n    \n    }), {\n      unary: unary,\n      binary: binary,\n      ternary: ternary,\n      quaternary: quaternary,\n      callWithLeftFlipped: callWithLeftFlipped\n    });\n  \n  })();\n  \n  // synonymish\n  var flip = unary(callFlipped);\n\n  extend(allong.es, {\n    callFlipped: callFlipped,\n    flip: flip\n  });\n  \n  // # APPLY\n  \n  // the basics: apply and call\n  \n  // call that retuns a curried function\n  \n  var apply = binary( function (fn, args) {\n    return curryWithLeftAndRight(fn, args, []);\n  });\n  \n  var call = variadic( function (fn, args) {\n    return curryWithLeftAndRight(fn, args, []);\n  });\n  \n  var curry = unary(call);\n  \n  function urApply (fn, args) {\n    return fn.apply(this, args);\n  };\n  \n  var applyNow = call( urApply );\n  \n  var callNow = extend( variadic(applyNow), {\n    unary: unary,\n    binary: binary,\n    ternary: ternary,\n    quaternary: quaternary\n  });\n  \n  // flipped forms\n  \n  var applyNowFlipped = flip(urApply);\n  \n  // apply and call left\n  \n  function urApplyLeft (fn, leftArgs) {\n    var remainingLength = fn.length - leftArgs.length;\n    \n    if (fn.length > 0 && remainingLength > 0) {\n      return variadic(remainingLength, function (args) {\n        return fn.apply(this, leftArgs.concat(args));\n      });\n    }\n    else return fn.apply(this, leftArgs);\n  };\n  \n  var applyLeftNow = call(urApplyLeft);\n  \n  var callLeftNow = variadic(urApplyLeft);\n  \n  // flipped\n  \n  var applyLeftNowWith = flip(urApplyLeft);\n  \n  var applyRightNowWith = flip(urApplyRight);\n  \n  // rightmost\n  \n  function urApplyRight (fn, rightArgs) {\n    var remainingLength = fn.length - rightArgs.length;\n    \n    if (fn.length > 0 && remainingLength > 0) {\n      return variadic(remainingLength, function (args) {\n        return fn.apply(this, args.concat(rightArgs));\n      });\n    }\n    else return fn.apply(this, rightArgs);\n  }\n  \n  var applyRightNow = call(urApplyRight);\n  \n  var callRightNow = variadic(urApplyRight);\n  \n  var callRight = variadic( function (fn, args) {\n    return curryWithLeftAndRight(fn, [], args);\n  });\n  \n  var callFirst = binary(call);\n  var callFirstWith = flip(callFirst);\n  \n  var callLast = binary(callRight);\n  var callLastWith = flip(callLast);\n\n  // ### Partial applications that bind\n\n  // A partially applied binding function\n  //\n  // roughly equivalent to applyRight\n  //\n  // var fn = function (...) { ... }\n  //\n  // bound(fn)(x)\n  //   //=> fn.bind(x)\n  //\n  // bound(fn, foo)(x)\n  //   //=> fn.bind(x, foo)\n  //\n  // bound(fn, foo, bar)(x)\n  //   //=> fn.bind(x, foo, bar)\n  var bound = variadic( function (messageName, args) {\n    if (args === []) {\n      return function (instance) {\n        return instance[messageName].bind(instance)\n      }\n    }\n    else {\n      return function (instance) {\n        return Function.prototype.bind.apply(\n          instance[messageName], [instance].concat(args)\n        )\n      }\n    }\n  });\n  \n  var defaults = variadic( function (fn, values) {\n    var fln = fn.length,\n        vln = values.length;\n    return variadic( function (args) {\n      var aln = args.length,\n          mln = Math.max(fln - aln, 0);\n      args = args.concat(values.slice(vln-mln));\n      return fn.apply(this, args);\n    })\n  });\n  \n  // collects arguments\n  function args (arity) {\n    if (arity === 1) {\n      return function (a) {\n        return [a];\n      };\n    }\n    else if (arity === 2) {\n      return function (a, b) {\n        return [a, b];\n      };\n    }\n    else if (arity === 3) {\n      return function (a, b, c) {\n        return [a, b, c];\n      };\n    }\n    else return variadic( function (args) {\n      return args;\n    });\n  };\n  \n  extend(allong.es, {\n    applyNow: applyNow,\n    apply: apply,\n    callNow: callNow,\n    call: call,\n    callLeft: call,\n    callRight: callRight,\n    applyNowFlipped: applyNowFlipped,\n    applyLeftNow: applyLeftNow,\n    callLeftNow: callLeftNow,\n    applyLeftNowWith: applyLeftNowWith,\n    applyRightNow: applyRightNow,\n    callRightNow: callRightNow,\n    applyRightNowWith: applyRightNowWith,\n    callFirst: callFirst,\n    callLast: callLast,\n    callFirstWith: callFirstWith,\n    callLastWith: callLastWith,\n    bound: bound,\n    defaults: defaults,\n    args: args,\n    curry: curry\n  });\n  \n  // # FOLDING\n  \n  var filter = binary( function filter (list, fn) {\n    fn = functionalize(fn);\n    \n    return __filter.call(list, fn);\n  });\n  \n  var filterWith = flip(filter);\n  \n  var map = binary( function map (list, fn) {\n    fn = functionalize(fn);\n    var fnLength = fn.length;\n  \n    if (fnLength !== 1) {\n      fn = unary(fn);\n    }\n    return __map.call(list, fn);\n  });\n  \n  var mapWith = flip(map);\n\n  // turns any function into a recursive mapper\n  //\n  // deepMap(function (x) { return x * x })([1, [2, 3], 4])\n  //   //=> [1, [4, 9], 16]\n  function deepMap (fn) {\n    return function innerDeepMap (tree) {\n      return __map.call(tree, function (element) {\n        if (Array.isArray(element)) {\n          return innerSoak(element);\n        }\n        else return fn(element);\n      });\n    };\n  };\n  \n  var deepMap = binary( function (tree, fn) {\n    fn = functionalize(fn);\n    \n    return __map.call(tree, function (element) {\n      if (Array.isArray(element)) {\n        return deepMap(element, fn);\n      }\n      else return fn(element);\n    });\n  });\n  \n  var deepMapWith = flip(deepMap);\n  \n  extend(allong.es, {\n    map: map,\n    mapWith: mapWith,\n    filter: filter,\n    filterWith: filterWith,\n    deepMap: deepMap,\n    deepMapWith: deepMapWith\n  });\n  \n  // # DECORATORS\n\n  function maybe (fn) {\n    fn = functionalize(fn);\n    return function () {\n      var i;\n\n      if (arguments.length === 0) {\n        return\n      }\n      else {\n        for (i = 0; i < arguments.length; ++i) {\n          if (arguments[i] == null) return\n        }\n        return fn.apply(this, arguments)\n      }\n    }\n  }\n\n  function tap (value, fn) {\n    fn = functionalize(fn);\n\n    if (fn === void 0) {\n      return curried\n    }\n    else return curried(fn);\n\n    function curried (fn) {\n      if (typeof(fn) === 'function') {\n        fn(value)\n      }\n      return value\n    }\n  }\n\n  function fluent (fn) {\n    fn = functionalize(fn);\n    return function () {\n      fn.apply(this, arguments);\n      return this\n    }\n  }\n\n  // decorates a function to return its first argument\n  var returnFirst = function (fn) {\n    fn = functionalize(fn);\n    return function () {\n      fn.apply(this, arguments);\n      return arguments[0];\n    }\n  }\n\n  function tee (decoration) {\n    decoration = functionalize(decoration);\n    return function (fn) {\n      fn = functionalize(fn);\n      return compose(returnFirst(decoration), fn);\n    };\n  };\n\n  function once (fn) {\n    fn = functionalize(fn);\n    var done = false,\n        testAndSet;\n\n    if (!!fn.name) {\n      testAndSet = function () {\n        this[\"__once__\"] || (this[\"__once__\"] = {})\n        if (this[\"__once__\"][fn.name]) return true;\n        this[\"__once__\"][fn.name] = true;\n        return false\n      }\n    }\n    else  {\n      testAndSet = function (fn) {\n        if (done) return true;\n        done = true;\n        return false\n      }\n    }\n\n    return function () {\n      return testAndSet.call(this) ? void 0 : fn.apply(this, arguments)\n    }\n  }\n\n  function memoized (fn, keymaker) {\n    fn = functionalize(fn);\n    var lookupTable = {},\n        key,\n        value;\n\n    keymaker || (keymaker = function (args) {\n      return JSON.stringify(args)\n    });\n\n    return function () {\n      var key = keymaker.call(this, arguments);\n\n      return lookupTable[key] || (\n        lookupTable[key] = fn.apply(this, arguments)\n      )\n    }\n  };\n  \n  extend(allong.es, {\n    maybe: maybe,\n    tap: tap,\n    fluent: fluent,\n    returnFirst: returnFirst,\n    tee: tee,\n    once: once,\n    memoized: memoized\n  });\n  \n  // # MIXIN\n\n  function mixin (decoration) {\n    return function decorator () {\n      if (arguments[0] !== void 0) {\n        return decorator.call(arguments[0]);\n      }\n      else {\n        extend(this, decoration);\n        return this;\n      }\n    };\n  };\n\n  function classDecorator (decoration) {\n    return function (clazz) {\n      function Decorated  () {\n        var self = this instanceof Decorated\n                   ? this\n                   : new Decorated();\n\n        return clazz.apply(self, arguments);\n      };\n      Decorated.prototype = extend(new clazz(), decoration);\n      return Decorated;\n    };\n  };\n  \n  extend(allong.es, {\n    mixin: mixin,\n    classDecorator: classDecorator\n  });\n  \n  // # MORE\n\n  var unbind = function unbind (fn) {\n    fn = functionalize(fn);\n    return fn.unbound ? unbind(fn.unbound()) : fn\n  };\n\n  function bind (fn, context, force) {\n    fn = functionalize(fn);\n    var unbound, bound;\n\n    if (force) {\n      fn = unbind(fn)\n    }\n    bound = function () {\n      return fn.apply(context, arguments)\n    };\n    bound.unbound = function () {\n      return fn;\n    };\n\n    return bound;\n  }\n\n  function invoke (fn) {\n    fn = functionalize(fn);\n    var args = __slice.call(arguments, 1);\n\n    return function (instance) {\n      return fn.apply(instance, args)\n    }\n  };\n\n  function get (object, getName) {\n    if (getName == null) {\n      return function (getName) { return object[getName]; };\n    }\n    else return object[getName];\n  };\n\n  function getWith (getName, object) {\n    if (object == null) {\n      return function (object) { return object[getName]; };\n    }\n    else return object[getName];\n  };\n\n  var pluckWith = compose(mapWith, getWith),\n      pluck = flip(pluckWith);\n\n  // Send a message/invoke a method on the receiver.\n  // TODO: Think about what it has in common with callLeft\n  var send = variadic( function (methodName, args) {\n    return variadic( function (receiver, remainingArgs) {\n      var fn = receiver[methodName];\n      return fn.apply(receiver, args.concat(remainingArgs))\n    })\n  });\n  \n  extend(allong.es, {\n    bind: bind,\n    unbind: unbind,\n    invoke: invoke,\n    get: get,\n    getWith: getWith,\n    send: send,\n    pluckWith: pluckWith,\n    pluck: pluck\n  });\n  \n  // # TRAMPOLINE\n      \n  function Thunk (closure) {\n    if (!(this instanceof Thunk))\n      return new Thunk(closure);\n    \n    this.closure = closure;\n  };\n  \n  Thunk.prototype.force = function () {\n    return this.closure();\n  };\n      \n  function trampoline (fn) {\n    var trampolined = variadic( function (args) {\n      var result = fn.apply(this, args);\n      \n      while (result instanceof Thunk) {\n        result = result.force();\n      }\n      \n      return result;\n    });\n    trampolined.__trampolined_fn = fn;\n    return trampolined;\n  };\n  \n  var tailCall = variadic( function (fn, args) {\n    var context = this;\n    if (fn.__trampolined_fn instanceof Function) {\n      return new Thunk( function () { \n        return fn.__trampolined_fn.apply(context, args);\n      });\n    }\n    else return new Thunk( function () { \n      return fn.apply(context, args);\n    });\n  });\n  \n  extend(allong.es, {\n    trampoline: trampoline,\n    tailCall: tailCall,\n    Thunk: Thunk\n  });\n  \n  // # ITERATORS\n  \n  (function (allong) {\n      \n    function fold (iter, binaryFn, seed) {\n      var state, element;\n      binaryFn = functionalize(binaryFn);\n      if (seed !== void 0) {\n        state = seed;\n      }\n      else {\n        state = iter();\n      }\n      element = iter();\n      while (element != null) {\n        state = binaryFn.call(element, state, element);\n        element = iter();\n      }\n      return state;\n    };\n  \n    var HASNTBEENRUN = {};\n  \n    function unfold (seed, unaryFn) {\n      var state = HASNTBEENRUN;\n      unaryFn = functionalize(unaryFn);\n      return function () {\n        if (state === HASNTBEENRUN) {\n          return (state = seed);\n        }\n        else if (state != null) {\n          return (state = unaryFn.call(state, state));\n        }\n        else return state;\n      };\n    };\n  \n    // note that the unfoldWithReturn behaves differently than\n    // unfold with respect to the first value returned\n    function unfoldWithReturn (seed, unaryFn) {\n      var state = seed,\n          pair,\n          value;\n      unaryFn = functionalize(unaryFn);\n      return function () {\n        if (state != null) {\n          pair = unaryFn.call(state, state);\n          value = pair[1];\n          state = value != null\n                  ? pair[0]\n                  : void 0\n          return value;\n        }\n        else return void 0;\n      };\n    };\n\n    function accumulate (iter, binaryFn, initial) {\n      var state = initial;\n      binaryFn = functionalize(binaryFn);\n      return function () {\n        element = iter();\n        if (element == null) {\n          return element;\n        }\n        else {\n          if (state === void 0) {\n            return (state = element);\n          }\n          else return (state = binaryFn.call(element, state, element));\n        }\n      }\n    };\n  \n    function accumulateWithReturn (iter, binaryFn, initial) {\n      var state = initial,\n          stateAndReturnValue;\n      binaryFn = functionalize(binaryFn);\n      return function () {\n        element = iter();\n        if (element == null) {\n          return element;\n        }\n        else {\n          if (state === void 0) {\n            return (state = element);\n          }\n          else {\n            stateAndReturnValue = binaryFn.call(element, state, element);\n            state = stateAndReturnValue[0];\n            return stateAndReturnValue[1];\n          }\n        }\n      }\n    };\n  \n    function map (iter, unaryFn) {\n      unaryFn = functionalize(unaryFn);\n      return function() {\n        var element;\n        element = iter();\n        if (element != null) {\n          return unaryFn.call(element, element);\n        } else {\n          return void 0;\n        }\n      };\n    };\n\n    function select (iter, unaryPredicateFn) {\n      unaryPredicateFn = functionalize(unaryPredicateFn);\n      return function() {\n        var element;\n        element = iter();\n        while (element != null) {\n          if (unaryPredicateFn.call(element, element)) {\n            return element;\n          }\n          element = iter();\n        }\n        return void 0;\n      };\n    };\n  \n    function reject (iter, unaryPredicateFn) {\n      unaryPredicateFn = functionalize(unaryPredicateFn);\n      return select(iter, function (something) {\n        return !unaryPredicateFn(something);\n      });\n    };\n  \n    function find (iter, unaryPredicateFn) {\n      unaryPredicateFn = functionalize(unaryPredicateFn);\n      return select(iter, unaryPredicateFn)();\n    }\n\n    function slice (iter, numberToDrop, numberToTake) {\n      var count = 0;\n      while (numberToDrop-- > 0) {\n        iter();\n      }\n      if (numberToTake != null) {\n        return function() {\n          if (++count <= numberToTake) {\n            return iter();\n          } else {\n            return void 0;\n          }\n        };\n      }\n      else return iter;\n    };\n  \n    var drop = defaults(binary(slice), 1);\n  \n    function take (iter, numberToTake) {\n      return slice(iter, 0, numberToTake == null ? 1 : numberToTake);\n    }\n\n    function FlatArrayIterator (array) {\n      var index = 0;\n      return function() {\n        return array[index++];\n      };\n    };\n  \n    function RecursiveArrayIterator (array) {\n      var index, myself, state;\n      index = 0;\n      state = [];\n      myself = function() {\n        var element, tempState;\n        element = array[index++];\n        if (element instanceof Array) {\n          state.push({\n            array: array,\n            index: index\n          });\n          array = element;\n          index = 0;\n          return myself();\n        } else if (element === void 0) {\n          if (state.length > 0) {\n            tempState = state.pop(), array = tempState.array, index = tempState.index;\n            return myself();\n          } else {\n            return void 0;\n          }\n        } else {\n          return element;\n        }\n      };\n      return myself;\n    };\n  \n    function K (value) {\n      return function () {\n        return value;\n      };\n    };\n\n    function upRange (from, to, by) {\n      return function () {\n        var was;\n      \n        if (from > to) {\n          return void 0;\n        }\n        else {\n          was = from;\n          from = from + by;\n          return was;\n        }\n      }\n    };\n\n    function downRange (from, to, by) {\n      return function () {\n        var was;\n      \n        if (from < to) {\n          return void 0;\n        }\n        else {\n          was = from;\n          from = from - by;\n          return was;\n        }\n      }\n    };\n  \n    function range (from, to, by) {\n      if (from == null) {\n        return upRange(1, Infinity, 1);\n      }\n      else if (to == null) {\n        return upRange(from, Infinity, 1);\n      }\n      else if (by == null) {\n        if (from <= to) {\n          return upRange(from, to, 1);\n        }\n        else return downRange(from, to, 1)\n      }\n      else if (by > 0) {\n        return upRange(from, to, by);\n      }\n      else if (by < 0) {\n        return downRange(from, to, Math.abs(by))\n      }\n      else return k(from);\n    };\n  \n    var numbers = unary(range);\n\n    extend(allong.es, { iterators: {\n      accumulate: accumulate,\n      accumulateWithReturn: accumulateWithReturn,\n      fold: fold,\n      unfold: unfold,\n      unfoldWithReturn: unfoldWithReturn,\n      map: map,\n      select: select,\n      reject: reject,\n      filter: select,\n      find: find,\n      slice: slice,\n      drop: drop,\n      take: take,\n      FlatArrayIterator: FlatArrayIterator,\n      RecursiveArrayIterator: RecursiveArrayIterator,\n      constant: K,\n      K: K,\n      numbers: numbers,\n      range: range\n    }});\n  \n  })(allong);\n  \n  // Monadic Sequencing\n  // ------------------\n  \n  //    sequence(a, b, c)\n  //      //=> function (x) {\n  //        return c(b(a(x)))\n  //      }\n  var sequence = callFlipped(compose);\n\n  var Promise = require('promise');\n\n  var Supervisor = (function() {\n\n    function Supervisor(methods) {\n      var body, name;\n      for (name in methods) {\n        if (!__hasProp.call(methods, name)) continue;\n        body = methods[name];\n        this[name] = body;\n      }\n      this.of || (this.of = function(value) {\n        return value;\n      });\n      this.map || (this.map = function(fn) {\n        return fn;\n      });\n      this.chain || (this.chain = function(mValue, fn) {\n        return this.map(fn)(mValue);\n      });\n      for (name in this) {\n        if (!__hasProp.call(this, name)) continue;\n        body = this[name];\n        this[name] = body.bind(this);\n      }\n    }\n\n    return Supervisor;\n\n  })();\n\n  Supervisor.Identity = new Supervisor();\n\n  Supervisor.Maybe = new Supervisor({\n    map: function(fn) {\n      return function(mValue) {\n        if (mValue === null || mValue === void 0) {\n          return mValue;\n        } else {\n          return fn(mValue);\n        }\n      };\n    }\n  });\n\n  Supervisor.Writer = new Supervisor({\n    of: function(value) {\n      return [value, ''];\n    },\n    map: function(fn) {\n      return function(_arg) {\n        var newlyWritten, result, value, writtenSoFar, _ref;\n        value = _arg[0], writtenSoFar = _arg[1];\n        _ref = fn(value), result = _ref[0], newlyWritten = _ref[1];\n        return [result, writtenSoFar + newlyWritten];\n      };\n    }\n  });\n\n  Supervisor.List = new Supervisor({\n    of: function(value) {\n      return [value];\n    },\n    join: function(mValue) {\n      return mValue.reduce(this.concat, this.zero());\n    },\n    map: function(fn) {\n      return function(mValue) {\n        return mValue.map(fn);\n      };\n    },\n    zero: function() {\n      return [];\n    },\n    concat: function(ma, mb) {\n      return ma.concat(mb);\n    },\n    chain: function(mValue, fn) {\n      return this.join(this.map(fn)(mValue));\n    }\n  });\n\n  Supervisor.Promise = new Supervisor({\n    of: function(value) {\n      return new Promise(function(resolve, reject) {\n        return resolve(value);\n      });\n    },\n    map: function(fnReturningAPromise) {\n      return function(promiseIn) {\n        return new Promise(function(resolvePromiseOut, rejectPromiseOut) {\n          return promiseIn.then((function(value) {\n            return fnReturningAPromise(value).then(resolvePromiseOut, rejectPromiseOut);\n          }), rejectPromiseOut);\n        });\n      };\n    }\n  });\n\n  Supervisor.Callback = new Supervisor({\n    of: function(value) {\n      return function(callback) {\n        return callback(value);\n      };\n    },\n    map: function(fn) {\n      return function(value) {\n        return function(callback) {\n          return fn(value, callback);\n        };\n      };\n    },\n    chain: function(mValue, fn) {\n      var _this = this;\n      return function(callback) {\n        return mValue(function(value) {\n          return _this.map(fn)(value)(callback);\n        });\n      };\n    }\n  });\n\n  Supervisor.sequence = function() {\n    var args, fns, supervisor;\n    args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];\n    if (args[0] instanceof Supervisor) {\n      supervisor = args[0], fns = 2 <= args.length ? __slice.call(args, 1) : [];\n    } else {\n      supervisor = Supervisor.Identity;\n      fns = args;\n    }\n    return function() {\n      return fns.reduce(supervisor.chain, supervisor.of.apply(supervisor, arguments));\n    };\n  };\n\n  extend(allong.es, {\n    sequence: sequence,\n    Supervisor: Supervisor\n  });\n\n  // Exports and sundries\n  // --------------------\n\n  if (typeof exports !== 'undefined') {\n    if (typeof module !== 'undefined' && module.exports) {\n      exports = module.exports = allong;\n    }\n    exports.allong = allong;\n  } else {\n    root.allong = allong;\n  }\n  \n}).call(this);"
  },
  {
    "path": "_site/package.json",
    "content": "{\n  \"author\": \"Reg Braithwaite <raganwald@gmail.com> (http://braythwayt.com)\",\n  \"name\": \"allong.es\",\n  \"description\": \"Combinators and Function Decorators\",\n  \"version\": \"0.10.2\",\n  \"homepage\": \"http://allong.es\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/raganwald/allong.es.git\"\n  },\n  \"main\": \"lib/allong.es.js\",\n  \"scripts\": {\n    \"test\": \"jasmine-node --coffee --verbose spec\"\n  },\n  \"engines\": {\n    \"node\": \"\"\n  },\n  \"dependencies\": {\n    \"promise\": \"\"\n  },\n  \"devDependencies\": {\n    \"jasmine-node\": \"\",\n    \"coffee-script\": \"\",\n    \"grunt\": \"~0.4.1\",\n    \"grunt-contrib-uglify\": \"~0.2.0\"\n  }\n}\n"
  },
  {
    "path": "_site/release_notes.md",
    "content": "# Release Notes\n\n1. Currying is implicit\n2. \"With\" and \"This\" naming conventions, e.g. `pluckWith` is the should of `pluck`\n3. `splat` is now `mapWith`\n4. `applyLeft` and `applyFirst` are now `callLeft` and `callFirst`\n5. `curry` now falls out of `apply`/`applyLeft`!\n6. soak->deepMap"
  },
  {
    "path": "_site/spec/apply.spec.coffee",
    "content": "{ callRight, applyNow, callNow, applyNowFlipped, \n  call, applyLeftNow, callLeftNow, args, applyLeftNowWith,\n  applyRightNow, callRightNow, applyRightNowWith,\n  callFirst, callFirstWith, callLast, callLastWith, apply\n} = require('../lib/allong.es.js').allong.es\n\necho = (a, b, c) -> \"#{a} #{b} #{c}\"\n\nfive = (a, b, c, d, e) -> [a, b, c, d, e]\nthree = (a, b, c) -> [a, b, c]\ntwelve = (a, b, c, d, e, f, g, h, i, j, k, l) ->\nvari = (args...) -> args\none = (x) -> x\n\ndescribe \"apply\", ->\n  \n  it \"should apply an array of arguments to a function\", ->\n    expect( apply(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it \"should be curried\", ->\n    expect( apply(three)([1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it \"should  be self-currying, it should apply what it gets\", ->\n    expect( apply(three, [1, 2])(3) ).toEqual three(1, 2, 3)\n\ndescribe \"applyNow\", ->\n  \n  it \"should apply an array of arguments to a function\", ->\n    expect( applyNow(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it \"should not be self-currying, it should apply what it gets\", ->\n    expect( applyNow(three, [1, 2]) ).toEqual three(1, 2)\n    expect( applyNow(three, [1]) ).toEqual three(1)\n    \n  it \"should be curried\", ->\n    expect( applyNow(three)([1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  describe \"when flipped\", ->\n    \n    it \"should apply an array of arguments to a function\", ->\n      expect( applyNowFlipped([1, 2, 3], three) ).toEqual three(1, 2, 3)\n\n    it \"should be curried\", ->\n      expect( applyNowFlipped([1, 2, 3])(three) ).toEqual three(1, 2, 3)\n\ndescribe \"callNow\", ->\n  \n  it \"should apply arguments to a function\", ->\n    expect( callNow(three, 1, 2, 3) ).toEqual three(1, 2, 3)\n    \n  it \"should not be self-currying, it should apply what it gets\", ->\n    expect( callNow(three, 1, 2) ).toEqual three(1, 2)\n    expect( callNow(three, 1) ).toEqual three(1)\n    \n  it \"should not be curried\", ->\n    expect( callNow(three) ).toEqual three()\n    \n  # variadic functions do not have a 'this' predefined at this point.\n    \ndescribe \"applyLeftNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( applyLeftNow(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( applyLeftNow(three, [1, 2]) ).not.toEqual three(1, 2)\n    expect( applyLeftNow(three, [1, 2])(3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be fully curried', ->\n    expect( applyLeftNow(three, [1])(2) ).toEqual three(1, 2)\n    \n  describe \"when flipped\", ->\n  \n    it 'should apply all the arguments if possible', ->\n      expect( applyLeftNowWith([1, 2, 3], three) ).toEqual three(1, 2, 3)\n    \n    it 'should not be full application', ->\n      expect( applyLeftNowWith([1, 2], three) ).not.toEqual three(1, 2)\n      expect( applyLeftNowWith([1, 2], three)(3) ).toEqual three(1, 2, 3)\n    \n    it 'should not be fully curried', ->\n      expect( applyLeftNowWith([1], three)(2) ).toEqual three(1, 2)\n    \ndescribe \"callLeftNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( callLeftNow(three, 1, 2, 3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( callLeftNow(three, 1, 2) ).not.toEqual three(1, 2)\n    expect( callLeftNow(three, 1, 2)(3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be fully curried', ->\n    expect( callLeftNow(three, 1)(2) ).toEqual three(1, 2)\n\ndescribe \"applyRightNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( applyRightNow(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( applyRightNow(three, [1, 2]) ).not.toEqual three(1, 2)\n    expect( applyRightNow(three, [1, 2])(3) ).toEqual three(3, 1, 2)\n    \n  it 'should not be fully curried', ->\n    expect( applyRightNow(three, [1])(2) ).toEqual three(2, 1)\n    \n  describe \"when flipped\", ->\n  \n    it 'should apply all the arguments if possible', ->\n      expect( applyRightNowWith([1, 2, 3], three) ).toEqual three(1, 2, 3)\n    \n    it 'should not be full application', ->\n      expect( applyRightNowWith([1, 2], three) ).not.toEqual three(1, 2)\n      expect( applyRightNowWith([1, 2], three)(3) ).toEqual three(3, 1, 2)\n    \n    it 'should not be fully curried', ->\n      expect( applyRightNowWith([1], three)(2) ).toEqual three(2, 1)\n    \ndescribe \"callRightNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( callRightNow(three, 1, 2, 3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( callRightNow(three, 1, 2) ).not.toEqual three(1, 2)\n    expect( callRightNow(three, 1, 2)(3) ).toEqual three(3, 1, 2)\n    \n  it 'should not be fully curried', ->\n    expect( callRightNow(three, 1)(2) ).toEqual three(2, 1)\n    \n################################\n\ndescribe \"call\", ->\n  \n  it \"should call an array of arguments to a function\", ->\n    expect( call(echo, 1, 2, 3) ).toEqual \"1 2 3\"\n  \n  it \"should have a curried nature\", ->\n    expect( call(five)(1, 2, 3, 4, 5) ).toEqual [1..5]\n    expect( call(five)(1, 2, 3)(4, 5) ).toEqual [1..5]\n    expect( call(five, 1, 2, 3)(4, 5) ).toEqual [1..5]\n    expect( call(five, 1, 2, 3)(4)(5) ).toEqual [1..5]\n    \n  it \"should get the arity right for small amounts\", ->\n    expect( call(five, 1, 2).length ).toEqual 3\n\ndescribe \"callRight\", ->\n  \n  it \"should call an array of arguments to a function\", ->\n    expect( callRight(echo, 1, 2, 3) ).toEqual \"1 2 3\"\n  \n  it \"should have a curried nature\", ->\n    expect( callRight(five)(1, 2, 3, 4, 5) ).toEqual [1..5]\n    expect( callRight(five)(1, 2, 3)(4, 5) ).toEqual [1..5]\n    \n  it \"should apply given arguments to the right\", ->\n    expect( callRight(five, 1)(2, 3, 4, 5) ).toEqual [2, 3, 4, 5, 1]\n    expect( callRight(five, 1, 2)(3, 4, 5) ).toEqual [3, 4, 5, 1, 2]\n    expect( callRight(five, 1, 2, 3)(4, 5) ).toEqual [4, 5, 1, 2, 3]\n    expect( callRight(five, 1, 2, 3, 4)(5) ).toEqual [5, 1, 2, 3, 4]\n    expect( callRight(five, 1, 2, 3)(4, 5) ).toEqual [4, 5, 1, 2, 3]\n    expect( callRight(five, 1, 2, 3)(4)(5) ).toEqual [4, 5, 1, 2, 3]\n    \n  it \"should get the arity right for small amounts\", ->\n    expect( callRight(five, 1, 2).length ).toEqual 3\n    \ndescribe 'callFirst', ->\n  \n  it 'should call with the first argument', ->\n    expect( callFirst(three, 1)(2, 3) ).toEqual [1..3]\n    \n  it 'should get the arity right', ->\n    expect( callFirst.length ).toEqual 2\n    expect( callFirst(three, 1).length ).toEqual 2\n    \n  it 'should be curried', ->\n    expect( callFirst(three)(1)(2, 3) ).toEqual [1..3]\n    \ndescribe 'callFirstWith', ->\n  \n  it 'should call with the first argument', ->\n    expect( callFirstWith(1, three)(2, 3) ).toEqual [1..3]\n    \n  it 'should get the arity right', ->\n    expect( callFirstWith.length ).toEqual 2\n    expect( callFirstWith(1, three).length ).toEqual 2\n    \n  it 'should be curried', ->\n    expect( callFirstWith(1)(three)(2, 3) ).toEqual [1..3]\n    \ndescribe \"args\", ->\n  \n  it \"should collect arguments into an array\", ->\n    expect( args(3)(1, 2, 3) ).toEqual [1, 2, 3]"
  },
  {
    "path": "_site/spec/arity.spec.coffee",
    "content": "{unvariadic, variadic, curry} = require('../lib/allong.es.js').allong.es\n\nnumberOfArgs = -> arguments.length\nthreeArguments = (a, b, c) -> arguments.length\n\ndescribe \"unvariadic\", ->\n  \n  it \"should clip arguments\", ->\n    expect( unvariadic(3, numberOfArgs)(1, 2, 3, 4, 5) ).toEqual threeArguments(1, 2, 3, 4, 5)\n    \n  it \"shouldn't pad arguments\", ->\n    expect( unvariadic(3, numberOfArgs)(1) ).toEqual threeArguments(1)\n    \ndescribe \"variadic\", ->\n  \n  describe \"with an arity\", ->\n    \n    one = (args) -> [args]\n    \n    two = (arg, args) -> [arg, args]\n    \n    onev = (args...) -> [args]\n    \n    twov = (arg, args...) -> [arg, args]\n    \n    it 'should 1', ->\n      expect( variadic(1, one)(1, 2, 3) ).toEqual onev(1, 2, 3)\n    \n    it 'should 2', ->\n      expect( variadic(1, one).length ).toEqual 1\n    \n    it 'should 3', ->\n      expect( variadic(2, one).length ).toEqual 2\n\ndescribe \"curry\", ->\n  \n  three = (a, b, c) -> [a, b, c]\n  \n  it \"should be a function that returns a function\", ->\n    expect( curry instanceof Function).toEqual true\n    expect( curry(three) instanceof Function).toEqual true\n  \n  it \"should allow a full invocation\", ->\n    expect( curry(three)(1, 2, 3) ).toEqual [1, 2, 3]\n  \n  it \"should allow partial invocation\", ->\n    expect( curry(three)(1)(2, 3) ).toEqual [1, 2, 3]\n    expect( curry(three)()(1, 2, 3) ).toEqual [1, 2, 3]\n    expect( curry(three)(1)(2)(3) ).toEqual [1, 2, 3]\n    expect( curry(three)(1, 2)(3) ).toEqual [1, 2, 3]\n    \n    # describe \"self-currying\", ->\n    #   \n    #   it \"shouldn't affect normal useage\", ->\n    #     expect(selfCurrying(three)(4, 5, 6)).toEqual three(4, 5, 6)\n    #     expect(selfCurrying(three)(4, 5)).toEqual three(4, 5)\n    #     expect(selfCurrying(three)(4)).toEqual three(4)\n    #   \n    #   it \"should curry with no arguments\", ->\n    # expect( selfCurrying(three)()(1)(2, 3) ).toEqual [1, 2, 3]\n    # expect( selfCurrying(three)()()(1, 2, 3) ).toEqual [1, 2, 3]\n    # expect( selfCurrying(three)()(1)(2)(3) ).toEqual [1, 2, 3]\n    # expect( selfCurrying(three)()(1, 2)(3) ).toEqual [1, 2, 3]\n"
  },
  {
    "path": "_site/spec/basic.spec.coffee",
    "content": "{Sequence, Sequence: {sequence}} = require('../lib/allong.es.js').allong.es\n\ndouble = (n) -> n + n\nplusOne = (n) -> n + 1\n  \ndescribe \"sequence\", ->\n\n  it \"should be a thing\", ->\n    expect( sequence ).not.toBeNull()\n    \n  it \"should return a function when given a function\", ->\n    expect( sequence(double) ).not.toBeNull()\n  \n  it \"should sequence a single function\", ->\n    expect( sequence(double)(3) ).toEqual 6\n  \n  it \"should sequence two functions\", ->\n    expect( sequence(double, plusOne)(3) ).toEqual 7\n    \ndescribe \"Identity\", ->\n  \n  it \"should sequence a single function\", ->\n    expect( sequence(Sequence.Identity, double)(3) ).toEqual 6\n  \n  it \"should sequence two functions\", ->\n    expect( sequence(Sequence.Identity, double, plusOne)(3) ).toEqual 7\n    \ndescribe \"Maybe\", ->\n  \n  it \"should pass numbers through\", ->\n    expect( sequence(Sequence.Maybe, double, plusOne)(3) ).toEqual 7\n  \n  it \"should pass null through\", ->\n    expect( sequence(Sequence.Maybe, double, plusOne)(null) ).toBeNull()\n  \n  it \"should pass undefined through\", ->\n    expect( sequence(Sequence.Maybe, double, plusOne)(undefined) ).toBeUndefined()\n    \n  it \"should short-circuit\", ->\n    expect( sequence(Sequence.Maybe, double, ((x) ->), plusOne)(undefined) ).toBeUndefined()\n      \ndescribe \"Writer\", ->\n  \n  parity = (n) ->\n    [\n      n\n      if n % 2 is 0 then 'even' else 'odd'\n    ]\n    \n  space = (n) ->\n    [\n      n\n      ' '\n    ]\n    \n  size = (n) ->\n    [\n      n\n      if n < 10 then 'small' else 'normal'\n    ]\n  \n  it \"should accumulate writes\", ->\n    expect( sequence(Sequence.Writer, parity, space, size)(5) ).toEqual [5, 'odd small']\n    \ndescribe 'List', ->\n  \n  oneToN = (n) ->\n    [1..n]\n  \n  nToOne = (n) ->\n    [n..1]\n    \n  it \"should handle two levels of lists\", ->\n    expect( sequence(Sequence.List, oneToN, nToOne)(3) ).toEqual [1, 2, 1, 3, 2, 1]\n      "
  },
  {
    "path": "_site/spec/callbacks.spec.coffee",
    "content": "{Sequence, Sequence: {do}} = require('../lib/allong.es.js').allong.es\n\ndouble = (v, c) -> c(v * 2)\nplus1 = (v, c) -> c(v + 1)\nidentity = (v) -> v\n\ndescribe \"continuation\", ->\n  \n  it \"should work for the null do\", ->\n    \n    expect( do(Sequence.Callback)(42)(identity) ).toBe 42\n  \n  it \"should work for a double\", ->\n    \n    expect( do(Sequence.Callback, double)(42)(identity) ).toBe 84\n  \n  it \"should work for a double double\", ->\n    \n    expect( do(Sequence.Callback, double, double)(2)(identity) ).toBe 8\n  \n  it \"should work for a double plus1 double\", ->\n    \n    expect( do(Sequence.Callback, double, plus1, double)(2)(identity) ).toBe 10"
  },
  {
    "path": "_site/spec/core.spec.coffee",
    "content": "# unary, binary, ternary, variadic, compose, sequence???\n{defaults, mapWith, getWith, filterWith, compose, sequence, variadic, flip, curry} = require('../lib/allong.es.js').allong.es\n\necho = (a, b, c) -> \"#{a} #{b} #{c}\"\nparenthesize = (a) -> \"(#{a})\"\nsquare = (n) -> n * n\noddP = (n) -> !!(n % 2)\n\ndescribe \"defaults\", ->\n  \n  it \"should default values\", ->\n    expect( defaults(echo, 'c')('a', 'b') ).toEqual 'a b c'\n    expect( defaults(echo, 'b', 'c')('a') ).toEqual 'a b c'\n    expect( defaults(echo, 'a', 'b', 'c')() ).toEqual 'a b c'\n  \n  it \"should ignore uneccesary defaults\", ->\n    expect( defaults(echo, 'a', 'b', 'c')('A') ).toEqual 'A b c'\n    expect( defaults(echo, 'a', 'b', 'c')('A', 'B') ).toEqual 'A B c'\n    expect( defaults(echo, 'a', 'b', 'c')('A', 'B', 'C') ).toEqual 'A B C'\n    expect( defaults(echo, 'a', 'b', 'c')('A', 'B', 'C', 'D') ).toEqual 'A B C'\n    \ndescribe \"mapWith\", ->\n  \n  it \"should map backwards\", ->\n    expect( mapWith(square, [1..5]) ).toEqual [1, 4, 9, 16, 25]\n  \n  it \"should map backwards, curried\", ->\n    expect( mapWith(square)([1..5]) ).toEqual [1, 4, 9, 16, 25]\n    \ndescribe \"filterWith\", ->\n  \n  it \"should filter backwards\", ->\n    expect( filterWith(oddP, [1..5]) ).toEqual [1, 3, 5]\n  \n  it \"should filter backwards, curried\", ->\n    expect( filterWith(oddP)([1..5]) ).toEqual [1, 3, 5]\n\ndescribe \"compose\", ->\n  \n  it \"should compose two functions\", ->\n    expect( compose(parenthesize, parenthesize)('hello') ).toEqual '((hello))'\n  \n  it \"should respect the arity of the first function\", ->\n    expect( compose(parenthesize, parenthesize).length ).toEqual 1\n    expect( compose(echo, parenthesize).length ).toEqual 3\n    \n  it \"should handle a common use case, pluckWith\", ->\n    myPluckWith = compose mapWith, getWith\n    expect( myPluckWith('name')([{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n    expect( myPluckWith('name', [{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n\ndescribe \"sequence\", ->\n  \n  it \"should sequence two functions\", ->\n    expect( sequence(parenthesize, parenthesize)('hello') ).toEqual '((hello))'\n  \n  it \"should respect the arity of the first function\", ->\n    expect( sequence(parenthesize, parenthesize).length ).toEqual 1\n    expect( sequence(parenthesize, echo).length ).toEqual 3\n    \n  it \"should handle a common use case, pluckWith\", ->\n    myPluckWith = sequence getWith, mapWith\n    expect( myPluckWith('name')([{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n    expect( myPluckWith('name', [{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n  \ndescribe \"flip\", ->\n  \n  a = (a) -> [a]\n  b = (a, b) -> [a, b]\n  c = (a, b, c) -> [a, b, c]\n  d = (a, b, c, d) -> [a, b, c, d]\n  v = variadic( (x) -> x )\n  \n  it \"should flip a unary function\", ->\n    expect( flip(a)(1) ).toEqual [1]\n    \n  it \"should flip a binary function\", ->\n    expect( flip(b)(1, 2) ).toEqual [2, 1]\n    \n  it \"should flip a ternary function\", ->\n    expect( flip(c)(1, 2, 3) ).toEqual [3, 2, 1]\n    \n  it \"should flip a quaternary function\", ->\n    expect( flip(d)(1, 2, 3, 4) ).toEqual [4, 3, 2, 1]\n    \n  it \"should flip a variadic function\", ->\n    expect( flip(v)(1, 2, 3, 4, 5) ).toEqual [5, 4, 3, 2, 1]\n    \n  it \"should respect arities\", ->\n    expect( flip(v).length ).toEqual v.length\n    expect( flip(a).length ).toEqual a.length\n    expect( flip(b).length ).toEqual b.length\n    expect( flip(c).length ).toEqual c.length\n    \n    # expect( flip(d).length ).toEqual d.length\n    # NO; We do not guarantee arity for length > 3\n    \n  it 'should be self-currying', ->\n    expect( flip(b)(1)(2) ).toEqual [2, 1]\n    expect( flip(c)(1)(2)(3) ).toEqual [3, 2, 1]\n    expect( flip(d)(1)(2)(3)(4) ).toEqual [4, 3, 2, 1]"
  },
  {
    "path": "_site/spec/decorating-classes.spec.coffee",
    "content": "{classDecorator, mixin, fluent} = require('../lib/allong.es.js').allong.es\n\nclass Todo\n  constructor: (name) ->\n    self = if this instanceof Todo\n             this\n           else\n             new Todo()\n    self.name = name or 'Untitled'\n    self.done = false\n  do: fluent -> this.done = true\n  undo: fluent -> this.done = false\n  \ndescribe \"features\", ->\n  it \"should include mixin\", ->\n    expect(typeof mixin).toEqual 'function'\n  it \"should include classDecorator\", ->\n    expect(typeof classDecorator).toEqual 'function'\n\ndescribe \"classDecorator\", ->\n\n  AndColourCoded = classDecorator\n    setColourRGB: (r, g, b) ->\n      @colourCode = { r, g, b }\n      this\n    getColourRGB: -> @colourCode\n\n  ColourTodo = AndColourCoded Todo\n\n  todo = new ColourTodo('Use More Decorators')\n        .setColourRGB(0, 255, 0)\n\n  it \"should set the name correctly\", ->\n    expect( todo.name ).toEqual \"Use More Decorators\"\n\n  it \"should set the colour code correctly\", ->\n    expect( todo.getColourRGB() ).toEqual\n      r: 0\n      g: 255\n      b: 0\n\ndescribe \"mixin\", ->\n\n  LocationAware = mixin\n    setLocation: (@location) -> this\n    getLocation: -> @location\n    \n  describe \"Using context\", ->\n\n    it \"should add location to the existing class's prototype\", ->\n      LocationAware.call(Todo.prototype)\n      expect( typeof Todo.prototype.setLocation ).toEqual 'function'\n      expect( typeof Todo.prototype.getLocation ).toEqual 'function'\n      \n  describe \"Using a parameter\", ->\n    \n    a = { a: 'a' }\n    b = { b: 'b' }\n    c = { c: 'b' }\n    \n    it \"should not add the location to the context\", ->\n      LocationAware.call(a, b)\n      expect( a.setLocation ).toBeUndefined()\n      expect( a.getLocation ).toBeUndefined()\n      expect( typeof b.setLocation ).toEqual 'function'\n      expect( typeof b.getLocation ).toEqual 'function'\n      \n    it \"should add the location when called normally\", ->\n      LocationAware(c)\n      expect( typeof c.setLocation ).toEqual 'function'\n      expect( typeof c.getLocation ).toEqual 'function'\n    "
  },
  {
    "path": "_site/spec/folding.spec.coffee",
    "content": "{mapWith, deepMapWith, filter} = require('../lib/allong.es.js').allong.es\n\nsquare = (n) -> n * n\n\ndescribe 'mapWith', ->\n  \n  it 'should square some numbers', ->\n    \n    expect( mapWith(square)([1..5]) ).toEqual [1, 4, 9, 16, 25]\n\ndescribe 'deepMapWith', ->\n  \n  it 'should square some numbers', ->\n    \n    expect( deepMapWith(square)([1, [2..4], 5]) ).toEqual [1, [4, 9, 16], 25]\n    \ndescribe \"filter\", ->\n  \n  it \"should find odd numbers\", ->\n    \n    expect( filter([1, 2, 3, 4, 5, 6], '% 2 === 1') ).toEqual [1, 3, 5]\n  \n  it \"should be self-currying\", ->\n    \n    expect( filter([1, 2, 3, 4, 5, 6])('% 2 === 0') ).toEqual [2, 4, 6]"
  },
  {
    "path": "_site/spec/iterators.spec.coffee",
    "content": "{iterators: {slice, drop, take, accumulate, accumulateWithReturn, \n             fold, map, filter, FlatArrayIterator, RecursiveArrayIterator,\n             unfold, unfoldWithReturn}} = require('../lib/allong.es.js').allong.es\n\ndescribe \"FlatArrayIterator\", ->\n  \n  it \"should iterate over a flat array\", ->\n    i = FlatArrayIterator([1, 2, 3, 4, 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).toEqual(2)\n    expect( i() ).toEqual(3)\n    expect( i() ).toEqual(4)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n    \n  it \"should not iterate down through an array\", ->\n    i = FlatArrayIterator([1, [2, 3, [4]], 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).not.toEqual(2)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n  \n  it \"should have no values given an empty array\", ->\n    i = FlatArrayIterator([])\n    expect( i() ).toBeUndefined()\n  \n  it \"should have a values given an empty tree\", ->\n    i = FlatArrayIterator([[], [[]]])\n    expect( i() ).not.toBeUndefined()\n\ndescribe \"RecursiveArrayIterator\", ->\n  \n  it \"should have no values given an empty array\", ->\n    i = RecursiveArrayIterator([])\n    expect( i() ).toBeUndefined()\n  \n  it \"should have no values given an empty tree\", ->\n    i = RecursiveArrayIterator([[], [[]]])\n    expect( i() ).toBeUndefined()\n  \n  it \"should iterate over a flat array\", ->\n    i = RecursiveArrayIterator([1, 2, 3, 4, 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).toEqual(2)\n    expect( i() ).toEqual(3)\n    expect( i() ).toEqual(4)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n    \n  it \"should also iterate down through an array\", ->\n    i = RecursiveArrayIterator([1, [2, 3, [4]], 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).toEqual(2)\n    expect( i() ).toEqual(3)\n    expect( i() ).toEqual(4)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n\nsum = (x, y) -> x + y\n\ndescribe \"fold\", ->\n  \n    describe \"with a seed\", ->\n  \n      it \"should fold an iterator with many elements\", ->\n        expect( fold(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum, 0) ).toEqual(15)\n  \n      it \"should fold an iterator with one element\", ->\n        expect( fold(RecursiveArrayIterator([[[4], []]]), sum, 42) ).toEqual(46)\n  \n      it \"should fold an empty iterator\", ->\n        expect( fold(RecursiveArrayIterator([[], [[]]]), sum, 42) ).toEqual(42)\n      \n    describe \"without a seed\", ->\n      \n      it \"should fold an array with two or more elements\", ->\n        expect( fold(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum) ).toEqual(15)\n      \n      it \"should fold an array with one element\", ->\n        expect( fold(RecursiveArrayIterator([[[4], []]]), sum) ).toEqual(4)\n      \n      it \"should fold an array with no elements\", ->\n        expect( fold(RecursiveArrayIterator([[[], []]]), sum) ).toBeUndefined()\n\ndescribe \"accumulate\", ->\n  \n    describe \"with a seed\", ->\n  \n      it \"should map an iterator with many elements\", ->\n        i = accumulate(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum, 0)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(3)\n        expect( i() ).toEqual(6)\n        expect( i() ).toEqual(10)\n        expect( i() ).toEqual(15)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an iterator with one element\", ->\n        i = accumulate(RecursiveArrayIterator([[[4], []]]), sum, 42)\n        expect( i() ).toEqual(46)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an empty iterator\", ->\n        i = accumulate(RecursiveArrayIterator([[[], []]]), sum, 42)\n        expect( i() ).toBeUndefined()\n      \n    describe \"without a seed\", ->\n  \n      it \"should map an iterator with many elements\", ->\n        i = accumulate(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(3)\n        expect( i() ).toEqual(6)\n        expect( i() ).toEqual(10)\n        expect( i() ).toEqual(15)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an iterator with one element\", ->\n        i = accumulate(RecursiveArrayIterator([[[4], []]]), sum)\n        expect( i() ).toEqual(4)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an empty iterator\", ->\n        i = accumulate(RecursiveArrayIterator([[[], []]]), sum)\n        expect( i() ).toBeUndefined()\n\nsquare = (x) -> x*x\n\ndescribe \"map\", ->\n  \n      it \"should map an iterator with many elements\", ->\n        i = map(RecursiveArrayIterator([1, [2, 3, [4]], 5]), square)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(4)\n        expect( i() ).toEqual(9)\n        expect( i() ).toEqual(16)\n        expect( i() ).toEqual(25)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an iterator with one element\", ->\n        i = map(RecursiveArrayIterator([[[4], []]]), square)\n        expect( i() ).toEqual(16)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an empty iterator\", ->\n        i = map(RecursiveArrayIterator([[[], []]]), square)\n        expect( i() ).toBeUndefined()\n\nodd = (x) -> x % 2 is 1\n\ndescribe \"filter\", ->\n  \n      it \"should filter an iterator with many elements\", ->\n        i = filter(RecursiveArrayIterator([1, [2, 3, [4]], 5]), odd)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(3)\n        expect( i() ).toEqual(5)\n        expect( i() ).toBeUndefined()\n  \n      it \"should filter an iterator with one element\", ->\n        i = filter(RecursiveArrayIterator([[[4], []]]), odd)\n        expect( i() ).toBeUndefined()\n  \n      it \"should filter an empty iterator\", ->\n        i = filter(RecursiveArrayIterator([[[], []]]), odd)\n        expect( i() ).toBeUndefined()\n  \n      it \"should filter an iterator with no matches\", ->\n        i = filter(FlatArrayIterator([2, 4, 6, 8, 10]), odd)\n        expect( i() ).toBeUndefined()\n\ndescribe \"slice\", ->\n  \n  describe \"with two parameter\", ->\n    \n    it \"should return an identity iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n    \n    it \"should return a trailing iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n      \n    it \"should return an empty iterator when out of range\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 5)\n      expect( i() ).toBeUndefined()\n  \n  describe \"with three parameters\", ->\n    \n    it \"should return an identity iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0, 5)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0, 99)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n    \n    it \"should return a leading iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0, 4)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toBeUndefined()\n    \n    it \"should return a trailing iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 4)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 99)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n    \n    it \"should return an inner iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 3)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toBeUndefined()\n      \n    it \"should return an empty iterator when given a zero length\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 0)\n      expect( i() ).toBeUndefined()\n      \n    it \"should return an empty iterator when out of range\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 5, 1)\n      expect( i() ).toBeUndefined()\n      \ndescribe \"drop\", ->\n  \n  it \"should drop the number of items dropped\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]), 2)\n    expect( i() ).toEqual 3\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 5\n    expect( i() ).toBeUndefined()\n  \n  it \"should handle overdropping\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]), 99)\n    expect( i() ).toBeUndefined()\n    \n  it \"should handle underdropping\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]), 0)\n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 2\n    expect( i() ).toEqual 3\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 5\n    expect( i() ).toBeUndefined()\n    \n  it \"should default to one\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]))\n    expect( i() ).toEqual 2\n    expect( i() ).toEqual 3\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 5\n    expect( i() ).toBeUndefined()\n    \ndescribe \"accumulateWithReturn\", ->\n  \n  it \"should pass the state and result in a pair\", ->\n    i = accumulateWithReturn(FlatArrayIterator([1, 2, 3, 4, 5]), (state, element) ->\n      [state + element, 'Total is ' + (state + element)]\n    , 0);\n    \n    expect( i() ).toEqual 'Total is 1'\n    expect( i() ).toEqual 'Total is 3'\n    expect( i() ).toEqual 'Total is 6'\n    expect( i() ).toEqual 'Total is 10'\n    expect( i() ).toEqual 'Total is 15'\n    \ndescribe \"unfold\", ->\n  \n  it \"should unfold and include the seed\", ->\n    i = unfold 0, (n) -> n + 1\n    \n    expect( i() ).toEqual 0\n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 2\n  \n  it \"should not unfold without a seed\", ->\n    i = unfold undefined, (n) -> n + 1\n    \n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n\ndescribe \"unfoldWithReturn\", ->\n  \n  it \"should unfold and throw off a value\", ->\n    i = unfoldWithReturn 1, (n) -> [n + 1, n*n]\n    \n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 9\n    expect( i() ).toEqual 16\n  \n  it \"should halt if it returns undefined\", ->\n    i = unfoldWithReturn 1, (n) ->\n      [n + 1, if n is 1 then undefined else n * n]\n    \n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n  \n  it \"should halt if the state becomes undefined\", ->\n    i = unfoldWithReturn 1, (n) ->\n      [(if n is 3 then undefined else n + 1), (if n is undefined then 100 else n * n)]\n    \n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 9\n    expect( i() ).toEqual undefined"
  },
  {
    "path": "_site/spec/promises.spec.coffee",
    "content": "Promise = require 'promise'\n{Sequence, Sequence: {do}} = require('../lib/allong.es.js').allong.es\n\ndescribe \"do\", ->\n    \n  double = (value) ->\n    new Promise (resolve, reject) ->\n      resolve(value * 2)\n      \n  success = undefined\n  failure = undefined\n      \n  beforeEach ->\n      \n    success = undefined\n    failure = undefined\n  \n  describe \"for a doubling promise\", ->\n  \n    it \"should work asynchronously\", (done) ->\n      \n      dodPromise = do(Sequence.Promise, double)(3)\n            \n      dodPromise.then ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done())\n            \n    afterEach ->    \n      expect( success ).toEqual 6\n      expect( failure ).toBeUndefined()\n  \n  describe \"for a double double\", ->\n  \n    it \"should work asynchronously\", (done) ->\n      \n      dodPromise = do(Sequence.Promise, double, double)(2)\n            \n      dodPromise.then ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done())\n            \n    afterEach ->    \n      expect( success ).toEqual 8\n      expect( failure ).toBeUndefined()\n  \n  describe \"for a double fail double\", ->\n  \n    it \"should fail forward\", (done) ->\n      \n      failer = (value) ->\n        new Promise (resolve, reject) ->\n          reject 'sorry, old chap'\n      \n      dodPromise = do(Sequence.Promise, double, failer, double)(2)\n            \n      dodPromise.then( ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done()))\n            \n    afterEach ->    \n      expect( success ).toBeUndefined()\n      expect( failure ).toBe 'sorry, old chap'\n      "
  },
  {
    "path": "_site/spec/trampoline.spec.coffee",
    "content": "{trampoline, tailCall} = require('../lib/allong.es.js').allong.es\n\ndescribe \"trampolining\", ->\n\n  depth = 32768\n\n  it \"should execute a clean even/odd to #{depth} levels\", ->\n  \n    even = trampoline (n) ->\n      if n is 0\n        true\n      else\n        tailCall odd, n - 1\n  \n    odd = trampoline (n) ->\n      if n is 0\n        false\n      else\n        tailCall even, n - 1\n  \n    expect( even(0) ).toEqual true\n    expect( even(1) ).toEqual false\n    expect( even(2) ).toEqual true\n    expect( even(3) ).toEqual false\n    expect(-> even(depth) ).not.toThrow()\n    \n  it \"should allow tail calling a co-recursive non-trampolined function too\", ->\n  \n    even2 = trampoline (n) ->\n      if n is 0\n        true\n      else\n        tailCall odd2, n - 1\n  \n    odd2 = (n) ->\n      if n is 0\n        false\n      else\n        even2 n - 1\n  \n    expect(-> even2(1000) ).not.toThrow()\n    expect( even2(100) ).toEqual true\n    expect( even2(101) ).toEqual false"
  },
  {
    "path": "hello/world.txt",
    "content": "Hello!"
  },
  {
    "path": "lib/allong.es.js",
    "content": "/*! http://github.com/raganwald/allong.es (c) 2012-2013 Reg Braithwaite MIT Licensed */\n(function (root) {\n  \n  // Setup\n  // -----\n\n  // Establish the root object, `window` in the browser, or `global` on the server.\n  // *taken from [Underscore.js](http://underscorejs.org/)*\n\n  var root = this;\n  \n  var __slice = Array.prototype.slice,\n      __map = Array.prototype.map,\n      __hasProp = Array.prototype.hasOwnProperty,\n      __filter = Array.prototype.filter;\n      \n  \n  // See: http://underscorejs.org/docs/underscore.html\n  var nativeIsArray = Array.isArray,\n      toString = Object.prototype.toString,\n      isArray = nativeIsArray || function(obj) {\n        return toString.call(obj) == '[object Array]';\n      },\n      isString = function (obj) { return toString.call(obj) == '[object String]'; },\n      isFunction = function (obj) { return toString.call(obj) == '[object Function]'; };\n      \n  if (typeof (/./) !== 'function') {\n    isFunction = function(obj) {\n      return typeof obj === 'function';\n    };\n  }\n  \n  \n  \n  // here's our export object\n  var allong = { es: {} };\n\n  // ## Functionalizing\n  //\n  // The utility functions operate on other functions. They can also operate on string\n  // abbreviations for functions by calling `functionalzie(...)` on their inputs.\n\n  // SHIM\n  if ('ab'.split(/a*/).length < 2) {\n    if (typeof console !== \"undefined\" && console !== null) {\n      console.log(\"Warning: IE6 split is not ECMAScript-compliant.  This breaks '->1'\");\n    }\n  }\n\n  // on the fence about whether to export this?\n  function to_function (str) {\n    var expr, leftSection, params, rightSection, sections, v, vars, _i, _len;\n    params = [];\n    expr = str;\n    sections = expr.split(/\\s*->\\s*/m);\n    if (sections.length > 1) {\n      while (sections.length) {\n        expr = sections.pop();\n        params = sections.pop().split(/\\s*,\\s*|\\s+/m);\n        sections.length && sections.push('(function(' + params + '){return (' + expr + ')})');\n      }\n    } else if (expr.match(/\\b_\\b/)) {\n      params = '_';\n    } else {\n      leftSection = expr.match(/^\\s*(?:[+*\\/%&|\\^\\.=<>]|!=)/m);\n      rightSection = expr.match(/[+\\-*\\/%&|\\^\\.=<>!]\\s*$/m);\n      if (leftSection || rightSection) {\n        if (leftSection) {\n          params.push('$1');\n          expr = '$1' + expr;\n        }\n        if (rightSection) {\n          params.push('$2');\n          expr = expr + '$2';\n        }\n      } else {\n        vars = str.replace(/(?:\\b[A-Z]|\\.[a-zA-Z_$])[a-zA-Z_$\\d]*|[a-zA-Z_$][a-zA-Z_$\\d]*\\s*:|this|arguments|'(?:[^'\\\\]|\\\\.)*'|\"(?:[^\"\\\\]|\\\\.)*\"/g, '').match(/([a-z_$][a-z_$\\d]*)/gi) || [];\n        for (_i = 0, _len = vars.length; _i < _len; _i++) {\n          v = vars[_i];\n          params.indexOf(v) >= 0 || params.push(v);\n        }\n      }\n    }\n    return new Function(params, 'return (' + expr + ')');\n  };\n\n  function functionalize (fn) {\n    if (typeof fn === 'function') {\n      return fn;\n    } else if (typeof fn === 'string' && /^[_a-zA-Z]\\w*$/.test(fn)) {\n      return function() {\n        var args, receiver, _ref;\n        receiver = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : [];\n        return (_ref = receiver[fn]).call.apply(_ref, [receiver].concat(__slice.call(args)));\n      };\n    } else if (typeof fn === 'string') {\n      return to_function(fn);\n    } else if (typeof fn.lambda === 'function') {\n      return fn.lambda();\n    } else if (typeof fn.toFunction === 'function') {\n      return fn.toFunction();\n    }\n  };\n\n  function extend () {\n    var consumer = arguments[0],\n        providers = __slice.call(arguments, 1),\n        key,\n        i,\n        provider,\n        except;\n\n    for (i = 0; i < providers.length; ++i) {\n      provider = providers[i];\n      except = provider['except'] || [];\n      except.push('except');\n      for (key in provider) {\n        if (except.indexOf(key) < 0 && provider.hasOwnProperty(key)) {\n          consumer[key] = provider[key];\n        };\n      };\n    };\n    return consumer;\n  };\n      \n  function rotate (array, n) {\n    var copy = array.slice(0),\n        i, \n        pull, \n        push;\n    \n    if (n !== 0) {\n      n || (n = 1);\n      if (n > 0) {\n        pull = 'shift';\n        push = 'push';\n      }\n      else {\n        n = -n;\n        pull = 'pop';\n        push = 'unshift'\n      }\n      for (i = 0; i < n; ++i) {\n        copy[push](copy[pull]());\n      }\n    }\n    \n    return copy;\n  };\n  \n  function reverse (array) {\n    return array.reduce(function (acc, element) {\n      acc.unshift(element);\n      return acc;\n    }, []);\n  };\n  \n  function flatten (array) {\n    var target = [];\n    \n    flattenOntoTarget(array);\n    \n    return target;\n    \n    function flattenOntoTarget (arr) {\n      arr.forEach(function (element) {\n        if (isArray(element)) {\n          flattenOntoTarget(element);\n        }\n        else target.push(element);\n      });\n    }\n  }\n  \n  extend(allong.es, {\n    flatten: flatten\n  })\n  \n  // # ARITY\n  \n  function invokeImmediately (fn) { return fn(); };\n\n  // ### \"Variadic\"\n  //\n  //    fn = variadic(function (args) { return args })\n  //\n  //    fn()        //=> []\n  //    fn(1)       //=> [1]\n  //    fn(1, 2)    //=> [1, 2]\n  //    fn(1, 2, 3) //=> [1, 2, 3]\n  //\n  //    fn = variadic(function (first, rest) { return [first, rest]})\n  //\n  //    fn()        //=> [undefined, []]\n  //    fn(1)       //=> [1, []]\n  //    fn(1, 2)    //=> [1, [2]]\n  //    fn(1, 2, 3) //=> [1, [2, 3]]\n  //\n  //    fn = variadic(function (first, second, rest) { return [first, second, rest]})\n  //\n  //    fn()        //=> [undefined, undefined, []]\n  //    fn(1)       //=> [1, undefined, []]\n  //    fn(1, 2)    //=> [1, 2, []]\n  //    fn(1, 2, 3) //=> [1, 2, [3]]\n  var variadic = function () {\n    var FUNCTIONS = {};\n    function oldVariadic (fn) {\n      var fnLength = fn.length;\n\n      if (fnLength < 1) {\n        return fn;\n      }\n      else if (fnLength === 1)  {\n        return function () {\n          return fn.call(this, __slice.call(arguments, 0))\n        }\n      }\n      else {\n        return function () {\n          var numberOfArgs = arguments.length,\n              namedArgs = __slice.call(arguments, 0, fnLength - 1),\n              numberOfMissingNamedArgs = Math.max(fnLength - numberOfArgs - 1, 0),\n              argPadding = new Array(numberOfMissingNamedArgs),\n              variadicArgs = __slice.call(arguments, fn.length - 1);\n\n          return fn.apply(this, namedArgs.concat(argPadding).concat([variadicArgs]))\n        }\n      }\n    };\n    return function (arity, fn) {\n      if (fn == null) {\n        fn = functionalize(arity);\n        arity = 0;\n      }\n      else fn = functionalize(fn);\n      var fnLength = fn.length;\n      if (arity === 0) {\n        return oldVariadic(fn);\n      }\n      else if (fnLength <= arity) {\n        var fixedParams = fnLength - 1;\n        var index = '' + arity + '-' + fixedParams;\n        var code;\n      \n        if (FUNCTIONS[index] == null) {\n          var parameters = new Array(arity);\n          for (var i = 0; i < arity; ++i) {\n            parameters[i] = \"__\" + i;\n          }\n          var pstr = parameters.join();\n          if (fnLength > 1) {\n            var cstr = parameters.slice(0, fnLength - 1).join();\n            code = \"return function (\"+pstr+\") { return fn.call(\"+cstr+\", [].slice.call(arguments,\"+(fnLength - 1)+\")); };\";\n          }\n          else code = \"return function (\"+pstr+\") { return fn.call(this, [].slice.call(arguments, 0)); };\";\n          FUNCTIONS[index] = new Function(['fn'], code);\n        }\n        return FUNCTIONS[index](fn);\n      }\n      else throw 'not supported yet'\n    };\n  }();\n  \n  // sets a fixed arity for a function, without currying\n  var unvariadic = (function () {\n    var FUNCTIONS = {};\n    return function unvariadic (arity, fn) {\n      if (FUNCTIONS[arity] == null) {\n        var parameters = new Array(arity);\n        for (var i = 0; i < arity; ++i) {\n          parameters[i] = \"__\" + i;\n        }\n        var pstr = parameters.join();\n        var code = \"return function (\"+pstr+\") { return fn.apply(this, arguments); };\";\n        FUNCTIONS[arity] = new Function(['fn'], code);\n      }\n      if (fn == null) {\n        return function (fn) { return unvariadic(arity, fn); };\n      }\n      else return FUNCTIONS[arity](functionalize(fn));\n    };\n  })();\n\n  // a kind of optional semantics: unary(f)(value) === f(value), unary(f)() === unary(f)\n  function unary (fn) {\n    return function unary (a) {\n      if (a == null) {\n        return unary;\n      }\n      else return fn(a);\n    }\n  };\n\n  function binary (fn) {\n    return function binary (a, b) {\n      if (a == null) {\n        return binary;\n      }\n      else if (b == null) {\n        return unary(function (b) { return fn(a, b); });\n      }\n      else return fn(a, b);\n    }\n  };\n\n  function ternary (fn) {\n    return function ternary (a, b, c) {\n      if (a == null) {\n        return ternary;\n      }\n      else if (b == null) {\n        return binary(function (b, c) { return fn(a, b, c); });\n      }\n      else if (c == null) {\n        return unary(function (c) { return fn(a, b, c); });\n      }\n      else return fn(a, b, c);\n    }\n  };\n\n  function quaternary (fn) {\n    return function quaternary (a, b, c, d) {\n      if (a == null) {\n        return quaternary;\n      }\n      else if (b == null) {\n        return ternary(function (b, c, d) { return fn(a, b, c, d); });\n      }\n      else if (c == null) {\n        return binary(function (c, d) { return fn(a, b, c, d); });\n      }\n      else if (d == null) {\n        return unary(function (d) { return fn(a, b, c, d); });\n      }\n      else return fn(a, b, c, d);\n    }\n  };\n  \n  var byArity = [\n        invokeImmediately,\n        unary,\n        binary,\n        ternary,\n        quaternary\n      ],\n      byArityLength = byArity.length;\n  \n  function curryWithLeftAndRight (fn, leftArgs, rightArgs) {\n    leftArgs || (leftArgs = []);\n    rightArgs || (rightArgs = []);\n    var fnLength = fn.length,\n        remainingLength = fnLength - leftArgs.length - rightArgs.length;\n    \n    if (remainingLength < byArityLength) {\n      return byArity[remainingLength](handleRemaining);\n    }\n    else return unvariadic(remainingLength, handleRemaining);\n        \n    function handleRemaining () {\n      var params = __slice.call(arguments, 0, arguments.length),\n          numParams = ((params.indexOf(void 0) >= 0)\n            ? params.indexOf(void 0)\n            : params.length),\n          newLeft = leftArgs.concat(params.slice(0, numParams)),\n          args = newLeft.concat(rightArgs),\n          argsLength = args.length,\n          remainingLength = fnLength - argsLength;\n      \n      if (remainingLength <= 0) {\n        return fn.apply(this, args);\n      }\n      else return curryWithLeftAndRight(fn, newLeft, rightArgs);\n    };\n  };\n  \n  extend(allong.es, { curryWithLeftAndRight: curryWithLeftAndRight });\n  \n  // TODO: Deprecate\n  function selfCurrying(fn) {\n    fn = functionalize(fn);\n    var fnLength = fn.length;\n    \n    if (fn.length > 0) {\n      return variadic(fnLength, function (args) {\n        if (args.length === 0) {\n          return curry(fn)\n        }\n        else return fn.apply(this, args);\n      });\n    }\n    else return fn;\n  };\n  \n  extend(allong.es, {\n    variadic: variadic,\n    unvariadic: unvariadic,\n    unary: unary,\n    binary: binary,\n    ternary: ternary,\n    quaternary: quaternary\n  });\n\n  // ### Composition\n\n  //    compose(a, b, c)\n  //      //=> function (x) {\n  //        return a(b(c(x)))\n  //      }\n  var compose = variadic( function compose (fns) {\n    fns = fns.map(functionalize);\n    \n    var first, firstLength, second, rest, i;\n    \n    if (fns.length === 0) {\n      return function () {};\n    }\n    else if (fns.length === 1) {\n      return fns[0];\n    }\n    else if (fns.length === 2) {\n      first = fns[0];\n      firstLength = first.length;\n      second = fns[1];\n      \n      if (firstLength === 1) {\n        return function (a) { return first(second(a)); };\n      }\n      else if (firstLength === 2) {\n        return function (a, b) { return first(second(a), b); };\n      }\n      else if (firstLength === 3) {\n        return function (a, b, c) { return first(second(a), b, c); };\n      }\n      else return variadic( function (a, rest) {\n        first.apply(this, [second(a)].concat(rest))\n      });\n    }\n    else {\n      first = fns[0];\n      firstLength = first.length;\n      \n      return function (value) {\n        for (i = fns.length - 1; i >= 0; --i) {\n          value = fns[i](value);\n        }\n        return value;\n      }\n    }\n  });\n\n  extend(allong.es, {\n    compose: compose\n  });\n  \n  // # CALL_FLIPPED\n  \n  var callFlipped = (function () {\n    \n    function nullary (fn) {\n      return variadic( function (args) {\n        return fn.apply(this, reverse(args));\n      });\n    };\n  \n    // a kind of optional semantics: unary(f)(value) === f(value), unary(f)() === unary(f)\n    function unary (fn) {\n      return function unary (a) {\n        if (a == null) {\n          return unary;\n        }\n        else return fn(a);\n      }\n    };\n\n    function binary (fn) {\n      return function binary (a, b) {\n        if (a == null) {\n          return binary;\n        }\n        else if (b == null) {\n          return unary(function (b) { return fn(b, a); });\n        }\n        else return fn(b, a);\n      }\n    };\n\n    function ternary (fn) {\n      return function ternary (a, b, c) {\n        if (a == null) {\n          return ternary;\n        }\n        else if (b == null) {\n          return binary(function (c, b) { return fn(c, b, a); });\n        }\n        else if (c == null) {\n          return unary(function (c) { return fn(c, b, a); });\n        }\n        else return fn(c, b, a);\n      }\n    };\n\n    function quaternary (fn) {\n      return function quaternary (a, b, c, d) {\n        if (a == null) {\n          return quaternary;\n        }\n        else if (b == null) {\n          return ternary(function (d, c, b) { return fn(d, c, b, a); });\n        }\n        else if (c == null) {\n          return binary(function (d, c) { return fn(d, c, b, a); });\n        }\n        else if (d == null) {\n          return unary(function (d) { return fn(d, c, b, a); });\n        }\n        else return fn(d, c, b, a);\n      }\n    };\n  \n    var byArity = [\n          nullary,\n          unary,\n          binary,\n          ternary,\n          quaternary\n        ],\n        byArityLength = byArity.length;\n\n    function callWithLeftFlipped (fn, leftArgs) {\n      leftArgs || ( leftArgs = []);\n      var fnLength = fn.length,\n          remainingLength = fnLength - leftArgs.length;\n    \n      if (remainingLength < byArityLength) {\n        return byArity[remainingLength](handleRemaining);\n      }\n      else return unvariadic(remainingLength, handleRemaining);\n        \n      function handleRemaining () {\n        var params = __slice.call(arguments, 0, arguments.length),\n            numParams = (params.indexOf(void 0) >= 0)\n              ? params.indexOf(void 0)\n              : params.length\n            args = leftArgs.concat(params.slice(0, numParams));\n            argsLength = args.length,\n            remainingLength = fnLength - argsLength;\n      \n        if (remainingLength <= 0) {\n          return fn.apply(this, reverse(args));\n        }\n        else return callWithLeftFlipped(fn, args);\n      };\n    };\n  \n    return extend( variadic( function callFlipped (fn, args) {\n      fn = functionalize(fn);\n      var fnLength = fn.length,\n          flipped = (fnLength < byArityLength)\n            ? byArity[fnLength](fn)\n            : callWithLeftFlipped(fn);\n    \n      if (args.length === 0) {\n        return flipped;\n      }\n      else return flipped.apply(this, args);\n    \n    }), {\n      unary: unary,\n      binary: binary,\n      ternary: ternary,\n      quaternary: quaternary,\n      callWithLeftFlipped: callWithLeftFlipped\n    });\n  \n  })();\n  \n  // synonymish\n  var flip = unary(callFlipped);\n\n  extend(allong.es, {\n    callFlipped: callFlipped,\n    flip: flip\n  });\n  \n  // # APPLY\n  \n  // the basics: apply and call\n  \n  // call that retuns a curried function\n  \n  var apply = binary( function (fn, args) {\n    return curryWithLeftAndRight(fn, args, []);\n  });\n  \n  var call = variadic( function (fn, args) {\n    return curryWithLeftAndRight(fn, args, []);\n  });\n  \n  var curry = unary(call);\n  \n  function urApply (fn, args) {\n    return fn.apply(this, args);\n  };\n  \n  var applyNow = call( urApply );\n  \n  var callNow = extend( variadic(applyNow), {\n    unary: unary,\n    binary: binary,\n    ternary: ternary,\n    quaternary: quaternary\n  });\n  \n  // flipped forms\n  \n  var applyNowFlipped = flip(urApply);\n  \n  // apply and call left\n  \n  function urApplyLeft (fn, leftArgs) {\n    var remainingLength = fn.length - leftArgs.length;\n    \n    if (fn.length > 0 && remainingLength > 0) {\n      return variadic(remainingLength, function (args) {\n        return fn.apply(this, leftArgs.concat(args));\n      });\n    }\n    else return fn.apply(this, leftArgs);\n  };\n  \n  var applyLeftNow = call(urApplyLeft);\n  \n  var callLeftNow = variadic(urApplyLeft);\n  \n  // flipped\n  \n  var applyLeftNowWith = flip(urApplyLeft);\n  \n  var applyRightNowWith = flip(urApplyRight);\n  \n  // rightmost\n  \n  function urApplyRight (fn, rightArgs) {\n    var remainingLength = fn.length - rightArgs.length;\n    \n    if (fn.length > 0 && remainingLength > 0) {\n      return variadic(remainingLength, function (args) {\n        return fn.apply(this, args.concat(rightArgs));\n      });\n    }\n    else return fn.apply(this, rightArgs);\n  }\n  \n  var applyRightNow = call(urApplyRight);\n  \n  var callRightNow = variadic(urApplyRight);\n  \n  var callRight = variadic( function (fn, args) {\n    return curryWithLeftAndRight(fn, [], args);\n  });\n  \n  var callFirst = binary(call);\n  var callFirstWith = flip(callFirst);\n  \n  var callLast = binary(callRight);\n  var callLastWith = flip(callLast);\n\n  // ### Partial applications that bind\n\n  // A partially applied binding function\n  //\n  // roughly equivalent to applyRight\n  //\n  // var fn = function (...) { ... }\n  //\n  // bound(fn)(x)\n  //   //=> fn.bind(x)\n  //\n  // bound(fn, foo)(x)\n  //   //=> fn.bind(x, foo)\n  //\n  // bound(fn, foo, bar)(x)\n  //   //=> fn.bind(x, foo, bar)\n  var bound = variadic( function (messageName, args) {\n    if (args === []) {\n      return function (instance) {\n        return instance[messageName].bind(instance)\n      }\n    }\n    else {\n      return function (instance) {\n        return Function.prototype.bind.apply(\n          instance[messageName], [instance].concat(args)\n        )\n      }\n    }\n  });\n  \n  var defaults = variadic( function (fn, values) {\n    var fln = fn.length,\n        vln = values.length;\n    return variadic( function (args) {\n      var aln = args.length,\n          mln = Math.max(fln - aln, 0);\n      args = args.concat(values.slice(vln-mln));\n      return fn.apply(this, args);\n    })\n  });\n  \n  // collects arguments\n  function args (arity) {\n    if (arity === 1) {\n      return function (a) {\n        return [a];\n      };\n    }\n    else if (arity === 2) {\n      return function (a, b) {\n        return [a, b];\n      };\n    }\n    else if (arity === 3) {\n      return function (a, b, c) {\n        return [a, b, c];\n      };\n    }\n    else return variadic( function (args) {\n      return args;\n    });\n  };\n  \n  extend(allong.es, {\n    applyNow: applyNow,\n    apply: apply,\n    callNow: callNow,\n    call: call,\n    callLeft: call,\n    callRight: callRight,\n    applyNowFlipped: applyNowFlipped,\n    applyLeftNow: applyLeftNow,\n    callLeftNow: callLeftNow,\n    applyLeftNowWith: applyLeftNowWith,\n    applyRightNow: applyRightNow,\n    callRightNow: callRightNow,\n    applyRightNowWith: applyRightNowWith,\n    callFirst: callFirst,\n    callLast: callLast,\n    callFirstWith: callFirstWith,\n    callLastWith: callLastWith,\n    bound: bound,\n    defaults: defaults,\n    args: args,\n    curry: curry\n  });\n  \n  // # FOLDING\n  \n  var filter = binary( function filter (list, fn) {\n    fn = functionalize(fn);\n    \n    return __filter.call(list, fn);\n  });\n  \n  var filterWith = flip(filter);\n  \n  var map = binary( function map (list, fn) {\n    fn = functionalize(fn);\n    var fnLength = fn.length;\n  \n    if (fnLength !== 1) {\n      fn = unary(fn);\n    }\n    return __map.call(list, fn);\n  });\n  \n  var mapWith = flip(map);\n  \n  var mapArgumentsWith = binary( function (withFn, fn) {\n    return variadic(fn.length, function (args) {\n      return applyNow(fn, map(args, withFn));\n    });\n  });\n\n  // turns any function into a recursive mapper\n  //\n  // deepMap(function (x) { return x * x })([1, [2, 3], 4])\n  //   //=> [1, [4, 9], 16]\n  // function deepMap (fn) {\n  //   return function innerDeepMap (tree) {\n  //     return __map.call(tree, function (element) {\n  //       if (Array.isArray(element)) {\n  //         return innerSoak(element);\n  //       }\n  //       else return fn(element);\n  //     });\n  //   };\n  // };\n  \n  var deepMap = binary( function (tree, fn) {\n    fn = functionalize(fn);\n    \n    return __map.call(tree, function (element) {\n      if (Array.isArray(element)) {\n        return deepMap(element, fn);\n      }\n      else return fn(element);\n    });\n  });\n  \n  var deepMapWith = flip(deepMap);\n  \n  extend(allong.es, {\n    map: map,\n    mapWith: mapWith,\n    mapArgumentsWith: mapArgumentsWith,\n    filter: filter,\n    filterWith: filterWith,\n    deepMap: deepMap,\n    deepMapWith: deepMapWith\n  });\n  \n  // # DECORATORS\n  \n  function mapIfMany (fn) {\n    fn = functionalize(fn);\n    \n    return variadic( function (argList) {\n      if (argList.length === 1 && !isArray(argList[0])) {\n        return fn.call(this, argList[0]);\n      }\n      else return deepMap(argList, fn);\n    });\n  }\n\n  var maybe = mapIfMany( function maybe (fn) {\n    fn = functionalize(fn);\n    return function () {\n      var i;\n\n      if (arguments.length === 0) {\n        return\n      }\n      else {\n        for (i = 0; i < arguments.length; ++i) {\n          if (arguments[i] == null) return arguments[i];\n        }\n        return fn.apply(this, arguments)\n      }\n    }\n  });\n\n  function tap (value, fn) {\n    fn = functionalize(fn);\n\n    if (fn === void 0) {\n      return curried\n    }\n    else return curried(fn);\n\n    function curried (fn) {\n      if (typeof(fn) === 'function') {\n        fn(value)\n      }\n      return value\n    }\n  }\n\n  function fluent (fn) {\n    fn = functionalize(fn);\n    return function () {\n      fn.apply(this, arguments);\n      return this\n    }\n  }\n\n  // decorates a function to return its first argument\n  var returnFirst = function (fn) {\n    fn = functionalize(fn);\n    return function () {\n      fn.apply(this, arguments);\n      return arguments[0];\n    }\n  }\n\n  function tee (decoration) {\n    decoration = functionalize(decoration);\n    return function (fn) {\n      fn = functionalize(fn);\n      return compose(returnFirst(decoration), fn);\n    };\n  };\n\n  function once (fn) {\n    fn = functionalize(fn);\n    var done = false,\n        testAndSet;\n\n    if (!!fn.name) {\n      testAndSet = function () {\n        this[\"__once__\"] || (this[\"__once__\"] = {})\n        if (this[\"__once__\"][fn.name]) return true;\n        this[\"__once__\"][fn.name] = true;\n        return false\n      }\n    }\n    else  {\n      testAndSet = function (fn) {\n        if (done) return true;\n        done = true;\n        return false\n      }\n    }\n\n    return function () {\n      return testAndSet.call(this) ? void 0 : fn.apply(this, arguments)\n    }\n  }\n\n  function memoized (fn, keymaker) {\n    fn = functionalize(fn);\n    var lookupTable = {},\n        key,\n        value;\n\n    keymaker || (keymaker = function (args) {\n      return JSON.stringify(args)\n    });\n\n    return function () {\n      var key = keymaker.call(this, arguments);\n\n      return lookupTable[key] || (\n        lookupTable[key] = fn.apply(this, arguments)\n      )\n    }\n  };\n  \n  extend(allong.es, {\n    maybe: maybe,\n    tap: tap,\n    fluent: fluent,\n    returnFirst: returnFirst,\n    tee: tee,\n    once: once,\n    memoized: memoized\n  });\n  \n  // # MIXIN\n\n  function mixin (decoration) {\n    return function decorator () {\n      if (arguments[0] !== void 0) {\n        return decorator.call(arguments[0]);\n      }\n      else {\n        extend(this, decoration);\n        return this;\n      }\n    };\n  };\n\n  function classDecorator (decoration) {\n    return function (clazz) {\n      function Decorated  () {\n        var self = this instanceof Decorated\n                   ? this\n                   : new Decorated();\n\n        return clazz.apply(self, arguments);\n      };\n      Decorated.prototype = extend(new clazz(), decoration);\n      return Decorated;\n    };\n  };\n  \n  extend(allong.es, {\n    mixin: mixin,\n    classDecorator: classDecorator\n  });\n  \n  // # MORE\n\n  var unbind = function unbind (fn) {\n    fn = functionalize(fn);\n    return fn.unbound ? unbind(fn.unbound()) : fn\n  };\n\n  function bind (fn, context, force) {\n    fn = functionalize(fn);\n    var unbound, bound;\n\n    if (force) {\n      fn = unbind(fn)\n    }\n    bound = function () {\n      return fn.apply(context, arguments)\n    };\n    bound.unbound = function () {\n      return fn;\n    };\n\n    return bound;\n  }\n\n  function invoke (fn) {\n    fn = functionalize(fn);\n    var args = __slice.call(arguments, 1);\n\n    return function (instance) {\n      return fn.apply(instance, args)\n    }\n  };\n\n  function get (object, getName) {\n    if (getName == null) {\n      return function (getName) { return object[getName]; };\n    }\n    else return object[getName];\n  };\n\n  function getWith (getName, object) {\n    if (object == null) {\n      return function (object) { return object[getName]; };\n    }\n    else return object[getName];\n  };\n\n  var pluckWith = compose(mapWith, getWith),\n      pluck = flip(pluckWith);\n\n  // Send a message/invoke a method on the receiver.\n  // TODO: Think about what it has in common with callLeft\n  var send = variadic( function (methodName, args) {\n    return variadic( function (receiver, remainingArgs) {\n      var fn = receiver[methodName];\n      return fn.apply(receiver, args.concat(remainingArgs))\n    })\n  });\n  \n  extend(allong.es, {\n    bind: bind,\n    unbind: unbind,\n    invoke: invoke,\n    get: get,\n    getWith: getWith,\n    send: send,\n    pluckWith: pluckWith,\n    pluck: pluck\n  });\n  \n  // # TRAMPOLINE\n      \n  function Thunk (closure) {\n    if (!(this instanceof Thunk))\n      return new Thunk(closure);\n    \n    this.closure = closure;\n  };\n  \n  Thunk.prototype.force = function () {\n    return this.closure();\n  };\n      \n  function trampoline (fn) {\n    var trampolined = variadic( function (args) {\n      var result = fn.apply(this, args);\n      \n      while (result instanceof Thunk) {\n        result = result.force();\n      }\n      \n      return result;\n    });\n    trampolined.__trampolined_fn = fn;\n    return trampolined;\n  };\n  \n  var tailCall = variadic( function (fn, args) {\n    var context = this;\n    if (fn.__trampolined_fn instanceof Function) {\n      return new Thunk( function () { \n        return fn.__trampolined_fn.apply(context, args);\n      });\n    }\n    else return new Thunk( function () { \n      return fn.apply(context, args);\n    });\n  });\n  \n  extend(allong.es, {\n    trampoline: trampoline,\n    tailCall: tailCall,\n    Thunk: Thunk\n  });\n  \n  // # ITERATORS\n  \n  (function (allong) {\n      \n    function fold (iter, binaryFn, seed) {\n      var state, element;\n      binaryFn = functionalize(binaryFn);\n      if (seed !== void 0) {\n        state = seed;\n      }\n      else {\n        state = iter();\n      }\n      element = iter();\n      while (element != null) {\n        state = binaryFn.call(element, state, element);\n        element = iter();\n      }\n      return state;\n    };\n  \n    var HASNTBEENRUN = {};\n  \n    function unfold (seed, unaryFn) {\n      var state = HASNTBEENRUN;\n      unaryFn = functionalize(unaryFn);\n      return function () {\n        if (state === HASNTBEENRUN) {\n          return (state = seed);\n        }\n        else if (state != null) {\n          return (state = unaryFn.call(state, state));\n        }\n        else return state;\n      };\n    };\n  \n    // note that the unfoldWithReturn behaves differently than\n    // unfold with respect to the first value returned\n    function unfoldWithReturn (seed, unaryFn) {\n      var state = seed,\n          pair,\n          value;\n      unaryFn = functionalize(unaryFn);\n      return function () {\n        if (state != null) {\n          pair = unaryFn.call(state, state);\n          value = pair[1];\n          state = value != null\n                  ? pair[0]\n                  : void 0\n          return value;\n        }\n        else return void 0;\n      };\n    };\n\n    function accumulate (iter, binaryFn, initial) {\n      var state = initial;\n      binaryFn = functionalize(binaryFn);\n      return function () {\n        element = iter();\n        if (element == null) {\n          return element;\n        }\n        else {\n          if (state === void 0) {\n            return (state = element);\n          }\n          else return (state = binaryFn.call(element, state, element));\n        }\n      }\n    };\n  \n    function accumulateWithReturn (iter, binaryFn, initial) {\n      var state = initial,\n          stateAndReturnValue;\n      binaryFn = functionalize(binaryFn);\n      return function () {\n        element = iter();\n        if (element == null) {\n          return element;\n        }\n        else {\n          if (state === void 0) {\n            return (state = element);\n          }\n          else {\n            stateAndReturnValue = binaryFn.call(element, state, element);\n            state = stateAndReturnValue[0];\n            return stateAndReturnValue[1];\n          }\n        }\n      }\n    };\n  \n    function map (iter, unaryFn) {\n      unaryFn = functionalize(unaryFn);\n      return function() {\n        var element;\n        element = iter();\n        if (element != null) {\n          return unaryFn.call(element, element);\n        } else {\n          return void 0;\n        }\n      };\n    };\n\n    function select (iter, unaryPredicateFn) {\n      unaryPredicateFn = functionalize(unaryPredicateFn);\n      return function() {\n        var element;\n        element = iter();\n        while (element != null) {\n          if (unaryPredicateFn.call(element, element)) {\n            return element;\n          }\n          element = iter();\n        }\n        return void 0;\n      };\n    };\n  \n    function reject (iter, unaryPredicateFn) {\n      unaryPredicateFn = functionalize(unaryPredicateFn);\n      return select(iter, function (something) {\n        return !unaryPredicateFn(something);\n      });\n    };\n  \n    function find (iter, unaryPredicateFn) {\n      unaryPredicateFn = functionalize(unaryPredicateFn);\n      return select(iter, unaryPredicateFn)();\n    }\n\n    function slice (iter, numberToDrop, numberToTake) {\n      var count = 0;\n      while (numberToDrop-- > 0) {\n        iter();\n      }\n      if (numberToTake != null) {\n        return function() {\n          if (++count <= numberToTake) {\n            return iter();\n          } else {\n            return void 0;\n          }\n        };\n      }\n      else return iter;\n    };\n  \n    var drop = defaults(binary(slice), 1);\n  \n    function take (iter, numberToTake) {\n      return slice(iter, 0, numberToTake == null ? 1 : numberToTake);\n    }\n\n    function FlatArrayIterator (array) {\n      var index = 0;\n      return function() {\n        return array[index++];\n      };\n    };\n  \n    function RecursiveArrayIterator (array) {\n      var index, myself, state;\n      index = 0;\n      state = [];\n      myself = function() {\n        var element, tempState;\n        element = array[index++];\n        if (element instanceof Array) {\n          state.push({\n            array: array,\n            index: index\n          });\n          array = element;\n          index = 0;\n          return myself();\n        } else if (element === void 0) {\n          if (state.length > 0) {\n            tempState = state.pop(), array = tempState.array, index = tempState.index;\n            return myself();\n          } else {\n            return void 0;\n          }\n        } else {\n          return element;\n        }\n      };\n      return myself;\n    };\n  \n    function K (value) {\n      return function () {\n        return value;\n      };\n    };\n\n    function upRange (from, to, by) {\n      return function () {\n        var was;\n      \n        if (from > to) {\n          return void 0;\n        }\n        else {\n          was = from;\n          from = from + by;\n          return was;\n        }\n      }\n    };\n\n    function downRange (from, to, by) {\n      return function () {\n        var was;\n      \n        if (from < to) {\n          return void 0;\n        }\n        else {\n          was = from;\n          from = from - by;\n          return was;\n        }\n      }\n    };\n  \n    function range (from, to, by) {\n      if (from == null) {\n        return upRange(1, Infinity, 1);\n      }\n      else if (to == null) {\n        return upRange(from, Infinity, 1);\n      }\n      else if (by == null) {\n        if (from <= to) {\n          return upRange(from, to, 1);\n        }\n        else return downRange(from, to, 1)\n      }\n      else if (by > 0) {\n        return upRange(from, to, by);\n      }\n      else if (by < 0) {\n        return downRange(from, to, Math.abs(by))\n      }\n      else return k(from);\n    };\n  \n    var numbers = unary(range);\n\n    extend(allong.es, { iterators: {\n      accumulate: accumulate,\n      accumulateWithReturn: accumulateWithReturn,\n      fold: fold,\n      unfold: unfold,\n      unfoldWithReturn: unfoldWithReturn,\n      map: map,\n      select: select,\n      reject: reject,\n      filter: select,\n      find: find,\n      slice: slice,\n      drop: drop,\n      take: take,\n      FlatArrayIterator: FlatArrayIterator,\n      RecursiveArrayIterator: RecursiveArrayIterator,\n      constant: K,\n      K: K,\n      numbers: numbers,\n      range: range\n    }});\n  \n  })(allong);\n  \n  // Monadic Sequencing\n  // ------------------\n  \n  //    sequence(a, b, c)\n  //      //=> function (x) {\n  //        return c(b(a(x)))\n  //      }\n  // var sequence = callFlipped(compose);\n\n  var Promise = require('promise');\n  \n  var BaseMonad = function (methods) {\n    var name,\n        body;\n    if (methods) {\n      for (name in methods) {\n        if (methods.hasOwnProperty(name)) {\n          this[name] = methods[name];\n        }\n      }\n    }\n  };\n\n  BaseMonad.prototype = {\n    of: function (value) { return value; },\n    map: function (fn) { return fn; },\n    chain: function (mValue, fn) { return this.map(fn)(mValue); }\n  };\n  \n  var Identity = new BaseMonad();\n\n  var Maybe = new BaseMonad({\n    map: maybe\n  });\n\n  var Writer = new BaseMonad({\n    of: function(value) {\n      return [value, ''];\n    },\n    map: function(fn) {\n      return function(_arg) {\n        var newlyWritten, result, value, writtenSoFar, _ref;\n        value = _arg[0], writtenSoFar = _arg[1];\n        _ref = fn(value), result = _ref[0], newlyWritten = _ref[1];\n        return [result, writtenSoFar + newlyWritten];\n      };\n    }\n  });\n  \n  var ArrayWriter = new BaseMonad({\n    of: function (argument) {\n          return [argument, []];\n        },\n    chain: function (valueAndLogList, fn) {\n              var value = valueAndLogList[0],\n                  logList = valueAndLogList[1],\n                  resultAndLogList = fn(value),\n                  result = resultAndLogList[0],\n                  resultLogList = flatten(logList.concat(resultAndLogList[1]));\n          \n              return [result, resultLogList];\n            }\n  });\n\n  var List = new BaseMonad({\n    of: function(value) {\n      return [value];\n    },\n    join: function(mValue) {\n      return mValue.reduce(this.concat, this.zero());\n    },\n    map: function(fn) {\n      return function(mValue) {\n        return mValue.map(fn);\n      };\n    },\n    zero: function() {\n      return [];\n    },\n    concat: function(ma, mb) {\n      return ma.concat(mb);\n    },\n    chain: function(mValue, fn) {\n      return this.join(this.map(fn)(mValue));\n    }\n  });\n\n  var Then = new BaseMonad({\n    of: function(value) {\n      return new Promise(function(resolve, reject) {\n        return resolve(value);\n      });\n    },\n    map: function(fnReturningAPromise) {\n      return function(promiseIn) {\n        return new Promise(function(resolvePromiseOut, rejectPromiseOut) {\n          return promiseIn\n            .then(fnReturningAPromise, rejectPromiseOut)\n            .then(resolvePromiseOut, rejectPromiseOut)\n        });\n      };\n    }\n  });\n\n  var Callback = {\n    chain: function (mValue, fn) {\n      if (mValue.length === 1) {\n        return function (value, callback) {\n          return mValue(value, variadic( function (results) {\n            return fn.apply(null, results.concat([callback]));\n          }));\n        };\n      }\n      else {\n        // needs variadicr\n        return variadic( function (args) {\n          var callback = args[args.length - 1],\n              values   = __slice.call(args, 0, args.length - 1);\n          return mValue.apply(this, values.concat([ variadic( function (results) {\n            return fn.apply(null, results.concat([callback]));\n          })]));\n        });\n      }\n    }\n  };\n  \n  var pipeline = flip(compose);\n\n  var sequence = variadic( function (sequenceArgs) {\n    var fns, supervisor, arity, _of, _map, _chain;\n    if (sequenceArgs.length === 0) {\n      return function (value) { return value; } // I combinator\n    }\n    else {\n      sequenceArgs = flatten(sequenceArgs);\n      if (isFunction(sequenceArgs[0])) {\n        return pipeline.apply(this, sequenceArgs);\n      }\n      else {\n        if (isString(sequenceArgs[0])) {\n          supervisor = sequence[sequenceArgs[0]];\n        }\n        else supervisor = sequenceArgs[0];\n        \n        _map   = (supervisor.map && supervisor.map.bind(supervisor));\n        _chain = (supervisor.chain && supervisor.chain.bind(supervisor));\n        _of    = (supervisor.of && supervisor.of.bind(supervisor));\n        \n        // default for _chain\n        if (_chain == null) {\n          _chain = (_map == null)\n                   ? function (mValue, fn) { return fn(mValue); } // \"T\"\n                   : function (mValue, fn) { return _map(fn)(mValue); }\n        }\n        \n        fns = 2 <= sequenceArgs.length ? __slice.call(sequenceArgs, 1) : [];\n        arity = fns.length > 0\n          ? fns[0].length\n          : 0;\n          \n        if (isFunction(_of)) {\n          // option 1: There is an _of: uses this function to provide a seed\n          return variadic(arity, function (args) {\n            return fns.reduce(_chain, _of.apply(this, args));\n          });\n        }\n        else {\n          // option 2: uses the first function as the seed\n          chained = fns.slice(1).reduce(_chain, fns[0]);\n          return unvariadic(arity, chained);\n        }\n      }\n    }\n  });\n  \n  extend(sequence, {\n    Identity: Identity,\n    Maybe: Maybe,\n    List: List,\n    Writer: Writer,\n    Then: Then,\n    Callback: Callback\n  });\n\n  extend(allong.es, {\n    pipeline: pipeline,\n    sequence: sequence\n  });\n  \n  // andand, oror\n  // ------------\n  \n  var andand = mapIfMany( function andand (fn) {\n    return variadic(fn.length, function (args) {\n      if (args.length > 0) {\n        var argTruthiness = args.reduce(function (acc, value) { return acc && value; });\n        return argTruthiness && fn.apply(this, args);\n      }\n    })\n  })\n  \n  var oror = mapIfMany( function oror (fn) {\n    return variadic(fn.length, function (args) {\n      if (args.length > 0) {\n        var argTruthiness = args.reduce(function (acc, value) { return acc || value; });\n        return argTruthiness || fn.apply(this, args);\n      }\n    })\n  });\n\n  extend(allong.es, {\n    andand: andand,\n    oror: oror\n  });\n  \n  // Sequence Transformers\n  // ---------------------\n  \n  var fn2Then = mapIfMany( function fn2Then (fn) {\n    return function (value) {\n      return new Promise(function(resolve, reject) {\n        return resolve(fn(value));\n      });\n    }\n  });\n  \n  var callback2Then = mapIfMany( function callback2Then (fn) {\n    if (fn.length === 1) {\n      return function () {\n        return new Promise(function(resolve, reject) {\n          return fn(function (value) {\n            return resolve(value);\n          })\n        });\n      };\n    }\n    else return variadic(fn.length - 1, function(values) {\n      return new Promise(function(resolve, reject) {\n        return fn.apply(this, values.concat([function (value) { return resolve(value); }]));\n      });\n    });\n  });\n  \n  var fn2Callback = mapIfMany( function fn2Callback (fn) {\n    return function (value, callback) {\n      return callback(fn(value));\n    }\n  });\n  \n  var then2Callback = mapIfMany( function fn2Callback (fn) {\n    return function (value, callback) {\n      var thennable = fn(value);\n      thennable.then(callback, function (error) { throw error; });\n    }\n  });\n\n  extend(sequence, {\n    fn2Then: fn2Then,\n    fn2Callback: fn2Callback,\n    callback2Then: callback2Then,\n    then2Callback: then2Callback\n  });\n\n  // Exports and sundries\n  // --------------------\n\n  if (typeof exports !== 'undefined') {\n    if (typeof module !== 'undefined' && module.exports) {\n      exports = module.exports = allong;\n    }\n    exports.allong = allong;\n  } else {\n    root.allong = allong;\n  }\n  \n}).call(this);\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"author\": \"Reg Braithwaite <raganwald@gmail.com> (http://braythwayt.com)\",\n  \"name\": \"allong.es\",\n  \"description\": \"Combinators and Function Decorators\",\n  \"version\": \"0.14.0\",\n  \"homepage\": \"http://allong.es\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/raganwald/allong.es.git\"\n  },\n  \"main\": \"lib/allong.es.js\",\n  \"scripts\": {\n    \"test\": \"jasmine-node --coffee --verbose spec\"\n  },\n  \"engines\": {\n    \"node\": \"\"\n  },\n  \"dependencies\": {\n    \"promise\": \"\"\n  },\n  \"devDependencies\": {\n    \"jasmine-node\": \"\",\n    \"coffee-script\": \"\",\n    \"grunt\": \"~0.4.1\",\n    \"grunt-contrib-uglify\": \"~0.2.0\"\n  }\n}\n"
  },
  {
    "path": "spec/andand-oror.spec.coffee",
    "content": "{andand, oror} = require('../lib/allong.es').allong.es\n\nT = () -> true\nF = () -> false\nN = () -> null\nU = () -> undefimed\n\ndescribe \"andand\", ->\n  \n  it \" should pass null through\", ->\n    expect( andand(T)(null) ).toEqual(null && true)\n  \n  it \" should pass undefined through\", ->\n    expect( andand(T)(undefined) ).toEqual(undefined && true)\n  \n  it \" should pass false through\", ->\n    expect( andand(T)(false) ).toEqual(false && true)\n    \n  it 'should evaluate on truthy', ->\n    expect( andand(T)('truthy') ).toEqual('truthy' && true)\n    \n  it 'should evaluate on []', ->\n    expect( andand(T)([]) ).toEqual([] && true)\n    \n  it 'should evaluate on \\'\\'', ->\n    expect( andand(T)('') ).toEqual('' && true)\n    \n  it 'should evaluate on 0', ->\n    expect( andand(T)(0) ).toEqual(0 && true)\n\ndescribe \"oror\", ->\n  \n  it \" should pass null through\", ->\n    expect( oror(T)(null) ).toEqual(null || true)\n  \n  it \" should pass undefined through\", ->\n    expect( oror(T)(undefined) ).toEqual(undefined || true)\n  \n  it \" should pass false through\", ->\n    expect( oror(T)(false) ).toEqual(false || true)\n    \n  it 'should evaluate on truthy', ->\n    expect( oror(T)('truthy') ).toEqual('truthy' || true)\n    \n  it 'should evaluate on []', ->\n    expect( oror(T)([]) ).toEqual([] || true)\n    \n  it 'should evaluate on \\'\\'', ->\n    expect( oror(T)('') ).toEqual('' || true)\n    \n  it 'should evaluate on 0', ->\n    expect( oror(T)(0) ).toEqual(0 || true)"
  },
  {
    "path": "spec/apply.spec.coffee",
    "content": "{ callRight, applyNow, callNow, applyNowFlipped, \n  call, applyLeftNow, callLeftNow, args, applyLeftNowWith,\n  applyRightNow, callRightNow, applyRightNowWith,\n  callFirst, callFirstWith, callLast, callLastWith, apply\n} = require('../lib/allong.es.js').allong.es\n\necho = (a, b, c) -> \"#{a} #{b} #{c}\"\n\nfive = (a, b, c, d, e) -> [a, b, c, d, e]\nthree = (a, b, c) -> [a, b, c]\ntwelve = (a, b, c, d, e, f, g, h, i, j, k, l) ->\nvari = (args...) -> args\none = (x) -> x\n\ndescribe \"apply\", ->\n  \n  it \"should apply an array of arguments to a function\", ->\n    expect( apply(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it \"should be curried\", ->\n    expect( apply(three)([1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it \"should  be self-currying, it should apply what it gets\", ->\n    expect( apply(three, [1, 2])(3) ).toEqual three(1, 2, 3)\n\ndescribe \"applyNow\", ->\n  \n  it \"should apply an array of arguments to a function\", ->\n    expect( applyNow(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it \"should not be self-currying, it should apply what it gets\", ->\n    expect( applyNow(three, [1, 2]) ).toEqual three(1, 2)\n    expect( applyNow(three, [1]) ).toEqual three(1)\n    \n  it \"should be curried\", ->\n    expect( applyNow(three)([1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  describe \"when flipped\", ->\n    \n    it \"should apply an array of arguments to a function\", ->\n      expect( applyNowFlipped([1, 2, 3], three) ).toEqual three(1, 2, 3)\n\n    it \"should be curried\", ->\n      expect( applyNowFlipped([1, 2, 3])(three) ).toEqual three(1, 2, 3)\n\ndescribe \"callNow\", ->\n  \n  it \"should apply arguments to a function\", ->\n    expect( callNow(three, 1, 2, 3) ).toEqual three(1, 2, 3)\n    \n  it \"should not be self-currying, it should apply what it gets\", ->\n    expect( callNow(three, 1, 2) ).toEqual three(1, 2)\n    expect( callNow(three, 1) ).toEqual three(1)\n    \n  it \"should not be curried\", ->\n    expect( callNow(three) ).toEqual three()\n    \n  # variadic functions do not have a 'this' predefined at this point.\n    \ndescribe \"applyLeftNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( applyLeftNow(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( applyLeftNow(three, [1, 2]) ).not.toEqual three(1, 2)\n    expect( applyLeftNow(three, [1, 2])(3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be fully curried', ->\n    expect( applyLeftNow(three, [1])(2) ).toEqual three(1, 2)\n    \n  describe \"when flipped\", ->\n  \n    it 'should apply all the arguments if possible', ->\n      expect( applyLeftNowWith([1, 2, 3], three) ).toEqual three(1, 2, 3)\n    \n    it 'should not be full application', ->\n      expect( applyLeftNowWith([1, 2], three) ).not.toEqual three(1, 2)\n      expect( applyLeftNowWith([1, 2], three)(3) ).toEqual three(1, 2, 3)\n    \n    it 'should not be fully curried', ->\n      expect( applyLeftNowWith([1], three)(2) ).toEqual three(1, 2)\n    \ndescribe \"callLeftNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( callLeftNow(three, 1, 2, 3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( callLeftNow(three, 1, 2) ).not.toEqual three(1, 2)\n    expect( callLeftNow(three, 1, 2)(3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be fully curried', ->\n    expect( callLeftNow(three, 1)(2) ).toEqual three(1, 2)\n\ndescribe \"applyRightNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( applyRightNow(three, [1, 2, 3]) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( applyRightNow(three, [1, 2]) ).not.toEqual three(1, 2)\n    expect( applyRightNow(three, [1, 2])(3) ).toEqual three(3, 1, 2)\n    \n  it 'should not be fully curried', ->\n    expect( applyRightNow(three, [1])(2) ).toEqual three(2, 1)\n    \n  describe \"when flipped\", ->\n  \n    it 'should apply all the arguments if possible', ->\n      expect( applyRightNowWith([1, 2, 3], three) ).toEqual three(1, 2, 3)\n    \n    it 'should not be full application', ->\n      expect( applyRightNowWith([1, 2], three) ).not.toEqual three(1, 2)\n      expect( applyRightNowWith([1, 2], three)(3) ).toEqual three(3, 1, 2)\n    \n    it 'should not be fully curried', ->\n      expect( applyRightNowWith([1], three)(2) ).toEqual three(2, 1)\n    \ndescribe \"callRightNow\", ->\n  \n  it 'should apply all the arguments if possible', ->\n    expect( callRightNow(three, 1, 2, 3) ).toEqual three(1, 2, 3)\n    \n  it 'should not be full application', ->\n    expect( callRightNow(three, 1, 2) ).not.toEqual three(1, 2)\n    expect( callRightNow(three, 1, 2)(3) ).toEqual three(3, 1, 2)\n    \n  it 'should not be fully curried', ->\n    expect( callRightNow(three, 1)(2) ).toEqual three(2, 1)\n    \n################################\n\ndescribe \"call\", ->\n  \n  it \"should call an array of arguments to a function\", ->\n    expect( call(echo, 1, 2, 3) ).toEqual \"1 2 3\"\n  \n  it \"should have a curried nature\", ->\n    expect( call(five)(1, 2, 3, 4, 5) ).toEqual [1..5]\n    expect( call(five)(1, 2, 3)(4, 5) ).toEqual [1..5]\n    expect( call(five, 1, 2, 3)(4, 5) ).toEqual [1..5]\n    expect( call(five, 1, 2, 3)(4)(5) ).toEqual [1..5]\n    \n  it \"should get the arity right for small amounts\", ->\n    expect( call(five, 1, 2).length ).toEqual 3\n\ndescribe \"callRight\", ->\n  \n  it \"should call an array of arguments to a function\", ->\n    expect( callRight(echo, 1, 2, 3) ).toEqual \"1 2 3\"\n  \n  it \"should have a curried nature\", ->\n    expect( callRight(five)(1, 2, 3, 4, 5) ).toEqual [1..5]\n    expect( callRight(five)(1, 2, 3)(4, 5) ).toEqual [1..5]\n    \n  it \"should apply given arguments to the right\", ->\n    expect( callRight(five, 1)(2, 3, 4, 5) ).toEqual [2, 3, 4, 5, 1]\n    expect( callRight(five, 1, 2)(3, 4, 5) ).toEqual [3, 4, 5, 1, 2]\n    expect( callRight(five, 1, 2, 3)(4, 5) ).toEqual [4, 5, 1, 2, 3]\n    expect( callRight(five, 1, 2, 3, 4)(5) ).toEqual [5, 1, 2, 3, 4]\n    expect( callRight(five, 1, 2, 3)(4, 5) ).toEqual [4, 5, 1, 2, 3]\n    expect( callRight(five, 1, 2, 3)(4)(5) ).toEqual [4, 5, 1, 2, 3]\n    \n  it \"should get the arity right for small amounts\", ->\n    expect( callRight(five, 1, 2).length ).toEqual 3\n    \ndescribe 'callFirst', ->\n  \n  it 'should call with the first argument', ->\n    expect( callFirst(three, 1)(2, 3) ).toEqual [1..3]\n    \n  it 'should get the arity right', ->\n    expect( callFirst.length ).toEqual 2\n    expect( callFirst(three, 1).length ).toEqual 2\n    \n  it 'should be curried', ->\n    expect( callFirst(three)(1)(2, 3) ).toEqual [1..3]\n    \ndescribe 'callFirstWith', ->\n  \n  it 'should call with the first argument', ->\n    expect( callFirstWith(1, three)(2, 3) ).toEqual [1..3]\n    \n  it 'should get the arity right', ->\n    expect( callFirstWith.length ).toEqual 2\n    expect( callFirstWith(1, three).length ).toEqual 2\n    \n  it 'should be curried', ->\n    expect( callFirstWith(1)(three)(2, 3) ).toEqual [1..3]\n    \ndescribe \"args\", ->\n  \n  it \"should collect arguments into an array\", ->\n    expect( args(3)(1, 2, 3) ).toEqual [1, 2, 3]"
  },
  {
    "path": "spec/arity.spec.coffee",
    "content": "{unvariadic, variadic, curry} = require('../lib/allong.es.js').allong.es\n\nnumberOfArgs = -> arguments.length\nthreeArguments = (a, b, c) -> arguments.length\n\ndescribe \"unvariadic\", ->\n  \n  it \"should clip arguments\", ->\n    expect( unvariadic(3, numberOfArgs)(1, 2, 3, 4, 5) ).toEqual threeArguments(1, 2, 3, 4, 5)\n    \n  it \"shouldn't pad arguments\", ->\n    expect( unvariadic(3, numberOfArgs)(1) ).toEqual threeArguments(1)\n    \ndescribe \"variadic\", ->\n  \n  describe \"with an arity\", ->\n    \n    one = (args) -> [args]\n    \n    two = (arg, args) -> [arg, args]\n    \n    onev = (args...) -> [args]\n    \n    twov = (arg, args...) -> [arg, args]\n    \n    it 'should 1', ->\n      expect( variadic(1, one)(1, 2, 3) ).toEqual onev(1, 2, 3)\n    \n    it 'should 2', ->\n      expect( variadic(1, one).length ).toEqual 1\n    \n    it 'should 3', ->\n      expect( variadic(2, one).length ).toEqual 2\n\ndescribe \"curry\", ->\n  \n  three = (a, b, c) -> [a, b, c]\n  \n  it \"should be a function that returns a function\", ->\n    expect( curry instanceof Function).toEqual true\n    expect( curry(three) instanceof Function).toEqual true\n  \n  it \"should allow a full invocation\", ->\n    expect( curry(three)(1, 2, 3) ).toEqual [1, 2, 3]\n  \n  it \"should allow partial invocation\", ->\n    expect( curry(three)(1)(2, 3) ).toEqual [1, 2, 3]\n    expect( curry(three)()(1, 2, 3) ).toEqual [1, 2, 3]\n    expect( curry(three)(1)(2)(3) ).toEqual [1, 2, 3]\n    expect( curry(three)(1, 2)(3) ).toEqual [1, 2, 3]\n    \n    # describe \"self-currying\", ->\n    #   \n    #   it \"shouldn't affect normal useage\", ->\n    #     expect(selfCurrying(three)(4, 5, 6)).toEqual three(4, 5, 6)\n    #     expect(selfCurrying(three)(4, 5)).toEqual three(4, 5)\n    #     expect(selfCurrying(three)(4)).toEqual three(4)\n    #   \n    #   it \"should curry with no arguments\", ->\n    # expect( selfCurrying(three)()(1)(2, 3) ).toEqual [1, 2, 3]\n    # expect( selfCurrying(three)()()(1, 2, 3) ).toEqual [1, 2, 3]\n    # expect( selfCurrying(three)()(1)(2)(3) ).toEqual [1, 2, 3]\n    # expect( selfCurrying(three)()(1, 2)(3) ).toEqual [1, 2, 3]\n"
  },
  {
    "path": "spec/core.spec.coffee",
    "content": "# unary, binary, ternary, variadic, compose, sequence???\n{defaults, mapWith, getWith, filterWith, compose, sequence, variadic, flip, curry} = require('../lib/allong.es.js').allong.es\n\necho = (a, b, c) -> \"#{a} #{b} #{c}\"\nparenthesize = (a) -> \"(#{a})\"\nsquare = (n) -> n * n\noddP = (n) -> !!(n % 2)\n\ndescribe \"defaults\", ->\n  \n  it \"should default values\", ->\n    expect( defaults(echo, 'c')('a', 'b') ).toEqual 'a b c'\n    expect( defaults(echo, 'b', 'c')('a') ).toEqual 'a b c'\n    expect( defaults(echo, 'a', 'b', 'c')() ).toEqual 'a b c'\n  \n  it \"should ignore uneccesary defaults\", ->\n    expect( defaults(echo, 'a', 'b', 'c')('A') ).toEqual 'A b c'\n    expect( defaults(echo, 'a', 'b', 'c')('A', 'B') ).toEqual 'A B c'\n    expect( defaults(echo, 'a', 'b', 'c')('A', 'B', 'C') ).toEqual 'A B C'\n    expect( defaults(echo, 'a', 'b', 'c')('A', 'B', 'C', 'D') ).toEqual 'A B C'\n    \ndescribe \"mapWith\", ->\n  \n  it \"should map backwards\", ->\n    expect( mapWith(square, [1..5]) ).toEqual [1, 4, 9, 16, 25]\n  \n  it \"should map backwards, curried\", ->\n    expect( mapWith(square)([1..5]) ).toEqual [1, 4, 9, 16, 25]\n    \ndescribe \"filterWith\", ->\n  \n  it \"should filter backwards\", ->\n    expect( filterWith(oddP, [1..5]) ).toEqual [1, 3, 5]\n  \n  it \"should filter backwards, curried\", ->\n    expect( filterWith(oddP)([1..5]) ).toEqual [1, 3, 5]\n\ndescribe \"compose\", ->\n  \n  it \"should compose two functions\", ->\n    expect( compose(parenthesize, parenthesize)('hello') ).toEqual '((hello))'\n  \n  it \"should respect the arity of the first function\", ->\n    expect( compose(parenthesize, parenthesize).length ).toEqual 1\n    expect( compose(echo, parenthesize).length ).toEqual 3\n    \n  it \"should handle a common use case, pluckWith\", ->\n    myPluckWith = compose mapWith, getWith\n    expect( myPluckWith('name')([{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n    expect( myPluckWith('name', [{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n\ndescribe \"sequence\", ->\n  \n  it \"should sequence two functions\", ->\n    expect( sequence(parenthesize, parenthesize)('hello') ).toEqual '((hello))'\n  \n  it \"should respect the arity of the first function\", ->\n    expect( sequence(parenthesize, parenthesize).length ).toEqual 1\n    expect( sequence(parenthesize, echo).length ).toEqual 3\n    \n  it \"should handle a common use case, pluckWith\", ->\n    myPluckWith = sequence getWith, mapWith\n    expect( myPluckWith('name')([{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n    expect( myPluckWith('name', [{name: 'foo'}, {name: 'bar'}]) ).toEqual ['foo', 'bar']\n  \ndescribe \"flip\", ->\n  \n  a = (a) -> [a]\n  b = (a, b) -> [a, b]\n  c = (a, b, c) -> [a, b, c]\n  d = (a, b, c, d) -> [a, b, c, d]\n  v = variadic( (x) -> x )\n  \n  it \"should flip a unary function\", ->\n    expect( flip(a)(1) ).toEqual [1]\n    \n  it \"should flip a binary function\", ->\n    expect( flip(b)(1, 2) ).toEqual [2, 1]\n    \n  it \"should flip a ternary function\", ->\n    expect( flip(c)(1, 2, 3) ).toEqual [3, 2, 1]\n    \n  it \"should flip a quaternary function\", ->\n    expect( flip(d)(1, 2, 3, 4) ).toEqual [4, 3, 2, 1]\n    \n  it \"should flip a variadic function\", ->\n    expect( flip(v)(1, 2, 3, 4, 5) ).toEqual [5, 4, 3, 2, 1]\n    \n  it \"should respect arities\", ->\n    expect( flip(v).length ).toEqual v.length\n    expect( flip(a).length ).toEqual a.length\n    expect( flip(b).length ).toEqual b.length\n    expect( flip(c).length ).toEqual c.length\n    \n    # expect( flip(d).length ).toEqual d.length\n    # NO; We do not guarantee arity for length > 3\n    \n  it 'should be self-currying', ->\n    expect( flip(b)(1)(2) ).toEqual [2, 1]\n    expect( flip(c)(1)(2)(3) ).toEqual [3, 2, 1]\n    expect( flip(d)(1)(2)(3)(4) ).toEqual [4, 3, 2, 1]"
  },
  {
    "path": "spec/decorating-classes.spec.coffee",
    "content": "{classDecorator, mixin, fluent} = require('../lib/allong.es.js').allong.es\n\nclass Todo\n  constructor: (name) ->\n    self = if this instanceof Todo\n             this\n           else\n             new Todo()\n    self.name = name or 'Untitled'\n    self.done = false\n  do: fluent -> this.done = true\n  undo: fluent -> this.done = false\n  \ndescribe \"features\", ->\n  it \"should include mixin\", ->\n    expect(typeof mixin).toEqual 'function'\n  it \"should include classDecorator\", ->\n    expect(typeof classDecorator).toEqual 'function'\n\ndescribe \"classDecorator\", ->\n\n  AndColourCoded = classDecorator\n    setColourRGB: (r, g, b) ->\n      @colourCode = { r, g, b }\n      this\n    getColourRGB: -> @colourCode\n\n  ColourTodo = AndColourCoded Todo\n\n  todo = new ColourTodo('Use More Decorators')\n        .setColourRGB(0, 255, 0)\n\n  it \"should set the name correctly\", ->\n    expect( todo.name ).toEqual \"Use More Decorators\"\n\n  it \"should set the colour code correctly\", ->\n    expect( todo.getColourRGB() ).toEqual\n      r: 0\n      g: 255\n      b: 0\n\ndescribe \"mixin\", ->\n\n  LocationAware = mixin\n    setLocation: (@location) -> this\n    getLocation: -> @location\n    \n  describe \"Using context\", ->\n\n    it \"should add location to the existing class's prototype\", ->\n      LocationAware.call(Todo.prototype)\n      expect( typeof Todo.prototype.setLocation ).toEqual 'function'\n      expect( typeof Todo.prototype.getLocation ).toEqual 'function'\n      \n  describe \"Using a parameter\", ->\n    \n    a = { a: 'a' }\n    b = { b: 'b' }\n    c = { c: 'b' }\n    \n    it \"should not add the location to the context\", ->\n      LocationAware.call(a, b)\n      expect( a.setLocation ).toBeUndefined()\n      expect( a.getLocation ).toBeUndefined()\n      expect( typeof b.setLocation ).toEqual 'function'\n      expect( typeof b.getLocation ).toEqual 'function'\n      \n    it \"should add the location when called normally\", ->\n      LocationAware(c)\n      expect( typeof c.setLocation ).toEqual 'function'\n      expect( typeof c.getLocation ).toEqual 'function'\n    "
  },
  {
    "path": "spec/folding.spec.coffee",
    "content": "{mapWith, deepMapWith, filter} = require('../lib/allong.es.js').allong.es\n\nsquare = (n) -> n * n\n\ndescribe 'mapWith', ->\n  \n  it 'should square some numbers', ->\n    \n    expect( mapWith(square)([1..5]) ).toEqual [1, 4, 9, 16, 25]\n\ndescribe 'deepMapWith', ->\n  \n  it 'should square some numbers', ->\n    \n    expect( deepMapWith(square)([1, [2..4], 5]) ).toEqual [1, [4, 9, 16], 25]\n    \ndescribe \"filter\", ->\n  \n  it \"should find odd numbers\", ->\n    \n    expect( filter([1, 2, 3, 4, 5, 6], '% 2 === 1') ).toEqual [1, 3, 5]\n  \n  it \"should be self-currying\", ->\n    \n    expect( filter([1, 2, 3, 4, 5, 6])('% 2 === 0') ).toEqual [2, 4, 6]"
  },
  {
    "path": "spec/iterators.spec.coffee",
    "content": "{iterators: {slice, drop, take, accumulate, accumulateWithReturn, \n             fold, map, filter, FlatArrayIterator, RecursiveArrayIterator,\n             unfold, unfoldWithReturn}} = require('../lib/allong.es.js').allong.es\n\ndescribe \"FlatArrayIterator\", ->\n  \n  it \"should iterate over a flat array\", ->\n    i = FlatArrayIterator([1, 2, 3, 4, 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).toEqual(2)\n    expect( i() ).toEqual(3)\n    expect( i() ).toEqual(4)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n    \n  it \"should not iterate down through an array\", ->\n    i = FlatArrayIterator([1, [2, 3, [4]], 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).not.toEqual(2)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n  \n  it \"should have no values given an empty array\", ->\n    i = FlatArrayIterator([])\n    expect( i() ).toBeUndefined()\n  \n  it \"should have a values given an empty tree\", ->\n    i = FlatArrayIterator([[], [[]]])\n    expect( i() ).not.toBeUndefined()\n\ndescribe \"RecursiveArrayIterator\", ->\n  \n  it \"should have no values given an empty array\", ->\n    i = RecursiveArrayIterator([])\n    expect( i() ).toBeUndefined()\n  \n  it \"should have no values given an empty tree\", ->\n    i = RecursiveArrayIterator([[], [[]]])\n    expect( i() ).toBeUndefined()\n  \n  it \"should iterate over a flat array\", ->\n    i = RecursiveArrayIterator([1, 2, 3, 4, 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).toEqual(2)\n    expect( i() ).toEqual(3)\n    expect( i() ).toEqual(4)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n    \n  it \"should also iterate down through an array\", ->\n    i = RecursiveArrayIterator([1, [2, 3, [4]], 5])\n    expect( i() ).toEqual(1)\n    expect( i() ).toEqual(2)\n    expect( i() ).toEqual(3)\n    expect( i() ).toEqual(4)\n    expect( i() ).toEqual(5)\n    expect( i() ).toBeUndefined()\n\nsum = (x, y) -> x + y\n\ndescribe \"fold\", ->\n  \n    describe \"with a seed\", ->\n  \n      it \"should fold an iterator with many elements\", ->\n        expect( fold(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum, 0) ).toEqual(15)\n  \n      it \"should fold an iterator with one element\", ->\n        expect( fold(RecursiveArrayIterator([[[4], []]]), sum, 42) ).toEqual(46)\n  \n      it \"should fold an empty iterator\", ->\n        expect( fold(RecursiveArrayIterator([[], [[]]]), sum, 42) ).toEqual(42)\n      \n    describe \"without a seed\", ->\n      \n      it \"should fold an array with two or more elements\", ->\n        expect( fold(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum) ).toEqual(15)\n      \n      it \"should fold an array with one element\", ->\n        expect( fold(RecursiveArrayIterator([[[4], []]]), sum) ).toEqual(4)\n      \n      it \"should fold an array with no elements\", ->\n        expect( fold(RecursiveArrayIterator([[[], []]]), sum) ).toBeUndefined()\n\ndescribe \"accumulate\", ->\n  \n    describe \"with a seed\", ->\n  \n      it \"should map an iterator with many elements\", ->\n        i = accumulate(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum, 0)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(3)\n        expect( i() ).toEqual(6)\n        expect( i() ).toEqual(10)\n        expect( i() ).toEqual(15)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an iterator with one element\", ->\n        i = accumulate(RecursiveArrayIterator([[[4], []]]), sum, 42)\n        expect( i() ).toEqual(46)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an empty iterator\", ->\n        i = accumulate(RecursiveArrayIterator([[[], []]]), sum, 42)\n        expect( i() ).toBeUndefined()\n      \n    describe \"without a seed\", ->\n  \n      it \"should map an iterator with many elements\", ->\n        i = accumulate(RecursiveArrayIterator([1, [2, 3, [4]], 5]), sum)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(3)\n        expect( i() ).toEqual(6)\n        expect( i() ).toEqual(10)\n        expect( i() ).toEqual(15)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an iterator with one element\", ->\n        i = accumulate(RecursiveArrayIterator([[[4], []]]), sum)\n        expect( i() ).toEqual(4)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an empty iterator\", ->\n        i = accumulate(RecursiveArrayIterator([[[], []]]), sum)\n        expect( i() ).toBeUndefined()\n\nsquare = (x) -> x*x\n\ndescribe \"map\", ->\n  \n      it \"should map an iterator with many elements\", ->\n        i = map(RecursiveArrayIterator([1, [2, 3, [4]], 5]), square)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(4)\n        expect( i() ).toEqual(9)\n        expect( i() ).toEqual(16)\n        expect( i() ).toEqual(25)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an iterator with one element\", ->\n        i = map(RecursiveArrayIterator([[[4], []]]), square)\n        expect( i() ).toEqual(16)\n        expect( i() ).toBeUndefined()\n  \n      it \"should map an empty iterator\", ->\n        i = map(RecursiveArrayIterator([[[], []]]), square)\n        expect( i() ).toBeUndefined()\n\nodd = (x) -> x % 2 is 1\n\ndescribe \"filter\", ->\n  \n      it \"should filter an iterator with many elements\", ->\n        i = filter(RecursiveArrayIterator([1, [2, 3, [4]], 5]), odd)\n        expect( i() ).toEqual(1)\n        expect( i() ).toEqual(3)\n        expect( i() ).toEqual(5)\n        expect( i() ).toBeUndefined()\n  \n      it \"should filter an iterator with one element\", ->\n        i = filter(RecursiveArrayIterator([[[4], []]]), odd)\n        expect( i() ).toBeUndefined()\n  \n      it \"should filter an empty iterator\", ->\n        i = filter(RecursiveArrayIterator([[[], []]]), odd)\n        expect( i() ).toBeUndefined()\n  \n      it \"should filter an iterator with no matches\", ->\n        i = filter(FlatArrayIterator([2, 4, 6, 8, 10]), odd)\n        expect( i() ).toBeUndefined()\n\ndescribe \"slice\", ->\n  \n  describe \"with two parameter\", ->\n    \n    it \"should return an identity iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n    \n    it \"should return a trailing iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n      \n    it \"should return an empty iterator when out of range\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 5)\n      expect( i() ).toBeUndefined()\n  \n  describe \"with three parameters\", ->\n    \n    it \"should return an identity iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0, 5)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0, 99)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n    \n    it \"should return a leading iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 0, 4)\n      expect( i() ).toEqual 1\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toBeUndefined()\n    \n    it \"should return a trailing iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 4)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 99)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toEqual 5\n      expect( i() ).toBeUndefined()\n    \n    it \"should return an inner iterator\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 3)\n      expect( i() ).toEqual 2\n      expect( i() ).toEqual 3\n      expect( i() ).toEqual 4\n      expect( i() ).toBeUndefined()\n      \n    it \"should return an empty iterator when given a zero length\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 1, 0)\n      expect( i() ).toBeUndefined()\n      \n    it \"should return an empty iterator when out of range\", ->\n      i = slice(FlatArrayIterator([1, 2, 3, 4, 5]), 5, 1)\n      expect( i() ).toBeUndefined()\n      \ndescribe \"drop\", ->\n  \n  it \"should drop the number of items dropped\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]), 2)\n    expect( i() ).toEqual 3\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 5\n    expect( i() ).toBeUndefined()\n  \n  it \"should handle overdropping\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]), 99)\n    expect( i() ).toBeUndefined()\n    \n  it \"should handle underdropping\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]), 0)\n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 2\n    expect( i() ).toEqual 3\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 5\n    expect( i() ).toBeUndefined()\n    \n  it \"should default to one\", ->\n    i = drop(FlatArrayIterator([1, 2, 3, 4, 5]))\n    expect( i() ).toEqual 2\n    expect( i() ).toEqual 3\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 5\n    expect( i() ).toBeUndefined()\n    \ndescribe \"accumulateWithReturn\", ->\n  \n  it \"should pass the state and result in a pair\", ->\n    i = accumulateWithReturn(FlatArrayIterator([1, 2, 3, 4, 5]), (state, element) ->\n      [state + element, 'Total is ' + (state + element)]\n    , 0);\n    \n    expect( i() ).toEqual 'Total is 1'\n    expect( i() ).toEqual 'Total is 3'\n    expect( i() ).toEqual 'Total is 6'\n    expect( i() ).toEqual 'Total is 10'\n    expect( i() ).toEqual 'Total is 15'\n    \ndescribe \"unfold\", ->\n  \n  it \"should unfold and include the seed\", ->\n    i = unfold 0, (n) -> n + 1\n    \n    expect( i() ).toEqual 0\n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 2\n  \n  it \"should not unfold without a seed\", ->\n    i = unfold undefined, (n) -> n + 1\n    \n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n\ndescribe \"unfoldWithReturn\", ->\n  \n  it \"should unfold and throw off a value\", ->\n    i = unfoldWithReturn 1, (n) -> [n + 1, n*n]\n    \n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 9\n    expect( i() ).toEqual 16\n  \n  it \"should halt if it returns undefined\", ->\n    i = unfoldWithReturn 1, (n) ->\n      [n + 1, if n is 1 then undefined else n * n]\n    \n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n    expect( i() ).toEqual undefined\n  \n  it \"should halt if the state becomes undefined\", ->\n    i = unfoldWithReturn 1, (n) ->\n      [(if n is 3 then undefined else n + 1), (if n is undefined then 100 else n * n)]\n    \n    expect( i() ).toEqual 1\n    expect( i() ).toEqual 4\n    expect( i() ).toEqual 9\n    expect( i() ).toEqual undefined"
  },
  {
    "path": "spec/map-arguments-with.spec.coffee",
    "content": "{mapArgumentsWith, variadic, maybe} = require('../lib/allong.es').allong.es\n\nmyArgs = variadic (a) -> a \ndouble = (n) -> n * 2\nplus1 = (n) -> n + 1\n\ndescribe \"mapArgumentsWith\", ->\n  \n  it \"should map some simple integers\", ->\n    expect( mapArgumentsWith(double, myArgs)(1, 2, 3) ).toEqual [2, 4, 6]\n    \n  it \"should curry\", ->\n    expect( mapArgumentsWith(double)(myArgs)(1, 2, 3) ).toEqual [2, 4, 6]\n    \n  it \"should construct nice decorators\", ->\n    doubleYourArguments = mapArgumentsWith(double)\n    expect( (doubleYourArguments myArgs)(1, 2, 3) ).toEqual [2, 4, 6]\n    \ndescribe \"self-mapping\", ->\n  \n  describe \"maybe\", ->\n    \n    it \"should return a function for a function\", ->\n      expect( maybe(double)(2) ).toEqual 4\n      expect( maybe(double)(undefined) ).toBeUndefined()\n      \n    it \"should return an array for multiple items\", ->\n      expect( maybe(double, plus1)[0](4) ).toEqual 8\n      expect( maybe(double, plus1)[0](undefined) ).toBeUndefined()\n      expect( maybe(double, plus1)[1](4) ).toEqual 5\n      expect( maybe(double, plus1)[1](undefined) ).toBeUndefined()\n  \n  "
  },
  {
    "path": "spec/sequence-objects.spec.coffee",
    "content": "{sequence, flatten} = require('../lib/allong.es').allong.es\n\nWithLogging =\n  chain: (valueAndLogList, fn) ->\n    value = valueAndLogList[0]\n    logList = valueAndLogList[1]\n    resultAndLogList = fn(value)\n    result = resultAndLogList[0]\n    resultLogList = flatten(logList.concat(resultAndLogList[1]))\n    [result, resultLogList]\n  of: (argument) -> [argument, []]\n\ndouble = (number) ->\n  result = number * 2\n  [result, ['' + number + ' * 2 = ' + result]]\n\nplus1 = (number) ->\n  result = number + 1\n  [result, ['' + number + ' + 1 = ' + result]]  \n\ndescribe \"sequence with object definitions\", ->\n  \n  it \"should work for some simple math\", ->\n    expect( sequence(WithLogging, double, plus1 )(2) ).toEqual [5, ['2 * 2 = 4', '4 + 1 = 5']]"
  },
  {
    "path": "spec/sequence.advanced.spec.coffee",
    "content": "{sequence, sequence: {Identity, Maybe, Writer, List, Then, Callback}} = require('../lib/allong.es.js').allong.es\n\ndescribe \"Sequence\", ->\n  \n  describe \"Naive\", ->\n\n    double = (n) -> n + n\n    plusOne = (n) -> n + 1\n  \n    it \"should be a thing\", ->\n      expect( sequence ).not.toBeNull()\n    \n    it \"should return a function when given a function\", ->\n      expect( sequence(double) ).not.toBeNull()\n  \n    it \"should do a single function\", ->\n      expect( sequence(double)(3) ).toEqual 6\n  \n    it \"should do two functions\", ->\n      expect( sequence(double, plusOne)(3) ).toEqual 7\n    \n  describe \"Identity\", ->\n\n    double = (n) -> n + n\n    plusOne = (n) -> n + 1\n    \n    it \"should be a thing\", ->\n      expect( Identity ).not.toBeNull()    \n  \n    it \"should do a single function\", ->\n      expect( sequence(Identity, double)(3) ).toEqual 6\n  \n    it \"should do two functions\", ->\n      expect( sequence(Identity, double, plusOne)(3) ).toEqual 7\n    \n  describe \"Maybe\", ->\n\n    double = (n) -> n + n\n    plusOne = (n) -> n + 1\n  \n    it \"should pass numbers through\", ->\n      expect( sequence(Maybe, double, plusOne)(3) ).toEqual 7\n  \n    it \"should pass null through\", ->\n      expect( sequence(Maybe, double, plusOne)(null) ).toBeNull()\n  \n    it \"should pass undefined through\", ->\n      expect( sequence(Maybe, double, plusOne)(undefined) ).toBeUndefined()\n    \n    it \"should short-circuit\", ->\n      expect( sequence(Maybe, double, ((x) ->), plusOne)(undefined) ).toBeUndefined()\n      \n  describe \"Writer\", ->\n  \n    parity = (n) ->\n      [\n        n\n        if n % 2 is 0 then 'even' else 'odd'\n      ]\n    \n    space = (n) ->\n      [\n        n\n        ' '\n      ]\n    \n    size = (n) ->\n      [\n        n\n        if n < 10 then 'small' else 'normal'\n      ]\n  \n    it \"should accumulate writes\", ->\n      expect( sequence(Writer, parity, space, size)(5) ).toEqual [5, 'odd small']\n    \n  describe 'List', ->\n  \n    oneToN = (n) ->\n      [1..n]\n  \n    nToOne = (n) ->\n      [n..1]\n    \n    it \"should handle two levels of lists\", ->\n      expect( sequence(List, oneToN, nToOne)(3) ).toEqual [1, 2, 1, 3, 2, 1]"
  },
  {
    "path": "spec/sequence.callback.spec.coffee",
    "content": "{sequence, sequence: {Identity, Maybe, Writer, List, Then, Callback}} = require('../lib/allong.es.js').allong.es\n\ndescribe \"Sequence\", ->\n      \n  describe \"Callback\", ->\n    \n    identity = (v) -> v\n      \n    describe \"with one parameter\", ->\n\n      double = (v, c) -> c(v * 2)\n      plus1 = (v, c) -> c(v + 1)\n  \n      it \"should work for a double\", ->\n    \n        expect( sequence(Callback, double)(42, identity) ).toBe 84\n  \n      it \"should work for a double double\", ->\n    \n        expect( sequence(Callback, double, double)(2, identity) ).toBe 8\n  \n      it \"should work for a double plus1 double\", ->\n    \n        expect( sequence(Callback, double, plus1, double)(2, identity) ).toBe 10\n        \n    describe \"with multiple parameters\", ->\n      \n      argsToArray = (args..., callback) ->\n        callback(args)\n      \n      argsToArgs = (args..., callback) ->\n        callback(args...)\n      \n      it \"should work for a singleton\", ->\n        expect( sequence(Callback, argsToArgs, argsToArray)(1, identity) ).toEqual [1]\n      \n      it \"should work for a doubleton\", ->\n        expect( sequence(Callback, argsToArgs, argsToArray)(1, 2, identity) ).toEqual [1, 2]"
  },
  {
    "path": "spec/sequence.decorataors.spec.coffee",
    "content": "{sequence, maybe, andand, oror} = require('../lib/allong.es.js').allong.es\n\ndescribe \"Sequence Decorations\", ->\n  \n  identity = (fn) -> fn\n  identitywrapper = (fn) -> (value) -> fn(value)\n  double = (n) -> n + n\n  plusOne = (n) -> n + 1\n  nothing = (x) ->\n    \n  describe \"maybe\", ->\n    \n    it \"for a number\", ->\n      expect(\n        sequence(\n          maybe(\n            double, \n            plusOne))(3)\n      ).toEqual sequence(maybe(double), maybe(plusOne))(3)\n      \n    it \"for a null\", ->\n      expect(\n        sequence(\n          maybe(\n            double, \n            plusOne))(null)\n      ).toEqual sequence(maybe(double), maybe(plusOne))(null)\n      \n    it \"for undefined\", ->\n      expect(\n        sequence(\n          maybe(\n            double, \n            plusOne))(undefined)\n      ).toEqual sequence(maybe(double), maybe(plusOne))(undefined)\n    \n    it \"should short-circuit\", ->\n      expect(\n        sequence(\n          maybe(\n            double, \n            nothing,\n            plusOne))(10)\n      ).toEqual sequence(maybe(double), maybe(nothing), maybe(plusOne))(10)"
  },
  {
    "path": "spec/sequence.then.spec.coffee",
    "content": "Promise = require 'promise'\n\n{sequence} = require('../lib/allong.es.js').allong.es\n\n# also demonstrates string shorthand\n\ndescribe \"Then\", ->\n    \n  double = (value) ->\n    new Promise (resolve, reject) ->\n      resolve(value * 2)\n      \n  success = undefined\n  failure = undefined\n      \n  beforeEach ->\n      \n    success = undefined\n    failure = undefined\n  \n  describe \"for a doubling promise\", ->\n  \n    it \"should work asynchronously\", (done) ->\n      \n      sequencedPromise = sequence('Then', double)(3)\n            \n      sequencedPromise.then ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done())\n            \n    afterEach ->    \n      expect( success ).toEqual 6\n      expect( failure ).toBeUndefined()\n  \n  describe \"for a double double\", ->\n  \n    it \"should work asynchronously\", (done) ->\n      \n      sequencedPromise = sequence('Then', double, double)(2)\n            \n      sequencedPromise.then ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done())\n            \n    afterEach ->    \n      expect( success ).toEqual 8\n      expect( failure ).toBeUndefined()\n  \n  describe \"for a double fail double\", ->\n  \n    it \"should fail forward\", (done) ->\n      \n      failer = (value) ->\n        new Promise (resolve, reject) ->\n          reject 'sorry, old chap'\n      \n      sequencedPromise = sequence('Then', double, failer, double)(2)\n            \n      sequencedPromise.then( ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done()))\n            \n    afterEach ->    \n      expect( success ).toBeUndefined()\n      expect( failure ).toBe 'sorry, old chap'\n      "
  },
  {
    "path": "spec/sequence.transformers.spec.coffee",
    "content": "Promise = require 'promise'\n\n{sequence, sequence: {Then, Callback, fn2Then, fn2Callback, callback2Then, then2Callback}} = require('../lib/allong.es.js').allong.es\n\ndescribe \"fn2Then\", ->\n  \n  plus1 = (value) -> value + 1\n    \n  double = (value) ->\n    new Promise (resolve, reject) ->\n      resolve(value * 2)\n      \n  success = undefined\n  failure = undefined\n      \n  beforeEach ->\n      \n    success = undefined\n    failure = undefined\n  \n  describe \"for a single function\", ->\n  \n    it \"should work \", (done) ->\n      \n      sequencedPromise = sequence(Then,\n        double,\n        fn2Then(plus1),\n        double\n      )(1)\n            \n      sequencedPromise.then ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done())\n            \n    afterEach ->    \n      expect( success ).toEqual 6\n      expect( failure ).toBeUndefined()\n\ndescribe \"callback2Then\", ->\n  \n  plus1 = (value, callback) ->\n    callback(value + 1)\n    \n  double = (value) ->\n    new Promise (resolve, reject) ->\n      resolve(value * 2)\n      \n  success = undefined\n  failure = undefined\n      \n  beforeEach ->\n      \n    success = undefined\n    failure = undefined\n  \n  describe \"for a single function\", ->\n  \n    it \"should work \", (done) ->\n      \n      sequencedPromise = sequence(Then,\n        double,\n        callback2Then(plus1),\n        double\n      )(1)\n            \n      sequencedPromise.then ((value) ->\n        success = value\n        done()),\n          ((reason) ->\n            failure = reason\n            done())\n            \n    afterEach ->    \n      expect( success ).toEqual 6\n      expect( failure ).toBeUndefined()\n\ndescribe \"fn2Callback\", ->\n  \n  plus1 = (value) -> value + 1\n    \n  double = (value, callback) ->\n    callback(value * 2)\n    \n  identity = (n) -> n\n  \n  it \"should work for a double plus1 double\", ->\n\n    expect(\n      sequence(Callback, \n        double, \n        fn2Callback(plus1), \n        double\n      )(2, identity) ).toBe 10\n\ndescribe \"then2Callback\", ->\n  \n  plus1 = (value) ->\n    new Promise (resolve, reject) ->\n      resolve(value + 1)\n    \n  double = (value, callback) ->\n    callback(value * 2)\n    \n  identity = (n) -> n\n      \n  success = undefined\n  failure = undefined\n      \n  beforeEach ->\n      \n    success = undefined\n    failure = undefined\n  \n  describe \"for a single function\", ->\n  \n    it \"should work \", (done) ->\n\n      sequence(Callback, \n        double, \n        then2Callback(plus1), \n        double\n      )(2, (value) -> \n        success = value\n        done())\n            \n    afterEach ->    \n      expect( success ).toEqual 10\n      expect( failure ).toBeUndefined()"
  },
  {
    "path": "spec/trampoline.spec.coffee",
    "content": "{trampoline, tailCall} = require('../lib/allong.es.js').allong.es\n\ndescribe \"trampolining\", ->\n\n  depth = 32768\n\n  it \"should execute a clean even/odd to #{depth} levels\", ->\n  \n    even = trampoline (n) ->\n      if n is 0\n        true\n      else\n        tailCall odd, n - 1\n  \n    odd = trampoline (n) ->\n      if n is 0\n        false\n      else\n        tailCall even, n - 1\n  \n    expect( even(0) ).toEqual true\n    expect( even(1) ).toEqual false\n    expect( even(2) ).toEqual true\n    expect( even(3) ).toEqual false\n    expect(-> even(depth) ).not.toThrow()\n    \n  it \"should allow tail calling a co-recursive non-trampolined function too\", ->\n  \n    even2 = trampoline (n) ->\n      if n is 0\n        true\n      else\n        tailCall odd2, n - 1\n  \n    odd2 = (n) ->\n      if n is 0\n        false\n      else\n        even2 n - 1\n  \n    expect(-> even2(1000) ).not.toThrow()\n    expect( even2(100) ).toEqual true\n    expect( even2(101) ).toEqual false"
  }
]