@panosoft/ramda-utils
Advanced tools
Comparing version 0.1.6 to 0.1.7
@@ -18,2 +18,4 @@ var R = require('ramda'); | ||
}, | ||
emptyC : f => R.compose(R.empty, f), | ||
notEmptyC: f => R.compose(R.complement(R.empty), f), | ||
compareProps: (props, a, b) => { | ||
@@ -40,23 +42,2 @@ // determine property compare function (lt or gt) based on + or - | ||
}, | ||
composeA: function() { // TODO arrow functions don't handle arguments correctly yet | ||
var fs = [].slice.call(arguments, 0); | ||
return R.nAry(fs[fs.length - 1].length, function() { | ||
var r = arguments; | ||
var more = i => i >= 0; | ||
for (var i = fs.length - 1; more(i); --i) | ||
{ | ||
r = fs[i].apply(this, r); | ||
if (typeof r == 'function') | ||
break; | ||
r = [r]; | ||
} | ||
if (more(i)) | ||
return Ru.composeA.apply(this, fs.slice(0, i).concat([r])); | ||
else | ||
return r; | ||
}); | ||
}, | ||
pipeA: function() { // TODO arrow functions don't handle arguments correctly yet | ||
return Ru.composeA.apply(this, R.reverse(arguments)); | ||
}, | ||
toNumber: x => Number(x), | ||
@@ -63,0 +44,0 @@ toString: x => String(x), |
{ | ||
"name": "@panosoft/ramda-utils", | ||
"version": "0.1.6", | ||
"version": "0.1.7", | ||
"description": "Utilities built on top of Ramda", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -36,4 +36,7 @@ var R = require('ramda'); | ||
var lastNameNeq = Ru.complementC(lastNameEq); | ||
console.log(lastNameEq('Smith')({lastName: 'Jones'})); // false | ||
console.log(lastNameNeq('Smith')({lastName: 'Jones'})); // true | ||
console.log('complementC: ' + lastNameEq('Smith')({lastName: 'Jones'})); // false | ||
console.log('complementC: ' + lastNameNeq('Smith')({lastName: 'Jones'})); // true | ||
// emptyC | ||
var a = ['abc', 'xyz']; | ||
console.log('emptyC: ' + R.any(Ru.notEmptyC(R.match('123')), a)); | ||
// compareProps | ||
@@ -89,6 +92,1 @@ var o = [ | ||
console.log(Ru.matchGroups(r, s)); // [ [ 'c', 'd'], [ 'bb', 'd' ], ['___', 'd'] ] | ||
//composeA | ||
Ru.composeA(console.log, R.propEq('lastName'), R.identity)('Smith')({lastName: 'Smith'}); // true | ||
Ru.composeA(console.log, R.multiply, R.inc)(3)(4); // 16 | ||
Ru.pipeA(R.inc, R.multiply, console.log)(3)(4); // 16 | ||
console.log('Arity: ' + Ru.composeA(console.log, R.multiply, R.inc).length); // Arity: 1 |
Sorry, the diff of this file is not supported yet
24450
131