fairmont-reactive
Advanced tools
Comparing version 1.0.0-beta-27 to 1.0.0-beta-28
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
var Method, _when, binary, compose, curry, events, flow, identity, isDefined, isFunction, isIterable, isIterator, isPromise, isReactor, isReagent, isSource, iterator, next, producer, promise, property, pull, reactor, ref, ref1, ref2, ref3, reject, repeat, resolve, stream, | ||
var Method, _when, apply, binary, combine, compose, curry, events, flow, identity, isArray, isDefined, isEmpty, isFunction, isIterable, isIterator, isProducer, isPromise, isReactor, isReagent, isSource, iterator, next, pipe, producer, promise, property, pull, reactor, ref, ref1, ref2, ref3, reject, repeat, resolve, stream, | ||
slice = [].slice; | ||
@@ -10,5 +10,5 @@ | ||
ref = require("fairmont-core"), curry = ref.curry, compose = ref.compose, binary = ref.binary, identity = ref.identity; | ||
ref = require("fairmont-core"), apply = ref.apply, pipe = ref.pipe, curry = ref.curry, compose = ref.compose, binary = ref.binary, identity = ref.identity; | ||
ref1 = require("fairmont-helpers"), isFunction = ref1.isFunction, isDefined = ref1.isDefined, isPromise = ref1.isPromise, property = ref1.property; | ||
ref1 = require("fairmont-helpers"), isEmpty = ref1.isEmpty, isFunction = ref1.isFunction, isArray = ref1.isArray, isDefined = ref1.isDefined, isPromise = ref1.isPromise, property = ref1.property; | ||
@@ -23,2 +23,6 @@ Method = require("fairmont-multimethods").Method; | ||
isProducer = function(x) { | ||
return (isIterator(x)) || (isReactor(x)); | ||
}; | ||
producer = Method.create(); | ||
@@ -34,6 +38,4 @@ | ||
Method.define(producer, isIterator, identity); | ||
Method.define(producer, isProducer, identity); | ||
Method.define(producer, isReactor, identity); | ||
Method.define(producer, isPromise, function(p) { | ||
@@ -97,2 +99,60 @@ var _p; | ||
combine = function() { | ||
var count, dequeue, done, enqueue, j, len, p, pending, px, resolved, wait; | ||
px = 1 <= arguments.length ? slice.call(arguments, 0) : []; | ||
count = px.length; | ||
done = false; | ||
pending = []; | ||
resolved = []; | ||
enqueue = function(x) { | ||
var p; | ||
if (pending.length === 0) { | ||
return resolved.push(x); | ||
} else { | ||
p = pending.shift(); | ||
return x.then(p.resolve)["catch"](p.reject); | ||
} | ||
}; | ||
dequeue = function() { | ||
if (resolved.length === 0) { | ||
if (!done) { | ||
return promise(function(resolve, reject) { | ||
return pending.push({ | ||
resolve: resolve, | ||
reject: reject | ||
}); | ||
}); | ||
} else { | ||
return resolve({ | ||
done: done | ||
}); | ||
} | ||
} else { | ||
return resolved.shift(); | ||
} | ||
}; | ||
wait = function(p) { | ||
var x; | ||
x = next(p); | ||
if (isPromise(x)) { | ||
return x.then(enqueue); | ||
} else { | ||
if (!x.done) { | ||
enqueue(x); | ||
return wait(p); | ||
} else { | ||
count--; | ||
if (count === 0) { | ||
return done = true; | ||
} | ||
} | ||
} | ||
}; | ||
for (j = 0, len = px.length; j < len; j++) { | ||
p = px[j]; | ||
wait(producer(p)); | ||
} | ||
return reactor(dequeue); | ||
}; | ||
repeat = function(x) { | ||
@@ -183,10 +243,26 @@ return iterator(function() { | ||
flow = function(arg) { | ||
var fx, x; | ||
x = arg[0], fx = 2 <= arg.length ? slice.call(arg, 1) : []; | ||
return fx.reduce((function(i, f) { | ||
return f(i); | ||
}), producer(x)); | ||
flow = Method.create(); | ||
flow.map = function(x) { | ||
return [x]; | ||
}; | ||
Method.define(flow, isDefined, function() { | ||
var fx, x; | ||
x = arguments[0], fx = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
return flow.apply(null, [producer(x)].concat(slice.call(fx))); | ||
}); | ||
Method.define(flow, isArray, function(arg) { | ||
var a, ax; | ||
a = arg[0], ax = 2 <= arg.length ? slice.call(arg, 1) : []; | ||
return flow.apply(null, [a].concat(slice.call(ax))); | ||
}); | ||
Method.define(flow, isProducer, function() { | ||
var fx, p; | ||
p = arguments[0], fx = 2 <= arguments.length ? slice.call(arguments, 1) : []; | ||
return apply(pipe.apply(null, fx), p); | ||
}); | ||
module.exports = { | ||
@@ -198,5 +274,6 @@ producer: producer, | ||
stream: stream, | ||
flow: flow | ||
flow: flow, | ||
combine: combine | ||
}; | ||
}).call(this); |
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
var Method, _when, async, binary, compact, curry, filter, isDefined, isFunction, isIterator, isReactor, isStreamLike, iterator, iteratorFunction, lines, map, negate, next, partition, producer, project, property, pump, query, reactor, reactorFunction, ref, ref1, ref2, ref3, reject, select, split, take, takeN, tee, throttle, where, | ||
var Method, _when, accumulate, async, binary, compact, curry, filter, isDefined, isFunction, isIterator, isReactor, isStreamLike, iterator, iteratorFunction, lines, map, negate, next, partition, producer, project, property, pump, query, reactor, reactorFunction, ref, ref1, ref2, ref3, reject, resolve, select, split, take, takeN, tee, throttle, where, | ||
slice = [].slice; | ||
@@ -107,2 +107,52 @@ | ||
accumulate = Method.create(); | ||
Method.define(accumulate, Function, (function() { | ||
return true; | ||
}), isDefined, function(f, k, x) { | ||
return accumulate(f, k, producer(x)); | ||
}); | ||
Method.define(accumulate, Function, (function() { | ||
return true; | ||
}), isIterator, function(f, k, i) { | ||
return iterator(function() { | ||
var done, ref4, value; | ||
ref4 = next(i), done = ref4.done, value = ref4.value; | ||
if (!done) { | ||
k = f(k, value); | ||
return { | ||
value: k, | ||
done: false | ||
}; | ||
} else { | ||
return { | ||
done: done | ||
}; | ||
} | ||
}); | ||
}); | ||
Method.define(accumulate, Function, (function() { | ||
return true; | ||
}), isReactor, function(f, k, i) { | ||
return reactor(function() { | ||
return (next(i)).then(function(arg) { | ||
var done, value; | ||
done = arg.done, value = arg.value; | ||
if (!done) { | ||
k = f(k, value); | ||
return { | ||
value: k, | ||
done: false | ||
}; | ||
} else { | ||
return { | ||
done: done | ||
}; | ||
} | ||
}); | ||
}); | ||
}); | ||
project = curry(function(p, i) { | ||
@@ -231,3 +281,3 @@ return map(property(p), i); | ||
return iterator(function() { | ||
var done, first, k, last, ref4, ref5, value; | ||
var done, first, l, last, ref4, ref5, value; | ||
if (lines.length > 0) { | ||
@@ -241,3 +291,3 @@ return { | ||
if (!done) { | ||
ref5 = f(value), first = ref5[0], lines = 3 <= ref5.length ? slice.call(ref5, 1, k = ref5.length - 1) : (k = 1, []), last = ref5[k++]; | ||
ref5 = f(value), first = ref5[0], lines = 3 <= ref5.length ? slice.call(ref5, 1, l = ref5.length - 1) : (l = 1, []), last = ref5[l++]; | ||
first = remainder + first; | ||
@@ -265,2 +315,4 @@ remainder = last; | ||
resolve = require("when").resolve; | ||
Method.define(split, Function, isReactor, function(f, i) { | ||
@@ -271,3 +323,3 @@ var lines, remainder; | ||
return reactor(async(function*() { | ||
var done, first, k, last, ref4, ref5, value; | ||
var done, first, l, last, ref4, ref5, value; | ||
if (lines.length > 0) { | ||
@@ -281,3 +333,3 @@ return { | ||
if (!done) { | ||
ref5 = f(value), first = ref5[0], lines = 3 <= ref5.length ? slice.call(ref5, 1, k = ref5.length - 1) : (k = 1, []), last = ref5[k++]; | ||
ref5 = f(value), first = ref5[0], lines = 3 <= ref5.length ? slice.call(ref5, 1, l = ref5.length - 1) : (l = 1, []), last = ref5[l++]; | ||
first = remainder + first; | ||
@@ -398,2 +450,3 @@ remainder = last; | ||
map: map, | ||
accumulate: accumulate, | ||
select: select, | ||
@@ -400,0 +453,0 @@ filter: filter, |
@@ -19,2 +19,4 @@ // Generated by CoffeeScript 1.9.3 | ||
include(module.exports, require("./helpers")); | ||
}).call(this); |
// Generated by CoffeeScript 1.9.3 | ||
(function() { | ||
var Method, W, async, asyncIterator, binary, compose, curry, either, has, identity, isAsyncIterable, isAsyncIterator, isDefined, isFunction, isGenerator, isPromise, isReactor, isReagent, negate, property, query, reactor, ref, ref1; | ||
var Method, async, asyncIterator, binary, curry, either, has, identity, isAsyncIterable, isAsyncIterator, isDefined, isFunction, isGenerator, isPromise, isReactor, isReagent, negate, property, query, reactor, ref, ref1, resolve; | ||
W = require("when"); | ||
resolve = require("when").resolve; | ||
ref = require("fairmont-core"), identity = ref.identity, curry = ref.curry, compose = ref.compose, binary = ref.binary, negate = ref.negate; | ||
ref = require("fairmont-core"), identity = ref.identity, curry = ref.curry, binary = ref.binary, negate = ref.negate; | ||
@@ -30,7 +30,17 @@ either = curry(function(f, g) { | ||
Method.define(reactor, isFunction, function(f) { | ||
f.next = f; | ||
f[Symbol.asyncIterator] = function() { | ||
var g; | ||
g = function() { | ||
var x; | ||
x = f.apply(null, arguments); | ||
if (isPromise(x)) { | ||
return x; | ||
} else { | ||
return resolve(x); | ||
} | ||
}; | ||
g.next = g; | ||
g[Symbol.asyncIterator] = function() { | ||
return this["this"]; | ||
}; | ||
return f; | ||
return g; | ||
}); | ||
@@ -37,0 +47,0 @@ |
{ | ||
"name": "fairmont-reactive", | ||
"version": "1.0.0-beta-27", | ||
"version": "1.0.0-beta-28", | ||
"description": "Functional reactive programming in JavaScript and CoffeeScript.", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57970
22
1364