Skip to content
This repository was archived by the owner on Jul 19, 2025. It is now read-only.

Ensure value is always defined before access #25

Merged
merged 1 commit into from
Oct 27, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 13 additions & 11 deletions lib/cc/engine/analyzers/javascript/parser.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,19 @@ var format = function(node) {
if (node.hasOwnProperty(prop) && !prop.startsWith("_") && toScrub.indexOf(prop) === -1) {
var value = node[prop];

if (value && value.constructor === Array) {
result[prop] = value.map(function(p) {
return format(p)
});
} else if (prop === "loc") {
result["start"] = value.start.line;
result["end"] = value.end.line;
} else if (value && typeof(value) === "object") {
result[prop] = format(value);
} else if (value) {
result[prop] = node[prop];
if (value) {
if (value.constructor === Array) {
result[prop] = value.map(function(p) {
return format(p)
});
} else if (prop === "loc") {
result["start"] = value.start.line;
result["end"] = value.end.line;
} else if (typeof(value) === "object") {
result[prop] = format(value);
} else {
result[prop] = node[prop];
}
}
}
}
Expand Down