Comparing version 1.0.0-alpha-12 to 1.0.0-alpha-14
@@ -21,3 +21,3 @@ // Generated by CoffeeScript 1.9.1 | ||
describe("Iterator functions", function(context) { | ||
var _foldr, _unzip, add, all, any, assoc, average, binary, cat, collect, delimit, detach, each, first, flatten, flip, fold, foldr, is_function, is_iterable, is_iterator, iterate, iterator, join, last, leave, map, negate, partition, project, property, ref2, reject, sample, second, select, skip, sum, take, ternary, third, unzip, w, wrap, zip; | ||
var _foldr, _unzip, add, all, any, assoc, average, binary, cat, collect, compact, delimit, detach, each, first, flatten, flip, fold, foldr, is_function, is_iterable, is_iterator, is_value, iterate, iterator, join, last, leave, map, negate, partition, project, property, ref2, reject, sample, second, select, skip, sum, take, ternary, third, unzip, w, wrap, zip; | ||
is_iterable = function(x) { | ||
@@ -322,2 +322,7 @@ return x[Symbol.iterator] != null; | ||
}); | ||
is_value = require("./type").is_value; | ||
compact = select(is_value); | ||
context.test("compact", function() { | ||
return assert((second(collect(compact([1, null, null, 2])))) === 2); | ||
}); | ||
partition = curry(function(n, i) { | ||
@@ -324,0 +329,0 @@ var done; |
// Generated by CoffeeScript 1.9.1 | ||
(function() { | ||
var assert, compose, curry, deep_equal, describe, ref, ref1, | ||
slice = [].slice; | ||
slice = [].slice, | ||
indexOf = [].indexOf || function(item) { for (var i = 0, l = this.length; i < l; i++) { if (i in this && this[i] === item) return i; } return -1; }; | ||
@@ -13,3 +14,3 @@ ref = require("./helpers"), describe = ref.describe, assert = ref.assert; | ||
describe("Object functions", function(context) { | ||
var bind, clone, delegate, detach, extend, include, merge, properties, property; | ||
var bind, clone, delegate, detach, extend, has, include, keys, merge, negate, omit, pairs, pick, properties, property, values; | ||
include = extend = function() { | ||
@@ -185,2 +186,84 @@ var i, key, len, mixin, mixins, object, value; | ||
}); | ||
has = curry(function(p, x) { | ||
return x[p] != null; | ||
}); | ||
context.test("has", function() { | ||
return assert(has("a", { | ||
a: 1 | ||
})); | ||
}); | ||
keys = Object.keys; | ||
context.test("keys", function() { | ||
return assert((indexOf.call(keys({ | ||
a: 1 | ||
}), "a") >= 0)); | ||
}); | ||
values = function(x) { | ||
var k, results, v; | ||
results = []; | ||
for (k in x) { | ||
v = x[k]; | ||
results.push(v); | ||
} | ||
return results; | ||
}; | ||
context.test("values", function() { | ||
return assert((indexOf.call(values({ | ||
a: 1 | ||
}), 1) >= 0)); | ||
}); | ||
pairs = function(x) { | ||
var k, results, v; | ||
results = []; | ||
for (k in x) { | ||
v = x[k]; | ||
results.push([k, v]); | ||
} | ||
return results; | ||
}; | ||
context.test("pairs", function() { | ||
return assert(deep_equal(pairs({ | ||
a: 1, | ||
b: 2, | ||
c: 3 | ||
}), [["a", 1], ["b", 2], ["c", 3]])); | ||
}); | ||
pick = function(f, x) { | ||
var k, r, v; | ||
r = {}; | ||
for (k in x) { | ||
v = x[k]; | ||
if (f(k, v)) { | ||
r[k] = v; | ||
} | ||
} | ||
return r; | ||
}; | ||
context.test("pick", function() { | ||
return assert(deep_equal(pick((function(k, v) { | ||
return v != null; | ||
}), { | ||
a: 1, | ||
b: null, | ||
c: 3 | ||
}), { | ||
a: 1, | ||
c: 3 | ||
})); | ||
}); | ||
negate = require("./logical").negate; | ||
omit = function(f, x) { | ||
return pick(negate(f), x); | ||
}; | ||
context.test("omit", function() { | ||
return assert(deep_equal(omit((function(k, v) { | ||
return v != null; | ||
}), { | ||
a: 1, | ||
b: null, | ||
c: 3 | ||
}), { | ||
b: null | ||
})); | ||
}); | ||
return module.exports = { | ||
@@ -195,3 +278,7 @@ include: include, | ||
bind: bind, | ||
detach: detach | ||
detach: detach, | ||
has: has, | ||
keys: keys, | ||
values: values, | ||
pairs: pairs | ||
}; | ||
@@ -198,0 +285,0 @@ }); |
@@ -10,3 +10,3 @@ // Generated by CoffeeScript 1.9.1 | ||
describe("Type functions", function(context) { | ||
var instance_of, is_function, is_string, is_type, type; | ||
var instance_of, is_function, is_string, is_type, is_value, type; | ||
type = function(x) { | ||
@@ -30,2 +30,5 @@ return Object.prototype.toString.call(x).slice(8, -1).toLowerCase(); | ||
}; | ||
is_value = function(x) { | ||
return x != null; | ||
}; | ||
return module.exports = { | ||
@@ -37,3 +40,4 @@ deep_equal: deep_equal, | ||
is_string: is_string, | ||
is_function: is_function | ||
is_function: is_function, | ||
is_value: is_value | ||
}; | ||
@@ -40,0 +44,0 @@ }); |
{ | ||
"name": "fairmont", | ||
"version": "1.0.0-alpha-12", | ||
"version": "1.0.0-alpha-14", | ||
"description": "A collection of useful functions and utilities.", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -67,11 +67,1 @@ # Fairmont | ||
[200]:https://github.com/pandastrike/fairmont/issues | ||
Our overarching goals for the project include: | ||
* Making the library more comprehensive | ||
* Improving the tests and documentation | ||
* Ensuring that we can use an FP style in real-world scenarios | ||
* Introducing an idiom for supporting lazy evaluation |
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
99047
1873
67