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

code-red

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

code-red - npm Package Compare versions

Comparing version 0.0.5 to 0.0.6

4

CHANGELOG.md
# code-red changelog
## 0.0.6
* Flatten arguments and parameters
## 0.0.5

@@ -4,0 +8,0 @@

48

dist/code-red.js

@@ -152,7 +152,7 @@ (function (global, factory) {

const flatten = (array, target) => {
const flatten_body = (array, target) => {
for (let i = 0; i < array.length; i += 1) {
const statement = array[i];
if (Array.isArray(statement)) {
flatten(statement, target);
flatten_body(statement, target);
continue;

@@ -165,3 +165,3 @@ }

if (Array.isArray(statement.expression)) {
flatten(statement.expression, target);
flatten_body(statement.expression, target);
continue;

@@ -177,2 +177,19 @@ }

const flatten = (nodes, target) => {
for (let i = 0; i < nodes.length; i += 1) {
const node = nodes[i];
if (!node) continue;
if (Array.isArray(node)) {
flatten(node, target);
continue;
}
target.push(node);
}
return target;
};
const inject = (node, values) => {

@@ -188,10 +205,14 @@ estreeWalker.walk(node, {

if (match) {
const value = match[1]
? +match[1] in values ? values[+match[1]] : match[1]
: { type: 'Identifier', name: `${match[2] ? `@` : `#`}${match[4]}` };
if (match[1]) {
if (+match[1] in values) {
const value = values[+match[1]];
if (index === null) {
parent[key] = value;
if (index === null) {
parent[key] = value;
} else {
parent[key][index] = value;
}
}
} else {
parent[key][index] = value;
node.name = `${match[2] ? `@` : `#`}${match[4]}`;
}

@@ -202,4 +223,7 @@ }

if (node.type === 'Program' || node.type === 'BlockStatement') {
node.body = flatten(node.body, []);
node.body = flatten_body(node.body, []);
}
if (node.params) node.params = flatten(node.params, []);
if (node.arguments) node.arguments = flatten(node.arguments, []);
}

@@ -223,3 +247,3 @@ });

} catch (err) {
console.log(str); // TODO proper error reporting
console.log(`failed to parse:\n${str}`); // TODO proper error reporting
throw err;

@@ -239,3 +263,3 @@ }

} catch (err) {
console.log(str); // TODO proper error reporting
console.log(`failed to parse:\n${str}`); // TODO proper error reporting
throw err;

@@ -242,0 +266,0 @@ }

{
"name": "code-red",
"description": "code-red",
"version": "0.0.5",
"version": "0.0.6",
"repository": "Rich-Harris/code-red",

@@ -6,0 +6,0 @@ "main": "dist/code-red.js",

Sorry, the diff of this file is not supported yet

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