Comparing version 1.0.0-alpha-19 to 1.0.0-alpha-20
@@ -8,3 +8,3 @@ // Generated by CoffeeScript 1.9.1 | ||
describe("General functions", function(context) { | ||
var abort, async, benchmark, blank, curry, empty, include, is_array, is_function, is_generator, is_object, keys, memoize, ref1, ref2, shell, sleep, timer, times; | ||
var abort, async, benchmark, blank, curry, empty, include, is_array, is_function, is_generator, is_object, is_string, keys, length, memoize, ref1, ref2, shell, sleep, timer, times; | ||
abort = function() { | ||
@@ -102,7 +102,7 @@ return process.exit(-1); | ||
keys = require("./object").keys; | ||
ref2 = require("./type"), is_array = ref2.is_array, is_object = ref2.is_object; | ||
ref2 = require("./type"), is_array = ref2.is_array, is_string = ref2.is_string, is_object = ref2.is_object; | ||
blank = require("./string").blank; | ||
empty = function(x) { | ||
if (is_array(x)) { | ||
return a.length === 0; | ||
return x.length === 0; | ||
} else if (is_object(x)) { | ||
@@ -113,5 +113,23 @@ return empty(keys(x)); | ||
} else { | ||
return x != null; | ||
return x == null; | ||
} | ||
}; | ||
context.test("empty", function() { | ||
assert(empty([])); | ||
assert(empty("")); | ||
assert(empty({})); | ||
assert(!empty([1])); | ||
assert(!empty("abc")); | ||
assert(!empty({ | ||
a: 0 | ||
})); | ||
assert(empty(void 0)); | ||
return assert(!empty(true)); | ||
}); | ||
length = function(x) { | ||
return x.length; | ||
}; | ||
context.test("length", function() { | ||
return assert((length([])) === 0); | ||
}); | ||
module.exports = { | ||
@@ -126,3 +144,4 @@ times: times, | ||
benchmark: benchmark, | ||
empty: empty | ||
empty: empty, | ||
length: length | ||
}; | ||
@@ -129,0 +148,0 @@ include = require("./object").include; |
@@ -10,3 +10,3 @@ // Generated by CoffeeScript 1.9.1 | ||
describe("Type functions", function(context) { | ||
var instance_of, is_array, is_boolean, is_date, is_function, is_generator, is_number, is_object, is_regexp, is_string, is_type, is_value, type; | ||
var instance_of, is_array, is_boolean, is_date, is_float, is_function, is_generator, is_integer, is_number, is_object, is_regexp, is_string, is_type, is_value, type; | ||
type = function(x) { | ||
@@ -24,7 +24,28 @@ return Object.prototype.toString.call(x).slice(8, -1).toLowerCase(); | ||
context.test("instance_of"); | ||
is_number = is_type("number"); | ||
is_number = function(n) { | ||
return n === +n; | ||
}; | ||
context.test("is_number", function() { | ||
assert(is_number(7)); | ||
assert(!is_number("7")); | ||
return assert(!is_number(false)); | ||
}); | ||
is_integer = function(n) { | ||
return n === +n && n === (n | 0); | ||
}; | ||
context.test("is_integer", function() { | ||
assert(is_integer(5)); | ||
assert(!is_integer(3.5)); | ||
assert(!is_integer("5")); | ||
return assert(!is_integer(NaN)); | ||
}); | ||
is_float = function(n) { | ||
return n === +n && n !== (n | 0); | ||
}; | ||
context.test("is_float", function() { | ||
assert(is_float(3.5)); | ||
assert(!is_float(5)); | ||
assert(!is_float("3.5")); | ||
return assert(!is_float(NaN)); | ||
}); | ||
is_boolean = is_type("boolean"); | ||
@@ -31,0 +52,0 @@ context.test("is_boolean", function() { |
{ | ||
"name": "fairmont", | ||
"version": "1.0.0-alpha-19", | ||
"version": "1.0.0-alpha-20", | ||
"description": "A collection of useful functions and utilities.", | ||
@@ -5,0 +5,0 @@ "files": [ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
110843
2067