UNPKG

720 BJavaScriptView Raw
1
2
3/**
4 * Create a semi UUID
5 * 9e17 is close to max of var
6 * @return {String} uuid
7 */
8exports.getUID = function () {
9 return Math.floor(Math.random() * 9e17).toString(36);
10};
11
12
13/**
14 * Get the type of something
15 * @param object
16 * @returns {string}
17 */
18exports.getType = function (object) {
19 if (object === null) {
20 return "null";
21 }
22 else if (object === undefined) {
23 return "undefined";
24 }
25 else if (object.constructor === stringConstructor) {
26 return "String";
27 }
28 else if (object.constructor === arrayConstructor) {
29 return "Array";
30 }
31 else if (object.constructor === objectConstructor) {
32 return "Object";
33 }
34 else {
35 return "don't know";
36 }
37};