Comparing version 1.0.0-alpha-21 to 1.0.0-beta-01
@@ -9,3 +9,3 @@ // Generated by CoffeeScript 1.9.2 | ||
describe("Functional programming functions", function(context) { | ||
var _, async, binary, compose, curry, deep_equal, flip, identity, no_op, partial, pipe, promise, ternary, unary, variadic, wrap; | ||
var _, binary, compose, curry, deep_equal, flip, identity, no_op, partial, pipe, ternary, unary, variadic, wrap; | ||
deep_equal = function(a, b) { | ||
@@ -132,4 +132,2 @@ assert = require("assert"); | ||
}); | ||
promise = require("when"); | ||
async = require("./generator").async; | ||
compose = function() { | ||
@@ -142,11 +140,15 @@ var f, fx, g, i; | ||
g = compose.apply(null, fx); | ||
return async(function*() { | ||
var ax; | ||
return function() { | ||
var ax, f_ax; | ||
ax = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
return (yield promise(g((yield promise(f.apply(null, ax)))))); | ||
}); | ||
if ((f_ax = f.apply(null, ax)).then != null) { | ||
return f_ax.then(g); | ||
} else { | ||
return g(f_ax); | ||
} | ||
}; | ||
} | ||
}; | ||
context.test("compose", function() { | ||
var clone, data, parse, stringify; | ||
context.test("compose", function*() { | ||
var _parse, _stringify, clone, clone_1, clone_2, clone_3, data, parse, promise, stringify; | ||
data = { | ||
@@ -159,3 +161,24 @@ foo: 1, | ||
clone = compose(parse, stringify); | ||
return assert(deep_equal(clone(data), data)); | ||
assert(deep_equal(clone(data), data)); | ||
promise = require("when").promise; | ||
_stringify = function(x) { | ||
return promise(function(resolve) { | ||
return setTimeout((function() { | ||
return resolve(stringify(x)); | ||
}), 100); | ||
}); | ||
}; | ||
_parse = function(s) { | ||
return promise(function(resolve) { | ||
return setTimeout((function() { | ||
return resolve(parse(s)); | ||
}), 100); | ||
}); | ||
}; | ||
clone_1 = compose(parse, _stringify); | ||
clone_2 = compose(_parse, stringify); | ||
clone_3 = compose(_parse, _stringify); | ||
assert(deep_equal((yield clone_1(data)), data)); | ||
assert(deep_equal((yield clone_2(data)), data)); | ||
return assert(deep_equal((yield clone_3(data)), data)); | ||
}); | ||
@@ -162,0 +185,0 @@ pipe = flip(compose); |
{ | ||
"name": "fairmont", | ||
"version": "1.0.0-alpha-21", | ||
"version": "1.0.0-beta-01", | ||
"description": "A collection of useful functions and utilities.", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
113380
2112