Comparing version 1.0.0-alpha-01 to 1.0.0-alpha-02
// Generated by CoffeeScript 1.8.0 | ||
(function() { | ||
var assert, binary, compose, curry, deep_equal, describe, flip, identity, liberate, lt, odd, partial, ternary, unary, _, _ref, _ref1, _ref2, | ||
var assert, binary, compose, curry, deep_equal, describe, detach, flip, identity, lt, odd, partial, ternary, unary, _, _ref, _ref1, _ref2, | ||
__slice = [].slice, | ||
@@ -9,3 +9,3 @@ __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; }; | ||
liberate = require("./object").liberate; | ||
detach = require("./object").detach; | ||
@@ -19,4 +19,4 @@ deep_equal = require("./type").deep_equal; | ||
describe("Array functions", function(context) { | ||
var all, any, cat, difference, drop, dupes, each, filter, first, flatten, fold, foldr, includes, intersection, last, leave, map, remove, rest, shuffle, slice, take, union, uniq, unique, unique_by; | ||
fold = curry(flip(ternary(liberate(Array.prototype.reduce)))); | ||
var all, any, cat, difference, drop, dupes, each, filter, first, flatten, fold, foldr, includes, intersection, last, leave, map, range, remove, rest, shuffle, slice, take, union, uniq, unique, unique_by; | ||
fold = curry(flip(ternary(detach(Array.prototype.reduce)))); | ||
context.test("fold", function() { | ||
@@ -30,3 +30,3 @@ var data, fn; | ||
}); | ||
foldr = curry(flip(ternary(liberate(Array.prototype.reduce)))); | ||
foldr = curry(flip(ternary(detach(Array.prototype.reduce)))); | ||
context.test("foldr", function() { | ||
@@ -40,3 +40,3 @@ var data, fn; | ||
}); | ||
map = curry(flip(binary(liberate(Array.prototype.map)))); | ||
map = curry(flip(binary(detach(Array.prototype.map)))); | ||
context.test("map", function() { | ||
@@ -49,3 +49,3 @@ var data; | ||
}); | ||
filter = curry(flip(binary(liberate(Array.prototype.filter)))); | ||
filter = curry(flip(binary(detach(Array.prototype.filter)))); | ||
context.test("filter", function() { | ||
@@ -56,3 +56,3 @@ var data; | ||
}); | ||
any = curry(flip(binary(liberate(Array.prototype.some)))); | ||
any = curry(flip(binary(detach(Array.prototype.some)))); | ||
context.test("any", function() { | ||
@@ -63,3 +63,3 @@ var data; | ||
}); | ||
all = curry(flip(binary(liberate(Array.prototype.every)))); | ||
all = curry(flip(binary(detach(Array.prototype.every)))); | ||
context.test("all", function() { | ||
@@ -70,3 +70,3 @@ var data; | ||
}); | ||
each = curry(flip(binary(liberate(Array.prototype.forEach)))); | ||
each = curry(flip(binary(detach(Array.prototype.forEach)))); | ||
context.test("each", function() { | ||
@@ -80,3 +80,3 @@ return (function(ax, data) { | ||
}); | ||
cat = liberate(Array.prototype.concat); | ||
cat = detach(Array.prototype.concat); | ||
context.test("cat", function() { | ||
@@ -236,2 +236,13 @@ var data; | ||
}); | ||
range = function(start, finish) { | ||
var _i, _results; | ||
return (function() { | ||
_results = []; | ||
for (var _i = start; start <= finish ? _i <= finish : _i >= finish; start <= finish ? _i++ : _i--){ _results.push(_i); } | ||
return _results; | ||
}).apply(this); | ||
}; | ||
context.test("range", function() { | ||
return assert(deep_equal(range(1, 5), [1, 2, 3, 4, 5])); | ||
}); | ||
return module.exports = { | ||
@@ -238,0 +249,0 @@ fold: fold, |
@@ -8,3 +8,3 @@ // Generated by CoffeeScript 1.8.0 | ||
describe("General functions", function(context) { | ||
var abort, memoize, sleep, timer; | ||
var abort, memoize, shell, sleep, timer; | ||
abort = function() { | ||
@@ -49,5 +49,33 @@ return process.exit(-1); | ||
}; | ||
return context.test("sleep"); | ||
context.test("sleep"); | ||
shell = function(command) { | ||
var exec, promise; | ||
promise = require("when").promise; | ||
exec = require("child_process").exec; | ||
return promise(function(resolve, reject) { | ||
return exec(command, function(error, stdout, stderr) { | ||
if (error) { | ||
return reject(error); | ||
} else { | ||
return resolve({ | ||
stdout: stdout, | ||
stderr: stderr | ||
}); | ||
} | ||
}); | ||
}); | ||
}; | ||
return context.test("shell", function*() { | ||
return assert(((yield shell("ls ./test"))).stdout.trim().split("\n").length === 4); | ||
}); | ||
}); | ||
module.exports = { | ||
shell: shell, | ||
sleep: sleep, | ||
timer: timer, | ||
memoize: memoize, | ||
abort: abort | ||
}; | ||
include = require("./object").include; | ||
@@ -54,0 +82,0 @@ |
@@ -13,3 +13,3 @@ // Generated by CoffeeScript 1.8.0 | ||
describe("Object functions", function(context) { | ||
var clone, delegate, extend, include, liberate, merge, pluck, properties, property; | ||
var bind, clone, delegate, detach, extend, include, merge, pluck, properties, property; | ||
include = extend = function() { | ||
@@ -107,10 +107,22 @@ var key, mixin, mixins, object, value, _i, _len; | ||
context.test("delegate"); | ||
liberate = (function(f) { | ||
return f.bind.bind(f.call); | ||
})((function() {})); | ||
context.test("liberate", function() { | ||
var reverse; | ||
reverse = liberate(Array.prototype.reverse); | ||
return assert(deep_equal(reverse([1, 2, 3]), [3, 2, 1])); | ||
bind = curry(function(f, x) { | ||
return f.bind(x); | ||
}); | ||
context.test("bind", function() { | ||
var trim; | ||
trim = bind(String.prototype.trim, "foo "); | ||
return assert(trim(), "foo"); | ||
}); | ||
detach = function(f) { | ||
return curry(function() { | ||
var args, x; | ||
x = arguments[0], args = 2 <= arguments.length ? __slice.call(arguments, 1) : []; | ||
return f.apply(x, args); | ||
}); | ||
}; | ||
context.test("detach", function() { | ||
var trim; | ||
trim = detach(String.prototype.trim); | ||
return assert(trim("foo "), "foo"); | ||
}); | ||
properties = property = (function() { | ||
@@ -165,3 +177,4 @@ var defaults; | ||
delegate: delegate, | ||
liberate: liberate | ||
bind: bind, | ||
detach: detach | ||
}; | ||
@@ -168,0 +181,0 @@ }); |
{ | ||
"name": "fairmont", | ||
"version": "1.0.0-alpha-01", | ||
"version": "1.0.0-alpha-02", | ||
"description": "A collection of useful functions and utilities.", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -77,3 +77,3 @@ # Fairmont | ||
include/extend, merge, clone, pluck, property, delegate, liberate | ||
include/extend, merge, clone, pluck, property, delegate, bind, detach | ||
@@ -91,1 +91,10 @@ [object]:src/object.litcoffee | ||
[string]:src/string.litcoffee | ||
## Miscellaneous Functions | ||
* [API Reference][misc] | ||
shell, sleep, timer, memoize, abort | ||
[misc]:src/index.litcoffee |
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
Shell access
Supply chain riskThis module accesses the system shell. Accessing the system shell increases the risk of executing arbitrary code.
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
60849
1146
99