Skip to content
This repository has been archived by the owner on Oct 25, 2018. It is now read-only.

Commit

Permalink
bug fix in assertArray()
Browse files Browse the repository at this point in the history
  • Loading branch information
darthcav committed Nov 2, 2015
1 parent ca28bef commit b7d1b1d
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/typly.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,16 @@ module.exports = {
},
assertArray: function (value, fn)
{
if (!this.isArray(value, fn))
if(arguments.length === 1)
{
if(arguments.length === 1)
if(!this.isArray(value))
{
throw createTypeError(value, 'Array');
}
else
}
else
{
if (!this.isArray(value, fn))
{
throw new TypeError('[tiply] Invalid comparison function or type used in array');
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "typly",
"description": "Generic Javascript type checker",
"version": "0.2.1",
"version": "0.2.2",
"author": {
"name": "Web Compliance Center",
"email": "webcc@fit.fraunhofer.de"
Expand Down
12 changes: 12 additions & 0 deletions test/ArrayTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe("typly#ArrayTest", () =>
assert(typly.isArray(new Array()));
});
it("should return true for integer arrays", () =>
{
assert(typly.isArray([4, 8, 66]));
});
it("should return true for integer arrays", () =>
{
assert(typly.isArray([4, 8, 66], typly.isInteger.bind(typly)));
});
Expand All @@ -23,6 +27,14 @@ describe("typly#ArrayTest", () =>
});
describe("#assertArray", () =>
{
it("should return true for integer arrays", () =>
{
assert(typly.assertArray([4, 8, 66]));
});
it("should return true for integer arrays", () =>
{
assert(typly.assertArray([4, 8, 66], typly.isInteger.bind(typly)));
});
it("should throw a TypeError for objects", () =>
{
assert.throws(() =>
Expand Down

0 comments on commit b7d1b1d

Please sign in to comment.