Comparing version 1.0.0-beta-16 to 1.0.0-beta-17
@@ -9,3 +9,3 @@ // Generated by CoffeeScript 1.9.3 | ||
describe("Iterator functions", function(context) { | ||
var $, Method, _flatten, add, all, any, assoc, async, asyncIterator, average, binary, cat, collect, compact, compose, curry, delimit, each, either, events, filter, first, flatten, fold, foldr, has, identity, isAsyncIterable, isAsyncIterator, isAsyncIteratorFunction, isDefined, isFunction, isGenerator, isIterable, isIterator, isIteratorFunction, isSource, iterator, iteratorFunction, join, lines, map, negate, partition, project, promise, property, query, reduce, reduceRight, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, reject, repeat, resolve, second, select, split, stream, sum, take, takeN, ternary, unzip, where, zip; | ||
var $, Method, _flatten, add, all, any, assoc, async, asyncIterator, average, binary, cat, collect, compact, compose, curry, delimit, each, either, events, filter, first, flatten, fold, foldr, has, identity, isAsyncIterable, isAsyncIterator, isAsyncIteratorFunction, isDefined, isFunction, isGenerator, isIterable, isIterator, isIteratorFunction, isPromise, isSource, iterator, iteratorFunction, join, lines, map, negate, partition, project, promise, property, query, reduce, reduceRight, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, ref9, reject, repeat, resolve, second, select, split, stream, sum, take, takeN, ternary, unzip, where, zip; | ||
isIterable = function(x) { | ||
@@ -149,2 +149,6 @@ return (x != null ? x[Symbol.iterator] : void 0) != null; | ||
}); | ||
isPromise = require("./type").isPromise; | ||
Method.define(map, Function, isPromise, async(function*(f, p) { | ||
return map(f, (yield p)); | ||
})); | ||
Method.define(map, Function, isIteratorFunction, function(f, i) { | ||
@@ -170,12 +174,12 @@ return iterator(function() { | ||
ref2 = (yield i()), done = ref2.done, value = ref2.value; | ||
if (done) { | ||
return { | ||
done: done | ||
}; | ||
} else { | ||
return { | ||
done: done, | ||
value: f(value) | ||
}; | ||
if (!done) { | ||
value = f(value); | ||
if (isPromise(value)) { | ||
value = (yield value); | ||
} | ||
} | ||
return { | ||
done: done, | ||
value: value | ||
}; | ||
}); | ||
@@ -815,2 +819,3 @@ }); | ||
map: map, | ||
each: each, | ||
fold: fold, | ||
@@ -817,0 +822,0 @@ reduce: reduce, |
@@ -9,3 +9,3 @@ // Generated by CoffeeScript 1.9.3 | ||
describe("Reactive programming functions", function(context) { | ||
var FS, async, curry, flow, iterator, pump, reduce, start, tee; | ||
var FS, async, curry, flow, iterator, pump, reduce, start, tee, throttle; | ||
FS = require("fs"); | ||
@@ -77,6 +77,30 @@ reduce = require("./iterator").reduce; | ||
}); | ||
throttle = curry(function(ms, i) { | ||
var last; | ||
last = 0; | ||
return iterator(function*() { | ||
var done, now, ref1, value; | ||
while (true) { | ||
ref1 = (yield i()), done = ref1.done, value = ref1.value; | ||
if (done) { | ||
break; | ||
} | ||
now = Date.now(); | ||
if (now - last >= ms) { | ||
break; | ||
} | ||
} | ||
last = now; | ||
return { | ||
done: done, | ||
value: value | ||
}; | ||
}); | ||
}); | ||
return module.exports = { | ||
flow: flow, | ||
start: start, | ||
pump: pump | ||
pump: pump, | ||
tee: tee, | ||
throttle: throttle | ||
}; | ||
@@ -83,0 +107,0 @@ }); |
@@ -10,3 +10,3 @@ // Generated by CoffeeScript 1.9.3 | ||
describe("Type functions", function(context) { | ||
var GeneratorFunction, instanceOf, isArray, isBoolean, isDate, isDefined, isFinite, isFloat, isFunction, isGenerator, isInteger, isNaN, isNumber, isObject, isRegexp, isString, isType, type; | ||
var GeneratorFunction, instanceOf, isArray, isBoolean, isDate, isDefined, isFinite, isFloat, isFunction, isGenerator, isInteger, isNaN, isNumber, isObject, isPromise, isRegexp, isString, isType, type; | ||
type = function(x) { | ||
@@ -79,13 +79,2 @@ return x != null ? x.constructor : void 0; | ||
}); | ||
GeneratorFunction = (function*() { | ||
return (yield null); | ||
}).constructor; | ||
isGenerator = isType(GeneratorFunction); | ||
context.test("isGenerator", function() { | ||
var f; | ||
f = function*() { | ||
return (yield true); | ||
}; | ||
return assert(isGenerator(f)); | ||
}); | ||
isObject = isType(Object); | ||
@@ -108,2 +97,16 @@ context.test("isObject", function() { | ||
}); | ||
GeneratorFunction = (function*() { | ||
return (yield null); | ||
}).constructor; | ||
isGenerator = isType(GeneratorFunction); | ||
context.test("isGenerator", function() { | ||
var f; | ||
f = function*() { | ||
return (yield true); | ||
}; | ||
return assert(isGenerator(f)); | ||
}); | ||
isPromise = function(x) { | ||
return ((x != null ? x.then : void 0) != null) && isFunction(x.then); | ||
}; | ||
return module.exports = { | ||
@@ -122,6 +125,7 @@ deepEqual: deepEqual, | ||
isFunction: isFunction, | ||
isGenerator: isGenerator, | ||
isObject: isObject, | ||
isArray: isArray, | ||
isDefined: isDefined | ||
isDefined: isDefined, | ||
isGenerator: isGenerator, | ||
isPromise: isPromise | ||
}; | ||
@@ -128,0 +132,0 @@ }); |
{ | ||
"name": "fairmont", | ||
"version": "1.0.0-beta-16", | ||
"version": "1.0.0-beta-17", | ||
"description": "A collection of useful functions and utilities.", | ||
@@ -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
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
155055
2779