Comparing version 0.1.10 to 0.1.11
332
flyd.js
@@ -1,10 +0,3 @@ | ||
(function (root, factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define([], factory); // AMD. Register as an anonymous module. | ||
} else if (typeof exports === 'object') { | ||
module.exports = factory(); // NodeJS | ||
} else { // Browser globals (root is window) | ||
root.flyd = factory(); | ||
} | ||
}(this, function () { | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var f;"undefined"!=typeof window?f=window:"undefined"!=typeof global?f=global:"undefined"!=typeof self&&(f=self),f.flyd=e()}}(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){ | ||
var curryN = require('ramda/src/curryN'); | ||
@@ -294,77 +287,141 @@ 'use strict'; | ||
function toArray(arg) { | ||
var arr = []; | ||
for (var i = 0; i < arg.length; ++i) { | ||
arr[i] = arg[i]; | ||
} | ||
return arr; | ||
} | ||
module.exports = { | ||
stream: stream, | ||
isStream: isStream, | ||
transduce: transduce, | ||
merge: merge, | ||
reduce: scan, // Legacy | ||
scan: scan, | ||
endsOn: endsOn, | ||
map: curryN(2, map), | ||
curryN: curryN, | ||
immediate: immediate, | ||
}; | ||
// Modified versions of arity and curryN from Ramda | ||
function ofArity(n, fn) { | ||
if (arguments.length === 1) { | ||
return ofArity.bind(undefined, n); | ||
} | ||
},{"ramda/src/curryN":4}],2:[function(require,module,exports){ | ||
/** | ||
* A special placeholder value used to specify "gaps" within curried functions, | ||
* allowing partial application of any combination of arguments, | ||
* regardless of their positions. | ||
* | ||
* If `g` is a curried ternary function and `_` is `R.__`, the following are equivalent: | ||
* | ||
* - `g(1, 2, 3)` | ||
* - `g(_, 2, 3)(1)` | ||
* - `g(_, _, 3)(1)(2)` | ||
* - `g(_, _, 3)(1, 2)` | ||
* - `g(_, 2, _)(1, 3)` | ||
* - `g(_, 2)(1)(3)` | ||
* - `g(_, 2)(1, 3)` | ||
* - `g(_, 2)(_, 3)(1)` | ||
* | ||
* @constant | ||
* @memberOf R | ||
* @category Function | ||
* @example | ||
* | ||
* var greet = R.replace('{name}', R.__, 'Hello, {name}!'); | ||
* greet('Alice'); //=> 'Hello, Alice!' | ||
*/ | ||
module.exports = {ramda: 'placeholder'}; | ||
},{}],3:[function(require,module,exports){ | ||
var _curry2 = require('./internal/_curry2'); | ||
/** | ||
* Wraps a function of any arity (including nullary) in a function that accepts exactly `n` | ||
* parameters. Unlike `nAry`, which passes only `n` arguments to the wrapped function, | ||
* functions produced by `arity` will pass all provided arguments to the wrapped function. | ||
* | ||
* @func | ||
* @memberOf R | ||
* @sig (Number, (* -> *)) -> (* -> *) | ||
* @category Function | ||
* @param {Number} n The desired arity of the returned function. | ||
* @param {Function} fn The function to wrap. | ||
* @return {Function} A new function wrapping `fn`. The new function is | ||
* guaranteed to be of arity `n`. | ||
* @example | ||
* | ||
* var takesTwoArgs = function(a, b) { | ||
* return [a, b]; | ||
* }; | ||
* takesTwoArgs.length; //=> 2 | ||
* takesTwoArgs(1, 2); //=> [1, 2] | ||
* | ||
* var takesOneArg = R.arity(1, takesTwoArgs); | ||
* takesOneArg.length; //=> 1 | ||
* // All arguments are passed through to the wrapped function | ||
* takesOneArg(1, 2); //=> [1, 2] | ||
*/ | ||
module.exports = _curry2(function(n, fn) { | ||
switch (n) { | ||
case 0: | ||
return function () { | ||
return fn.apply(this, arguments); | ||
}; | ||
case 1: | ||
return function (a0) { | ||
void a0; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 2: | ||
return function (a0, a1) { | ||
void a1; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 3: | ||
return function (a0, a1, a2) { | ||
void a2; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 4: | ||
return function (a0, a1, a2, a3) { | ||
void a3; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 5: | ||
return function (a0, a1, a2, a3, a4) { | ||
void a4; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 6: | ||
return function (a0, a1, a2, a3, a4, a5) { | ||
void a5; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 7: | ||
return function (a0, a1, a2, a3, a4, a5, a6) { | ||
void a6; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 8: | ||
return function (a0, a1, a2, a3, a4, a5, a6, a7) { | ||
void a7; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 9: | ||
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) { | ||
void a8; | ||
return fn.apply(this, arguments); | ||
}; | ||
case 10: | ||
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { | ||
void a9; | ||
return fn.apply(this, arguments); | ||
}; | ||
default: | ||
throw new Error('First argument to arity must be a non-negative integer no greater than ten'); | ||
case 0: return function() {return fn.apply(this, arguments);}; | ||
case 1: return function(a0) {void a0; return fn.apply(this, arguments);}; | ||
case 2: return function(a0, a1) {void a1; return fn.apply(this, arguments);}; | ||
case 3: return function(a0, a1, a2) {void a2; return fn.apply(this, arguments);}; | ||
case 4: return function(a0, a1, a2, a3) {void a3; return fn.apply(this, arguments);}; | ||
case 5: return function(a0, a1, a2, a3, a4) {void a4; return fn.apply(this, arguments);}; | ||
case 6: return function(a0, a1, a2, a3, a4, a5) {void a5; return fn.apply(this, arguments);}; | ||
case 7: return function(a0, a1, a2, a3, a4, a5, a6) {void a6; return fn.apply(this, arguments);}; | ||
case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {void a7; return fn.apply(this, arguments);}; | ||
case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {void a8; return fn.apply(this, arguments);}; | ||
case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {void a9; return fn.apply(this, arguments);}; | ||
default: throw new Error('First argument to arity must be a non-negative integer no greater than ten'); | ||
} | ||
} | ||
}); | ||
function curryN(length, fn) { | ||
return ofArity(length, function () { | ||
},{"./internal/_curry2":6}],4:[function(require,module,exports){ | ||
var __ = require('./__'); | ||
var _curry2 = require('./internal/_curry2'); | ||
var _slice = require('./internal/_slice'); | ||
var arity = require('./arity'); | ||
/** | ||
* Returns a curried equivalent of the provided function, with the | ||
* specified arity. The curried function has two unusual capabilities. | ||
* First, its arguments needn't be provided one at a time. If `g` is | ||
* `R.curryN(3, f)`, the following are equivalent: | ||
* | ||
* - `g(1)(2)(3)` | ||
* - `g(1)(2, 3)` | ||
* - `g(1, 2)(3)` | ||
* - `g(1, 2, 3)` | ||
* | ||
* Secondly, the special placeholder value `R.__` may be used to specify | ||
* "gaps", allowing partial application of any combination of arguments, | ||
* regardless of their positions. If `g` is as above and `_` is `R.__`, | ||
* the following are equivalent: | ||
* | ||
* - `g(1, 2, 3)` | ||
* - `g(_, 2, 3)(1)` | ||
* - `g(_, _, 3)(1)(2)` | ||
* - `g(_, _, 3)(1, 2)` | ||
* - `g(_, 2)(1)(3)` | ||
* - `g(_, 2)(1, 3)` | ||
* - `g(_, 2)(_, 3)(1)` | ||
* | ||
* @func | ||
* @memberOf R | ||
* @category Function | ||
* @sig Number -> (* -> a) -> (* -> a) | ||
* @param {Number} length The arity for the returned function. | ||
* @param {Function} fn The function to curry. | ||
* @return {Function} A new, curried function. | ||
* @see R.curry | ||
* @example | ||
* | ||
* var addFourNumbers = function() { | ||
* return R.sum([].slice.call(arguments, 0, 4)); | ||
* }; | ||
* | ||
* var curriedAddFourNumbers = R.curryN(4, addFourNumbers); | ||
* var f = curriedAddFourNumbers(1, 2); | ||
* var g = f(3); | ||
* g(4); //=> 10 | ||
*/ | ||
module.exports = _curry2(function curryN(length, fn) { | ||
return arity(length, function() { | ||
var n = arguments.length; | ||
@@ -374,3 +431,3 @@ var shortfall = length - n; | ||
while (--idx >= 0) { | ||
if (isPlaceholder(arguments[idx])) { | ||
if (arguments[idx] === __) { | ||
shortfall += 1; | ||
@@ -382,5 +439,5 @@ } | ||
} else { | ||
var initialArgs = toArray(arguments); | ||
return curryN(shortfall, function () { | ||
var currentArgs = toArray(arguments); | ||
var initialArgs = _slice(arguments); | ||
return curryN(shortfall, function() { | ||
var currentArgs = _slice(arguments); | ||
var combinedArgs = []; | ||
@@ -390,3 +447,3 @@ var idx = -1; | ||
var val = initialArgs[idx]; | ||
combinedArgs[idx] = isPlaceholder(val) ? currentArgs.shift() : val; | ||
combinedArgs[idx] = (val === __ ? currentArgs.shift() : val); | ||
} | ||
@@ -397,19 +454,96 @@ return fn.apply(this, combinedArgs.concat(currentArgs)); | ||
}); | ||
} | ||
}); | ||
},{"./__":2,"./arity":3,"./internal/_curry2":6,"./internal/_slice":7}],5:[function(require,module,exports){ | ||
var __ = require('../__'); | ||
return { | ||
stream: stream, | ||
isStream: isStream, | ||
transduce: transduce, | ||
merge: merge, | ||
reduce: scan, // Legacy | ||
scan: scan, | ||
endsOn: endsOn, | ||
map: curryN(2, map), | ||
curryN: curryN, | ||
_: _, | ||
immediate: immediate, | ||
/** | ||
* Optimized internal two-arity curry function. | ||
* | ||
* @private | ||
* @category Function | ||
* @param {Function} fn The function to curry. | ||
* @return {Function} The curried function. | ||
*/ | ||
module.exports = function _curry1(fn) { | ||
return function f1(a) { | ||
if (arguments.length === 0) { | ||
return f1; | ||
} else if (a === __) { | ||
return f1; | ||
} else { | ||
return fn(a); | ||
} | ||
}; | ||
}; | ||
})); | ||
},{"../__":2}],6:[function(require,module,exports){ | ||
var __ = require('../__'); | ||
var _curry1 = require('./_curry1'); | ||
/** | ||
* Optimized internal two-arity curry function. | ||
* | ||
* @private | ||
* @category Function | ||
* @param {Function} fn The function to curry. | ||
* @return {Function} The curried function. | ||
*/ | ||
module.exports = function _curry2(fn) { | ||
return function f2(a, b) { | ||
var n = arguments.length; | ||
if (n === 0) { | ||
return f2; | ||
} else if (n === 1 && a === __) { | ||
return f2; | ||
} else if (n === 1) { | ||
return _curry1(function(b) { return fn(a, b); }); | ||
} else if (n === 2 && a === __ && b === __) { | ||
return f2; | ||
} else if (n === 2 && a === __) { | ||
return _curry1(function(a) { return fn(a, b); }); | ||
} else if (n === 2 && b === __) { | ||
return _curry1(function(b) { return fn(a, b); }); | ||
} else { | ||
return fn(a, b); | ||
} | ||
}; | ||
}; | ||
},{"../__":2,"./_curry1":5}],7:[function(require,module,exports){ | ||
/** | ||
* An optimized, private array `slice` implementation. | ||
* | ||
* @private | ||
* @param {Arguments|Array} args The array or arguments object to consider. | ||
* @param {Number} [from=0] The array index to slice from, inclusive. | ||
* @param {Number} [to=args.length] The array index to slice to, exclusive. | ||
* @return {Array} A new, sliced array. | ||
* @example | ||
* | ||
* _slice([1, 2, 3, 4, 5], 1, 3); //=> [2, 3] | ||
* | ||
* var firstThreeArgs = function(a, b, c, d) { | ||
* return _slice(arguments, 0, 3); | ||
* }; | ||
* firstThreeArgs(1, 2, 3, 4); //=> [1, 2, 3] | ||
*/ | ||
module.exports = function _slice(args, from, to) { | ||
switch (arguments.length) { | ||
case 1: return _slice(args, 0, args.length); | ||
case 2: return _slice(args, from, args.length); | ||
default: | ||
var list = []; | ||
var idx = -1; | ||
var len = Math.max(0, Math.min(args.length, to) - from); | ||
while (++idx < len) { | ||
list[idx] = args[from + idx]; | ||
} | ||
return list; | ||
} | ||
}; | ||
},{}]},{},[1])(1) | ||
}); |
{ | ||
"name": "flyd", | ||
"version": "0.1.10", | ||
"version": "0.1.11", | ||
"description": "The less is more, modular, functional reactive programming library", | ||
"main": "flyd.js", | ||
"main": "lib/index.js", | ||
"directories": { | ||
@@ -11,12 +11,19 @@ "example": "examples", | ||
"dependencies": { | ||
"ramda": "^0.14.0" | ||
}, | ||
"devDependencies": { | ||
"benchmark": "^1.0.0", | ||
"browserify": "^10.2.4", | ||
"bluebird": "^2.9.13", | ||
"lodash": "^3.3.1", | ||
"coveralls": "^2.11.2", | ||
"istanbul": "^0.3.15", | ||
"mocha": "^2.2.1", | ||
"ramda": "^0.14.0", | ||
"mocha-lcov-reporter": "0.0.2", | ||
"transducers.js": "0.3.x" | ||
}, | ||
"scripts": { | ||
"test": "./node_modules/mocha/bin/mocha" | ||
"test": "mocha", | ||
"perf": "./perf/run-benchmarks", | ||
"post-to-coveralls-io": "istanbul cover _mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage", | ||
"build": "browserify -s flyd lib/index.js > flyd.js" | ||
}, | ||
@@ -23,0 +30,0 @@ "repository": { |
@@ -1,14 +0,10 @@ | ||
var _ = require('lodash'); | ||
var Benchmark = require('benchmark.js'); | ||
var Benchmark = require('benchmark'); | ||
var flyd = require('../flyd'); | ||
var oldFlyd = require('../flyd-old'); | ||
var stream = flyd.stream; | ||
// Attach benchmarks' dependencies to the global | ||
// scope, since the current version of benchmark.js | ||
// doesn't allow for anything simpler | ||
global.stream = require('../flyd').stream; | ||
global.oldStream = require('../flyd-old').stream; | ||
global.stream = flyd.stream; | ||
global.flyd = flyd; | ||
global.oldFlyd = oldFlyd; | ||
global.oldStream = oldFlyd.stream; | ||
// ************************************************ | ||
@@ -108,4 +104,2 @@ // Util functions | ||
setup: function() { | ||
var flyd = global.flyd; | ||
var stream = global.flyd.stream; | ||
function f(x) { return x; } | ||
@@ -123,4 +117,2 @@ var s1 = stream(); | ||
setup: function() { | ||
var flyd = global.flyd; | ||
var stream = global.flyd.stream; | ||
function f(x) { return x; } | ||
@@ -127,0 +119,0 @@ var s1 = stream(); |
@@ -6,3 +6,3 @@ var assert = require('assert'); | ||
var flyd = require('../flyd.js'); | ||
var flyd = require('../lib'); | ||
var stream = flyd.stream; | ||
@@ -9,0 +9,0 @@ |
Sorry, the diff of this file is not supported yet
289443
37
7646
1
8
12
+ Addedramda@^0.14.0
+ Addedramda@0.14.0(transitive)