Socket
Socket
Sign inDemoInstall

fairmont

Package Overview
Dependencies
Maintainers
3
Versions
90
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fairmont - npm Package Compare versions

Comparing version 1.0.0-alpha-09 to 1.0.0-alpha-10

97

lib/array.js

@@ -18,3 +18,6 @@ // Generated by CoffeeScript 1.9.1

describe("Array functions", function(context) {
var cat, difference, dupes, first, includes, intersection, last, range, remove, rest, second, shuffle, slice, third, union, uniq, unique, unique_by;
var cat, difference, dupes, empty, first, includes, intersection, last, range, remove, rest, second, shuffle, slice, third, union, uniq, unique, unique_by;
empty = function(ax) {
return ax.length === 0;
};
cat = detach(Array.prototype.concat);

@@ -24,3 +27,4 @@ context.test("cat", function() {

data = [1, 2, 3, 4, 5];
return assert(deep_equal(cat(data), data));
assert(deep_equal(cat(data), data));
return assert(deep_equal(cat(data, data), data.concat(data)));
});

@@ -30,2 +34,7 @@ slice = curry(function(i, j, ax) {

});
context.test("slice", function() {
var data;
data = [1, 2, 3, 4, 5];
return assert(deep_equal((slice(1, 2))(data), [2]));
});
first = function(ax) {

@@ -71,9 +80,9 @@ return ax[0];

unique_by = curry(function(f, ax) {
var a, bx, k, len, y;
var a, b, bx, k, len;
bx = [];
for (k = 0, len = ax.length; k < len; k++) {
a = ax[k];
y = f(a);
if (indexOf.call(bx, y) < 0) {
bx.push(y);
b = f(a);
if (indexOf.call(bx, b) < 0) {
bx.push(b);
}

@@ -85,31 +94,66 @@ }

context.test("unique", function() {
return (function(data) {
return assert(deep_equal(unique(data), [1, 2, 3, 5, 6]));
})([1, 2, 1, 3, 5, 3, 6]);
return assert(deep_equal(unique(cat([1, 2, 3, 4, 5], [1, 2, 3, 4, 5], [1, 2, 3, 4, 5])), [1, 2, 3, 4, 5]));
});
difference = curry(function(ax, bx) {
var cx;
cx = union(ax, bx);
return cx.filter(function(c) {
return (indexOf.call(ax, cx) >= 0 && !(indexOf.call(bx, cx) >= 0)) || (indexOf.call(bx, cx) >= 0 && !(indexOf.call(bx, cx) >= 0));
});
});
dupes = function(arg) {
var first, rest;
first = arg[0], rest = 2 <= arg.length ? slice1.call(arg, 1) : [];
if (rest.length === 0) {
var a, ax, bx;
a = arg[0], ax = 2 <= arg.length ? slice1.call(arg, 1) : [];
if (empty(ax)) {
return [];
} else if (indexOf.call(rest, first) >= 0) {
return [first].concat(slice1.call(dupes(rest)));
} else {
return dupes(rest);
bx = dupes(ax);
if (indexOf.call(ax, a) >= 0 && !(indexOf.call(bx, a) >= 0)) {
return [a].concat(slice1.call(bx));
} else {
return bx;
}
}
};
context.test("dupes", function() {
return (function(data) {
return assert(deep_equal(dupes(data), [1, 3]));
})([1, 2, 1, 3, 5, 3, 6]);
return assert(deep_equal(dupes(cat([1, 2, 3], [2, 3, 4], [3, 4, 5])), [2, 3, 4]));
});
union = curry(compose(unique, cat));
intersection = curry(compose(dupes, cat));
context.test("union", function() {
return (function(a, b) {
assert(deep_equal(union(a, b), [1, 2, 3, 4, 5, 6]));
return assert(deep_equal(union(a, a), [1, 2, 3, 4]));
})([1, 2, 3, 4], [3, 4, 5, 6]);
});
intersection = function() {
var first, k, len, ref3, rest, results, x;
first = arguments[0], rest = 2 <= arguments.length ? slice1.call(arguments, 1) : [];
if (empty(rest)) {
return first;
} else {
ref3 = intersection.apply(null, rest);
results = [];
for (k = 0, len = ref3.length; k < len; k++) {
x = ref3[k];
if (indexOf.call(first, x) >= 0) {
results.push(x);
}
}
return results;
}
};
context.test("intersection", function() {
assert(empty(intersection([1, 2], [3, 4])));
assert(empty(intersection([1, 1], [2, 2])));
assert(empty(intersection([], [1, 2, 3])));
assert(empty(intersection([1, 2, 3], [])));
assert(empty(intersection([1, 2], [2, 3], [3, 4])));
assert((first(intersection([1, 2], [2, 3]))) === 2);
return assert((first(intersection([1, 2], [2, 3], [3, 2]))) === 2);
});
difference = curry(function(ax, bx) {
var cx;
cx = union(ax, bx);
return cx.filter(function(c) {
return (indexOf.call(ax, c) >= 0 && !(indexOf.call(bx, c) >= 0)) || (indexOf.call(bx, c) >= 0 && !(indexOf.call(ax, c) >= 0));
});
});
context.test("difference", function() {
return (function(ax, bx) {
return assert(deep_equal(difference(ax, bx), [1, 2, 5, 6]));
})([1, 2, 3, 4], [3, 4, 5, 6]);
});
remove = function(array, element) {

@@ -176,2 +220,3 @@ var index, ref3;

intersection: intersection,
difference: difference,
remove: remove,

@@ -178,0 +223,0 @@ shuffle: shuffle

@@ -20,3 +20,3 @@ // Generated by CoffeeScript 1.9.1

describe("File system functions", function(context) {
var chdir, exists, lines, read, read_block, read_stream, readdir, rm, rmdir, stat, write;
var chdir, exists, lines, read, read_stream, readdir, rm, rmdir, stat, stream, write;
stat = function(path) {

@@ -94,6 +94,6 @@ return fs(function(arg) {

};
read_block = (function(arg) {
stream = (function(arg) {
var promise, reject, resolve;
promise = arg.promise, reject = arg.reject, resolve = arg.resolve;
return function(stream) {
return function(s) {
return (function(pending, resolved, _resolve, _reject) {

@@ -114,9 +114,9 @@ _resolve = function(x) {

};
stream.on("data", function(data) {
s.on("data", function(data) {
return _resolve(data.toString());
});
stream.on("end", function() {
s.on("end", function() {
return _resolve(null);
});
stream.on("error", function() {
s.on("error", function() {
return _reject(error);

@@ -139,14 +139,14 @@ });

})(require("when"));
context.test("read_block", function() {
context.test("stream", function() {
var Readable;
Readable = require("stream").Readable;
return (function*(stream) {
var _stream;
stream.push("one\n");
stream.push("two\n");
stream.push("three\n");
_stream = lines(stream);
assert(((yield read_block(_stream))) === "one");
assert(((yield read_block(_stream))) === "two");
return assert(((yield read_block(_stream))) === "three");
return (function*(s) {
var _s;
s.push("one\n");
s.push("two\n");
s.push("three\n");
_s = lines(s);
assert(((yield read_block(_s))) === "one");
assert(((yield read_block(_s))) === "two");
return assert(((yield read_block(_s))) === "three");
})(new Readable);

@@ -207,4 +207,4 @@ });

read_stream: read_stream,
stream: stream,
lines: lines,
read_block: read_block,
readdir: readdir,

@@ -211,0 +211,0 @@ stat: stat,

@@ -21,3 +21,3 @@ // Generated by CoffeeScript 1.9.1

describe("Iterator functions", function(context) {
var _foldr, _unzip, add, all, any, assoc, binary, collect, detach, each, first, flatten, flip, fold, foldr, is_function, is_iterable, is_iterator, iterate, iterator, last, leave, map, negate, odd, partition, project, property, ref2, reject, sample, second, select, skip, take, ternary, third, unzip, w, wrap, zip;
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;
is_iterable = function(x) {

@@ -190,5 +190,6 @@ return x[Symbol.iterator] != null;

});
odd = require("./numeric").odd;
second = require("./array").second;
context.test("select", function*() {
var odd, second;
second = require("./array").second;
odd = require("./numeric").odd;
return assert((second((yield collect(select(odd, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))))) === 3);

@@ -201,2 +202,5 @@ });

context.test("reject", function*() {
var odd, second;
second = require("./array").second;
odd = require("./numeric").odd;
return assert((second((yield collect(reject(odd, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))))) === 2);

@@ -219,3 +223,4 @@ });

context.test("any", function*() {
var count, test;
var count, odd, test;
odd = require("./numeric").odd;
count = 0;

@@ -233,2 +238,4 @@ test = function(x) {

context.test("all", function*() {
var odd;
odd = require("./numeric").odd;
assert(!((yield all(odd, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))));

@@ -257,4 +264,4 @@ return assert((yield all((function() {

context.test("zip", function*() {
var ref2, third;
ref2 = require("../src/index"), second = ref2.second, third = ref2.third;
var ref2, second, third;
ref2 = require("./array"), second = ref2.second, third = ref2.third;
return assert((second(third((yield collect(zip([1, 2, 3], [4, 5, 6])))))) === 6);

@@ -346,2 +353,4 @@ });

context.test("partition", function() {
var ref3;
ref3 = require("./array"), first = ref3.first, second = ref3.second;
return assert((first(second(collect(partition(2, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]))))) === 2);

@@ -399,2 +408,40 @@ });

context.test("sample");
add = require("./numeric").add;
sum = fold(0, add);
context.test("sum", function() {
return assert((sum([1, 2, 3, 4, 5])) === 15);
});
average = function(i) {
var f, j;
j = 0;
f = function(r, n) {
return r += (n - r) / ++j;
};
return fold(0, f, i);
};
context.test("average", function() {
assert((average([1, 2, 3, 4, 5])) === 3);
return assert((average([-5, -4, -3, -2, -1])) === -3);
});
cat = require("./array").cat;
join = fold("", add);
context.test("join", function() {
w = require("./string").w;
return assert((join(w("one two three"))) === "onetwothree");
});
delimit = curry(function(d, i) {
var f;
f = function(r, s) {
if (r === "") {
return r += s;
} else {
return r += d + s;
}
};
return fold("", f, i);
});
context.test("delimit", function() {
w = require("./string").w;
return assert((delimit(", ", w("one two three"))) === "one, two, three");
});
return module.exports = {

@@ -422,3 +469,5 @@ is_iterable: is_iterable,

skip: skip,
sample: sample
sample: sample,
sum: sum,
average: average
};

@@ -425,0 +474,0 @@ });

@@ -42,3 +42,3 @@ // Generated by CoffeeScript 1.9.1

clone = function(object) {
var flags, key;
var _clone, flags, key;
if ((object == null) || typeof object !== 'object') {

@@ -48,3 +48,3 @@ return object;

if (object instanceof Date) {
return new Date(obj.getTime());
return new Date(object.getTime());
}

@@ -67,9 +67,26 @@ if (object instanceof RegExp) {

}
clone = new object.constructor();
_clone = new object.constructor();
for (key in object) {
clone[key] = $.clone(object[key]);
_clone[key] = clone(object[key]);
}
return clone;
return _clone;
};
context.test("clone");
context.test("clone", function() {
var is_clone, person;
is_clone = function(original, copy) {
assert.notEqual(original, copy);
return assert.deepEqual(original, copy);
};
person = {
name: "Steve Jobs",
address: {
street: "1 Infinite Loop",
city: "Cupertino, CA",
zip: 95014
},
birthdate: new Date('Feb 24, 1955'),
regex: /foo.*/igm
};
return is_clone(person, clone(person));
});
property = curry(function(key, object) {

@@ -76,0 +93,0 @@ return object[key];

{
"name": "fairmont",
"version": "1.0.0-alpha-09",
"version": "1.0.0-alpha-10",
"description": "A collection of useful functions and utilities.",

@@ -13,3 +13,3 @@ "files": [

"prepublish": "coffee -o lib/ -c src/*.*coffee",
"test": "coffee ./test.coffee",
"test": "coffee --nodejs --harmony test/test.litcoffee",
"watch": "coffee --nodejs --harmony -o lib/ -cw src/*.*coffee"

@@ -16,0 +16,0 @@ },

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc