Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const allScopes = frame.scopeChain;
let count = allScopes.length;
// We find the top-level (module global) variable pollute the local
// variables we omit them by default, unless the breakpoint itself is
// top-level. The last scope is always omitted.
if (frame.scopeChain[count - 2].type === 'closure') {
count -= 2;
} else {
count -= 1;
}
for (let i = 0; i < count; ++i) {
const result = this.v8Inspector.getProperties({
objectId: frame.scopeChain[i].object.objectId as string,
});
// TODO: Handle when result.error exists.
if (result.response && !is.emptyArray(result.response.result)) {
for (let j = 0; j < result.response.result.length; ++j) {
if (!usedNames[result.response.result[j].name]) {
// It's a valid variable that belongs in the locals list
// and wasn't discovered at a lower-scope
usedNames[result.response.result[j].name] = true;
if (result.response.result[j].value) {
locals.push(
this.resolveVariable_(
result.response.result[j].name,
result.response.result[j]
.value as inspector.Runtime.RemoteObject,
false
)
);
}
}
// interceptors and getters by default.
if (!underFrameCap) {
args.push({
name: 'arguments_not_available',
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX,
});
locals.push({
name: 'locals_not_available',
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX,
});
} else {
// We will use the values aggregated from the ScopeMirror traversal stored
// in locals which will include any applicable arguments from the
// invocation.
locals = this.resolveLocalsList_(frame);
if (is.emptyArray(locals)) {
locals = [];
}
}
return {
function: this.resolveFunctionName_(frame.func()),
location: this.resolveLocation_(frame),
arguments: args,
locals,
};
}
const args: stackdriver.Variable[] = [];
let locals: Array<{}> = [];
if (!underFrameCap) {
args.push({
name: 'arguments_not_available',
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX,
});
locals.push({
name: 'locals_not_available',
varTableIndex: ARG_LOCAL_LIMIT_MESSAGE_INDEX,
});
} else {
locals = this.resolveLocalsList_(frame);
if (is.emptyArray(locals)) {
locals = [];
}
}
return {
function: this.resolveFunctionName_(frame),
location: this.resolveLocation_(frame),
arguments: args,
locals,
};
}
const merge = (requestData, responseData) => {
requestData = [].concat(requestData)
if (!responseData || is.emptyArray(responseData)) {
return requestData
}
responseData = [].concat(responseData)
return requestData.map(
(data, index) => (data) ? mergeDeepWith(mergeDiff, data, responseData[index]) : responseData[index]
)
}
const mergeDiff = (left, right) =>
(is.undefined(right) || (is.emptyArray(right) && is.nonEmptyArray(left)))
? left : right