-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathindex.js
More file actions
169 lines (144 loc) · 3.9 KB
/
index.js
File metadata and controls
169 lines (144 loc) · 3.9 KB
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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
// Generated by CoffeeScript 1.10.0
(function() {
"use strict";
var AUTO, Date, FUNCTION, NUMBER, OBJECT, Object, Phaser, RegExp, WHITE, aqua, blue, colorForValue, colors, defaultOptions, defaults, formatValue, fuchsia, gray, isArray, lime, orange, purple, red, silver, white, yellow;
Date = this.Date, Object = this.Object, Phaser = this.Phaser, RegExp = this.RegExp;
isArray = Array.isArray;
AUTO = "auto";
FUNCTION = "function";
NUMBER = "number";
OBJECT = "object";
WHITE = "white";
aqua = "#7fdbff";
blue = "#0074d9";
fuchsia = "#f012be";
gray = "#666666";
lime = "#01ff70";
orange = "#ff851b";
purple = "#b10dc9";
red = "#ff4136";
silver = "#aaaaaa";
white = "#ffffff";
yellow = "#ffdc00";
colors = {
boolean: orange,
date: purple,
"default": white,
"function": blue,
nan: red,
"null": silver,
number: yellow,
regexp: fuchsia,
special: aqua,
string: lime,
undefined: gray
};
defaultOptions = {
boldLabel: true,
color: WHITE,
filter: null,
keys: null,
label: null,
precision: 2,
sort: false
};
colorForValue = function(val) {
var typ;
typ = typeof val;
switch (false) {
case val !== null:
return colors["null"];
case val === val:
return colors.nan;
case !(val instanceof Date):
return colors.date;
case !(val instanceof RegExp):
return colors.regexp;
case !(typ === OBJECT && val.constructor !== Object):
return colors.special;
default:
return colors[typ] || colors["default"];
}
};
defaults = function(target) {
var key, val;
for (key in defaultOptions) {
val = defaultOptions[key];
if (!(key in target)) {
target[key] = val;
}
}
return target;
};
formatValue = function(val, precision) {
var ref, typ;
typ = typeof val;
switch (false) {
case !isArray(val):
return "(" + val.length + ")";
case typ !== NUMBER:
if (val % 1) {
return val.toFixed(precision);
} else {
return val;
}
case !(val instanceof Date):
case !(val instanceof RegExp):
return val.toString();
case !(typ === OBJECT && (val != null ? (ref = val.constructor) != null ? ref.name : void 0 : void 0)):
return val.constructor.name;
case typeof val !== FUNCTION:
return "[function " + val.name + "]";
case !(val != null ? val.toString : void 0):
return val.toString();
default:
return val;
}
};
Phaser.Utils.Debug.prototype.object = function(obj, x, y, options) {
var boldLabel, color, colorize, currentColor, filter, font, i, key, keys, label, len, map, precision, val;
if (options == null) {
options = {};
}
options = defaults(options);
boldLabel = options.boldLabel, color = options.color, filter = options.filter, keys = options.keys, label = options.label, map = options.map, precision = options.precision;
currentColor = this.currentColor, font = this.font;
if (color === AUTO) {
color = null;
colorize = true;
}
if (color == null) {
color = WHITE;
}
if (keys == null) {
keys = Object.keys(obj);
}
if (options.sort) {
keys.sort();
}
if (map) {
obj = obj.map(map);
}
this.start(x, y, color);
if (label) {
if (boldLabel) {
this.context.font = "bold " + font;
}
this.line(label);
if (boldLabel) {
this.context.font = font;
}
}
for (i = 0, len = keys.length; i < len; i++) {
key = keys[i];
val = obj[key];
if (filter && !filter(val, key)) {
continue;
}
this.currentColor = (colorize && colorForValue(val)) || color;
this.line(key + ": " + (formatValue(val, precision)));
}
this.stop();
this.currentColor = currentColor;
};
}).call(this);