New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

babel-plugin-flow-type-getter

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-flow-type-getter - npm Package Compare versions

Comparing version 1.0.4 to 1.0.5

12

example/dist/index.js

@@ -91,9 +91,10 @@ class Test1 {

const test1_str = 't1';
const testing_this_string = 'prop1';
console.log('unary test : ', (() => {
if (obj_test[test1_str].__getFlowTypes != null) {
return obj_test[test1_str].__getFlowTypes().prop1.stringified;
if (Test1.__getFlowTypes != null) {
return Test1.__getFlowTypes()[testing_this_string].stringified;
} else {
//_____babel-plugin-flow-type-getter-marker-comment____
return typeof obj_test[test1_str].prop1;
return typeof Test1.testing_this_string;
}

@@ -111,6 +112,6 @@ })()); // number

if (Test1.__getFlowTypes != null) {
return Test1.__getFlowTypes().prop5.is_array;
return Test1.__getFlowTypes()['prop5'].is_array;
} else {
//_____babel-plugin-flow-type-getter-marker-comment____
return Array.isArray(Test1.prop5);
return Array.isArray(Test1.undefined);
}

@@ -122,5 +123,4 @@ })()); // false

} else {
//_____babel-plugin-flow-type-getter-marker-comment____
return Array.isArray(obj_test['t2'].prop2);
}
})()); // true

@@ -39,6 +39,7 @@ class Test1 {

const test1_str = 't1';
const testing_this_string = 'prop1';
console.log('unary test : ', typeof obj_test[test1_str].prop1); // number
console.log('unary test : ', typeof Test1[testing_this_string]); // number
console.log('binary test : ', typeof obj_test.t1.prop2 == 'User'); // true
console.log('array test : ', Array.isArray(Test1.prop5)); // false
console.log('array test : ', Array.isArray(Test1['prop5'])); // false
console.log('array test : ', Array.isArray(obj_test['t2'].prop2)) // true

@@ -101,3 +101,4 @@ const babylon = require('babylon');

const replacementGenerator = (node, replacement_case) => {
const replacementGenerator = (path, replacement_case) => {
const { node } = path;
let expression, object_string, prop_name, code_expression;

@@ -108,3 +109,13 @@ switch(replacement_case) {

prop_name = node.argument.property.name;
expression = `${object_string}.${customFunctionName}().${prop_name}.stringified`;
if(node.argument.computed) {
if(t.isStringLiteral(node.argument.property)) {
expression = `${object_string}.${customFunctionName}()['${node.argument.property.value}'].stringified`;
}
else {
expression = `${object_string}.${customFunctionName}()[${prop_name}].stringified`;
}
}
else {
expression = `${object_string}.${customFunctionName}().${prop_name}.stringified`;
}
code_expression = `typeof ${object_string}.${prop_name}`;

@@ -120,3 +131,13 @@ break;

}
expression = `${object_string}.${customFunctionName}().${prop_name}.types.find(__type => __type == '${right_value}') != null`;
if(left.argument.computed) {
if(t.isStringLiteral(eft.argument.property)) {
expression = `${object_string}.${customFunctionName}()['${left.argument.property.value}'].types.find(__type => __type == '${right_value}') != null`;
}
else {
expression = `${object_string}.${customFunctionName}()[${prop_name}].types.find(__type => __type == '${right_value}') != null`;
}
}
else {
expression = `${object_string}.${customFunctionName}().${prop_name}.types.find(__type => __type == '${right_value}') != null`;
}
code_expression = `typeof ${object_string}.${prop_name} == ${right_value}`;

@@ -128,3 +149,13 @@ break;

prop_name = argument.property.name;
expression = `${object_string}.${customFunctionName}().${prop_name}.is_array`;
if(argument.computed) {
if(t.isStringLiteral(argument.property)) {
expression = `${object_string}.${customFunctionName}()['${argument.property.value}'].is_array`;
}
else {
expression = `${object_string}.${customFunctionName}()[${prop_name}].is_array`;
}
}
else {
expression = `${object_string}.${customFunctionName}().${prop_name}.is_array`;
}
code_expression = `Array.isArray(${object_string}.${prop_name})`;

@@ -214,3 +245,3 @@ break;

path.replaceWith(
replacementGenerator(path.node, 'unary')
replacementGenerator(path, 'unary')
)

@@ -230,3 +261,3 @@ }

path.replaceWith(
replacementGenerator(path.node, 'binary')
replacementGenerator(path, 'binary')
)

@@ -250,3 +281,3 @@ }

path.replaceWith(
replacementGenerator(path.node, 'array')
replacementGenerator(path, 'array')
)

@@ -253,0 +284,0 @@ }

{
"name": "babel-plugin-flow-type-getter",
"version": "1.0.4",
"version": "1.0.5",
"description": "Access flow types from uninstantiated classes.",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc