Socket
Socket
Sign inDemoInstall

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.6 to 0.0.7

4

CHANGELOG.md
# code-red changelog
## 0.0.7
* Various
## 0.0.6

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

71

dist/code-red.js
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('astring'), require('periscopic'), require('estree-walker'), require('is-reference'), require('acorn')) :
typeof define === 'function' && define.amd ? define(['exports', 'astring', 'periscopic', 'estree-walker', 'is-reference', 'acorn'], factory) :
(factory((global.CodeRed = {}),global.astring,global.perisopic,global.estreeWalker,global.is_reference,global.acorn));
}(this, (function (exports,astring,perisopic,estreeWalker,is_reference,acorn) { 'use strict';
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('astring'), require('periscopic'), require('acorn'), require('estree-walker')) :
typeof define === 'function' && define.amd ? define(['exports', 'astring', 'periscopic', 'acorn', 'estree-walker'], factory) :
(factory((global.CodeRed = {}),global.astring,global.perisopic,global.acorn,global.estreeWalker));
}(this, (function (exports,astring,perisopic,acorn,estreeWalker) { 'use strict';
is_reference = is_reference && is_reference.hasOwnProperty('default') ? is_reference['default'] : is_reference;
function deconflict(name, names) {

@@ -28,13 +26,7 @@ const original = name;

estreeWalker.walk(node, {
enter(node, parent) {
if (is_reference(node, parent)) ;
}
});
const generator = Object.assign({}, astring.baseGenerator, {
handle( node, state) {
// console.log('----> handling', JSON.stringify(node, null, ' '));
if (Array.isArray(node)) {
console.log(node);
throw new Error('hmm');
for (let i = 0; i < node.length; i += 1) {

@@ -63,6 +55,6 @@ this.handle(node[i], state);

if (!err.depth) {
console.log(`${err.message} while handling`, node);
console.log(`${err.message} while handling`, JSON.stringify(node, null, ' '));
err.depth = 1;
} else if (err.depth <= 3) {
console.log(`${err.depth}:`, node);
console.log(`${err.depth}:`, JSON.stringify(node, null, ' '));
err.depth += 1;

@@ -74,2 +66,3 @@ }

},
AwaitExpression( node, state) {

@@ -81,14 +74,2 @@ state.write('await ');

FunctionExpression( node, state) {
const params = [].concat(...node.params.map((param) => {
if (param.type === 'SequenceExpression') {
return param.expressions;
}
return param;
}));
return astring.baseGenerator.FunctionExpression.call(this, { ...node, params }, state);
},
Identifier( node, state) {

@@ -125,2 +106,11 @@ if (!node.name) {

return astring.baseGenerator.Identifier.call(this, node, state);
},
Literal( node, state) {
if (typeof node.value === 'string') {
state.write(JSON.stringify(node.value));
return;
}
astring.baseGenerator.Literal.call(this, node, state);
}

@@ -144,2 +134,6 @@ });

// generate an ID that is, to all intents and purposes, unique
const id = (Math.round(Math.random() * 1e20)).toString(36);
const re = new RegExp(`_${id}_(?:(\\d+)|(AT)|(HASH))_(\\w+)?`, 'g');
const sigils = {

@@ -153,5 +147,5 @@ '@': 'AT',

for (let i = 1; i < strings.length; i += 1) {
str += `___${i - 1}___${strings[i]}`;
str += `_${id}_${i - 1}_${strings[i]}`;
}
return str.replace(/([@#])(\w+)/g, (_m, sigil, name) => `___${sigils[sigil]}___${name}`);
return str.replace(/([@#])(\w+)/g, (_m, sigil, name) => `_${id}_${sigils[sigil]}_${name}`);
};

@@ -206,3 +200,4 @@

if (node.type === 'Identifier') {
const match = /___(?:(\d+)|(AT)|(HASH))___(\w+)?/.exec(node.name);
re.lastIndex = 0;
const match = re.exec(node.name);

@@ -226,2 +221,9 @@ if (match) {

if (node.type === 'Literal') {
if (typeof node.value === 'string') {
re.lastIndex = 0;
node.value = node.value.replace(re, (m, i) => +i in values ? values[+i] : m);
}
}
if (node.type === 'Program' || node.type === 'BlockStatement') {

@@ -233,2 +235,3 @@ node.body = flatten_body(node.body, []);

if (node.arguments) node.arguments = flatten(node.arguments, []);
if (node.specifiers) node.specifiers = flatten(node.specifiers, []);
}

@@ -261,3 +264,7 @@ });

try {
const expression = acorn.parseExpressionAt(str);
const expression = acorn.parseExpressionAt(str, 0, {
allowAwaitOutsideFunction: true,
allowImportExportEverywhere: true,
allowReturnOutsideFunction: true
});

@@ -264,0 +271,0 @@ inject(expression, values);

{
"name": "code-red",
"description": "code-red",
"version": "0.0.6",
"version": "0.0.7",
"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