summaryrefslogtreecommitdiff
path: root/src/macros.py
blob: 39d05c9a4281eca0101decfb78082c6d4b663ca0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
macro IS_BOOLEAN(arg)           = (typeof(arg) === 'boolean');
macro IS_NULL(arg)              = (arg === null);
macro IS_NULL_OR_UNDEFINED(arg) = (arg == null);
macro IS_NUMBER(arg)            = (typeof(arg) === 'number');
macro IS_STRING(arg)            = (typeof(arg) === 'string');
macro IS_SYMBOL(arg)            = (typeof(arg) === 'symbol');
macro IS_UNDEFINED(arg)         = (typeof(arg) === 'undefined');

# These macros follow the semantics of V8's %_Is*() functions.
macro IS_ARRAY(arg)             = (Array.isArray(arg));
macro IS_DATE(arg)              = ((arg) instanceof Date);
macro IS_FUNCTION(arg)          = (typeof(arg) === 'function');
macro IS_OBJECT(arg)            = (typeof(arg) === 'object');
macro IS_REGEXP(arg)            = ((arg) instanceof RegExp);

macro IS_BUFFER(arg)            = ((arg) instanceof Buffer);