Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

melody-compiler

Package Overview
Dependencies
Maintainers
3
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

melody-compiler - npm Package Compare versions

Comparing version 1.2.0-04d171a.4 to 1.2.0-42f95e8.8

10

package.json
{
"name": "melody-compiler",
"version": "1.2.0-04d171a.4+04d171a",
"version": "1.2.0-42f95e8.8+42f95e8",
"description": "",

@@ -17,3 +17,3 @@ "main": "./lib/index.js",

"lodash": "^4.12.0",
"melody-code-frame": "1.2.0-04d171a.4+04d171a",
"melody-code-frame": "1.2.0-42f95e8.8+42f95e8",
"random-seed": "^0.3.0"

@@ -29,6 +29,6 @@ },

"devDependencies": {
"melody-extension-core": "1.2.0-04d171a.4+04d171a",
"melody-plugin-idom": "1.2.0-04d171a.4+04d171a"
"melody-extension-core": "1.2.0-42f95e8.8+42f95e8",
"melody-plugin-idom": "1.2.0-42f95e8.8+42f95e8"
},
"gitHead": "04d171a1547d5dd95966e4a4b416db6cec429bd2"
"gitHead": "42f95e8a9d2eb19120722cede9c9b395e4e81c17"
}

@@ -44,8 +44,52 @@ /**

const node = path.node;
path.replaceWithJS({
type: 'BinaryExpression',
operator: '+',
left: node.left,
right: node.right,
});
if (t.isStringLiteral(node.left)) {
if (t.isStringLiteral(node.right)) {
path.replaceWithJS(
t.stringLiteral(node.left.value + node.right.value)
);
} else {
path.replaceWithJS(
t.templateLiteral(
[t.templateElement({cooked: node.left.value, raw: node.left.value}), t.templateElement({cooked: '', raw: ''})],
[node.right]
)
);
}
} else if (t.isTemplateLiteral(node.left)) {
if (t.isStringLiteral(node.right)) {
// we need to append the new value to the last quasi
// to keep things predictable and pure we start by cloning the existing structure
const quasis = node.left.quasis.map(quasi => t.templateElement({ cooked: quasi.value.cooked, raw: quasi.value.raw }));
const last = quasis[quasis.length - 1];
last.value.cooked += node.right.value;
last.value.raw += node.right.value;
path.replaceWithJS(
t.templateLiteral(
quasis,
node.left.expressions
)
);
} else {
path.replaceWithJS(
t.templateLiteral(
[...node.left.quasis, t.templateElement({cooked: '', raw: ''})],
[...node.left.expressions, node.right]
)
);
}
} else if (t.isStringLiteral(node.right)) {
path.replaceWithJS(
t.templateLiteral(
[t.templateElement({cooked: '', raw: ''}), t.templateElement({cooked: node.right.value, raw: node.right.value})],
[node.left]
)
);
} else {
path.replaceWithJS(
t.templateLiteral(
[t.templateElement({cooked: '', raw: ''}), t.templateElement({cooked: '', raw: ''}), t.templateElement({cooked: '', raw: ''})],
[node.left, node.right]
)
);
}
},

@@ -52,0 +96,0 @@ },

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

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