Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function pushDescriptors() {
pushInheritsToBody();
const { body } = classState;
let instanceProps;
let staticProps;
if (classState.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(classState.instanceMutatorMap);
}
if (classState.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(classState.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) {
instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
}
if (staticProps) {
staticProps = defineMap.toComputedObjectFromClass(staticProps);
}
let args = [
t.cloneNode(classState.classRef), // Constructor
function pushDescriptors() {
pushInheritsToBody();
const { body } = classState;
let instanceProps;
let staticProps;
if (classState.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(classState.instanceMutatorMap);
}
if (classState.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(classState.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) {
instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
}
if (staticProps) {
staticProps = defineMap.toComputedObjectFromClass(staticProps);
}
let args = [
t.cloneNode(classState.classRef), // Constructor
t.nullLiteral(), // instanceDescriptors
t.nullLiteral(), // staticDescriptors
];
const { body } = classState;
let instanceProps;
let staticProps;
if (classState.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(classState.instanceMutatorMap);
}
if (classState.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(classState.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) {
instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
}
if (staticProps) {
staticProps = defineMap.toComputedObjectFromClass(staticProps);
}
let args = [
t.cloneNode(classState.classRef), // Constructor
t.nullLiteral(), // instanceDescriptors
t.nullLiteral(), // staticDescriptors
];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
let lastNonNullIndex = 0;
for (let i = 0; i < args.length; i++) {
let staticProps;
if (classState.hasInstanceDescriptors) {
instanceProps = defineMap.toClassObject(classState.instanceMutatorMap);
}
if (classState.hasStaticDescriptors) {
staticProps = defineMap.toClassObject(classState.staticMutatorMap);
}
if (instanceProps || staticProps) {
if (instanceProps) {
instanceProps = defineMap.toComputedObjectFromClass(instanceProps);
}
if (staticProps) {
staticProps = defineMap.toComputedObjectFromClass(staticProps);
}
let args = [
t.cloneNode(classState.classRef), // Constructor
t.nullLiteral(), // instanceDescriptors
t.nullLiteral(), // staticDescriptors
];
if (instanceProps) args[1] = instanceProps;
if (staticProps) args[2] = staticProps;
let lastNonNullIndex = 0;
for (let i = 0; i < args.length; i++) {
if (!t.isNullLiteral(args[i])) lastNonNullIndex = i;
}
args = args.slice(0, lastNonNullIndex + 1);
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;
}
});
function pushToMap(node, enumerable, kind = "value", scope?) {
let mutatorMap;
if (node.static) {
setState({ hasStaticDescriptors: true });
mutatorMap = classState.staticMutatorMap;
} else {
setState({ hasInstanceDescriptors: true });
mutatorMap = classState.instanceMutatorMap;
}
const map = defineMap.push(mutatorMap, node, kind, classState.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;
}
});
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)],
),
);
},
},
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)],
),
);
},
},