Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
pushDescriptors() {
this.pushInherits();
let body = this.body;
let instanceProps;
let staticProps;
if (this.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
}
if (this.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
let nullNode = t.nullLiteral();
// (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
let args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
if (this.instanceInitializersId) {
args[3] = this.instanceInitializersId;
pushDescriptors() {
this.pushInherits();
let body = this.body;
let instanceProps;
let staticProps;
if (this.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
}
if (this.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
let nullNode = t.nullLiteral();
// (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
let args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
if (instanceProps) args[1] = instanceProps;
let body = this.body;
let instanceProps;
let staticProps;
if (this.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
}
if (this.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
let nullNode = t.nullLiteral();
// (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
let args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
if (this.instanceInitializersId) {
args[3] = this.instanceInitializersId;
body.unshift(this.buildObjectAssignment(this.instanceInitializersId));
}
if (this.staticInitializersId) {
let body = this.body;
let instanceProps;
let staticProps;
if (this.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(this.instanceMutatorMap);
}
if (this.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(this.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
if (staticProps) staticProps = defineMap.toComputedObjectFromClass(staticProps);
let nullNode = t.nullLiteral();
// (Constructor, instanceDescriptors, staticDescriptors, instanceInitializers, staticInitializers)
let args = [this.classRef, nullNode, nullNode, nullNode, nullNode];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
if (this.instanceInitializersId) {
args[3] = this.instanceInitializersId;
body.unshift(this.buildObjectAssignment(this.instanceInitializersId));
}
if (this.staticInitializersId) {
args[4] = this.staticInitializersId;
pushToMap(node, enumerable, kind = "value", scope) {
let mutatorMap;
if (node.static) {
this.hasStaticDescriptors = true;
mutatorMap = this.staticMutatorMap;
} else {
this.hasInstanceDescriptors = true;
mutatorMap = this.instanceMutatorMap;
}
let map = defineMap.push(mutatorMap, node, kind, this.file, scope);
if (enumerable) {
map.enumerable = t.booleanLiteral(true);
}
return map;
}
node.properties = node.properties.filter(function (prop) {
if (!prop.computed && (prop.kind === "get" || prop.kind === "set")) {
defineMap.push(mutatorMap, prop, null, file);
return false;
} else {
return true;
}
});
if (!hasAny) return;
let mutatorMap = {};
node.properties = node.properties.filter(function (prop) {
if (!prop.computed && (prop.kind === "get" || prop.kind === "set")) {
defineMap.push(mutatorMap, prop, null, file);
return false;
} else {
return true;
}
});
path.replaceWith(t.callExpression(
t.memberExpression(t.identifier("Object"), t.identifier("defineProperties")),
[node, defineMap.toDefineObject(mutatorMap)]
));
}
}