Skip to content

Commit

Permalink
feature(itype) add suppor of null (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
josher19 authored and coderaiser committed Dec 13, 2019
1 parent 364c811 commit 9cb378b
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/itype.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,12 @@ function TypeProto() {
return typeof variable === name;
}

['arrayBuffer', 'file', 'array', 'object']
['null', 'arrayBuffer', 'file', 'array', 'object']
.forEach((name) => {
type[name] = typeOf.bind(null, name);
});

['null', 'string', 'undefined', 'boolean', 'number', 'function']
['string', 'undefined', 'boolean', 'number', 'function']
.forEach((name) => {
type[name] = typeOfSimple.bind(null, name);
});
Expand Down
20 changes: 20 additions & 0 deletions test/itype.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,23 @@ test('itype.boolean: false', (t) => {
t.end();
});


test('itype.undefined: true', (t) => {
t.ok(itype.undefined(undefined), 'should return true');
t.end();
});

test('itype.undefined: false', (t) => {
t.notOk(itype.undefined(null), 'should return false');
t.end();
});

test('itype.null: true', (t) => {
t.ok(itype.null(null), 'should return true');
t.end();
});

test('itype.null: false', (t) => {
t.notOk(itype.null(undefined), 'should return false');
t.end();
});

0 comments on commit 9cb378b

Please sign in to comment.