var assert = require('assert');
var bool = require('true-bool');

module.exports = assert;

assert.str = string;
assert.string = string;
assert.obj = object;
assert.object = object;
assert.arr = array;
assert.array = array;
assert.map = map;
assert.set = set;
assert.num = number;
assert.number = number;
assert.int = integer;
assert.integer = integer;
assert.undefined = undefined_;
assert.undef = undefined_;
assert.true = true_;

string.nonempty = _nonempty;
string.none = _nonempty;
object.nonempty = _nonempty;
object.none= _nonempty;
array.nonempty = _nonempty;
array.none= _nonempty;
map.nonempty = _nonempty;
map.none= _nonempty;
set.nonempty = _nonempty;
set.none= _nonempty;

function _withoutConstructor(v) {
    if (v === undefined || v === null) return true;
}

function _nonempty(v, msg) {
    this(v, msg, true);
}

function string(v, msg, nonempty) {
    if (typeof v != 'string') {
        var fail = true;
        if (!msg) msg = nonempty ? v + ' is non-empty string' : v + ' is string';
    } else if (nonempty && !v) {
        fail = true;
        msg = msg ? msg : '"" is non-empty string';
    }
    if (fail) throw new assert.AssertionError(
            {message: msg, stackStartFunction: arguments.callee});
}

function object(v, msg, nonempty) {
    if (_withoutConstructor(v) || v.constructor.name != 'Object') {
        var fail = true;
        if (!msg) msg = nonempty ? v + ' is non-empty object' : v + ' is object';
    } else if (nonempty) {
        for (var k in v) return; 
        fail = true;
        msg = msg ? msg : v + ' is non-empty object';
    }
    if (fail) throw new assert.AssertionError(
            {message: msg, stackStartFunction: arguments.callee});
}

function array(v, msg, nonempty) {
    if (_withoutConstructor(v) || v.constructor.name != 'Array') {
        var fail = true;
        if (!msg) msg = nonempty ? v + ' is non-empty array' : v + ' is array';
    } else if (nonempty) {
        fail = v.length ? false : true;
        msg = msg ? msg : v + ' is non-empty array';
    }
    if (fail) throw new assert.AssertionError(
            {message: msg, stackStartFunction: arguments.callee});
}

function map(v, msg, nonempty) {
    if (_withoutConstructor(v) || v.constructor.name != 'Map') {
        var fail = true;
        if (!msg) msg = nonempty ? v + ' is non-empty map' : v + ' is map';
    } else if (nonempty) {
        fail = v.size ? false : true;
        msg = msg ? msg : v + ' is non-empty map';
    }
    if (fail) throw new assert.AssertionError(
            {message: msg, stackStartFunction: arguments.callee});
}

function set(v, msg, nonempty) {
    if (_withoutConstructor(v) || v.constructor.name != 'Set') {
        var fail = true;
        if (!msg) msg = nonempty ? v + ' is non-empty set' : v + ' is set';
    } else if (nonempty) {
        fail = v.size ? false : true;
        msg = msg ? msg : v + ' is non-empty set';
    }
    if (fail) throw new assert.AssertionError(
            {message: msg, stackStartFunction: arguments.callee});
}

function number(v, msg) {
    if (typeof v != 'number' ||
            v.toString() == 'NaN' ||
            v.toString() == 'Infinity' ||
            v.toString() == '-Infinity') {
        if (typeof v == 'string') v = '"' + v + '"';
        msg = msg ? msg : v + ' is number';
        throw new assert.AssertionError(
                {message: msg, stackStartFunction: arguments.callee});
    }
}

function integer(v, msg) {
    if (typeof v != 'number' ||
            v.toString() == 'NaN' ||
            v.toString() == 'Infinity' ||
            v.toString() == '-Infinity' ||
            v % 1 != 0) {
        if (typeof v == 'string') v = '"' + v + '"';
        msg = msg ? msg : v + ' is integer';
        throw new assert.AssertionError(
                {message: msg, stackStartFunction: arguments.callee});
    }
}

function undefined_(v, msg) {
  if (arguments.length == 0) throw new Error(
      'missing required argument "v"!');
  if (v !== undefined) {
    msg = msg ? msg : v + ' is undefined';
    throw new assert.AssertionError(
        {message: msg, stackStartFunction: arguments.callee});
  }
}

function true_(v, msg) {
  if (bool(v)) return;
  msg = msg ? msg : v + ' is true';
  throw new assert.AssertionError(
      {message: msg, stackStartFunction: arguments.callee}); 
}

@@ -3874,24 +3874,26 @@
 _(v, msg) %7B%0A
+  
   if (argume
@@ -3932,16 +3932,18 @@
 (%0A      
+  
 'missing
@@ -3969,16 +3969,18 @@
 %22v%22!');%0A
+  
   if (v 
@@ -3996,24 +3996,26 @@
 ined) %7B%0A    
+  
 msg = msg ? 
@@ -4041,24 +4041,26 @@
 fined';%0A    
+  
 throw new as
@@ -4080,32 +4080,34 @@
 nError(%0A        
+ 
+ 
 %7Bmessage: msg, s
@@ -4145,16 +4145,18 @@
 llee%7D);%0A
+  
   %7D%0A%7D%0A%0Af
@@ -4179,16 +4179,18 @@
  msg) %7B%0A
+  
   if (bo
@@ -4206,16 +4206,18 @@
 turn;%0A  
+ 
+ 
 msg = ms
@@ -4242,16 +4242,18 @@
  true';%0A
+  
   throw 
@@ -4275,24 +4275,26 @@
 rtionError(%0A
+  
       %7Bmessa

Fix indentation 2 spaces --> 4 spaces.