forked from jazzychad/querystring.node.js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathutil.js
51 lines (42 loc) · 931 Bytes
/
util.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
* util.js
* - utility helper functions for querystring module
*
* Chad Etzel
*
* Copyright (c) 2009, Yahoo! Inc. and Chad Etzel
* BSD License (see LICENSE.md for info)
*
*/
exports.is = is;
exports.isNull = isNull;
exports.isUndefined = isUndefined;
exports.isString = isString;
exports.isNumber = isNumber;
exports.isBoolean = isBoolean;
exports.isArray = isArray;
exports.isObject = isObject;
function is (type, obj) {
return Object.prototype.toString.call(obj) === '[object '+type+']';
}
function isArray (obj) {
return is("Array", obj);
}
function isObject (obj) {
return is("Object", obj);
}
function isString (obj) {
return is("String", obj);
}
function isNumber (obj) {
return is("Number", obj);
}
function isBoolean (obj) {
return is("Boolean", obj);
}
function isNull (obj) {
return typeof obj === "object" && !obj;
}
function isUndefined (obj) {
return typeof obj === "undefined";
}