-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
36 lines (24 loc) · 1.01 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
module.exports = (function(DEBUG){
/*----------------------------------------------------------------------------*/
//import vitals
var root = require('dsb-root');
/******************************************************************************/
/*
* @method defined
* checks if a variable is undefined
* returns false if {variable} undefined or {this} === {window||global}
* @param variable {any} the variable to check is defined
* @returns is_defined {boolean} returns true if defined AND not root
*/
/*----------------------------------------------------------------------------*/
var defined = function( v ){
var u = ( typeof v === 'undefined' ),
r = ( v === root ),
f = ( u || r ) ? false : true;
if( DEBUG ) console.log( 'Defined?', !u, 'Root?', r, 'Result:', f );
return f;
};
/******************************************************************************/
return defined;
/*----------------------------------------------------------------------------*/
}(0));