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

redeyed

Package Overview
Dependencies
Maintainers
1
Versions
20
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redeyed - npm Package Compare versions

Comparing version 1.0.1 to 2.0.0

10

package.json
{
"name": "redeyed",
"version": "1.0.1",
"version": "2.0.0",
"description": "Takes JavaScript code, along with a config and returns the original code with tokens wrapped as configured.",

@@ -26,9 +26,9 @@ "author": "Thorsten Lorenz <thlorenz@gmx.de> (thlorenz.com)",

"devDependencies": {
"tap": "~5.7.0",
"readdirp": "~0.3.3",
"cardinal": "~0.4.4"
"cardinal": "~1.0.0",
"readdirp": "~2.1.0",
"tap": "~11.1.4"
},
"dependencies": {
"esprima": "~3.0.0"
"esprima": "~4.0.0"
}
}

@@ -196,3 +196,3 @@ ;(function () {

if (buildAst) {
ast = parser.parse(code, { tokens: true, comment: true, range: true, tolerant: true });
ast = parser.parse(code, { tokens: true, comment: true, range: true, loc: true, tolerant: true });
tokens = ast.tokens;

@@ -203,3 +203,3 @@ comments = ast.comments;

comments = [];
parser.tokenize(code, { range: true, comment: true }, function (token) {
parser.tokenize(code, { range: true, loc: true, comment: true }, function (token) {
if (token.type === 'LineComment') {

@@ -206,0 +206,0 @@ token.type = 'Line';

@@ -17,3 +17,3 @@ 'use strict';

, ast = esprima.parse(code, { tokens: true, comment: true, range: true, tolerant: true })
, ast = esprima.parse(code, { tokens: true, comment: true, range: true, loc: true, tolerant: true })
, tokens = ast.tokens

@@ -34,4 +34,3 @@ , comments = ast.comments

, conf = { Keyword: { _default: '_:-' } }
, ast = esprima.parse(code, { tokens: true, comment: true, range: true, tolerant: true })
, ast = esprima.parse(code, { tokens: true, comment: true, range: true, loc: true, tolerant: true })
, tokens = ast.tokens

@@ -42,3 +41,2 @@ , comments = ast.comments

console.log(ast)
t.deepEquals(result.ast, ast, 'ast')

@@ -55,4 +53,3 @@ t.deepEquals(result.tokens, tokens, 'tokens')

, conf = { Keyword: { _default: '_:-' } }
, ast = esprima.parse(code, { tokens: true, comment: true, range: true, tolerant: true })
, ast = esprima.parse(code, { tokens: true, comment: true, range: true, loc: true, tolerant: true })
, tokens = ast.tokens

@@ -59,0 +56,0 @@ , comments = ast.comments

@@ -15,39 +15,2 @@ 'use strict';

test('tap', function (t) {
var invalidTapFiles = [
, 'slide/lib/async-map-ordered.js'
]
function shouldProcess (path) {
var include = true
invalidTapFiles.every(function (entry) {
return include = (path.indexOf(entry) < 0)
});
return include
}
function containsVarKeyword(code) {
code = code.replace(/^#!([^\r\n]+)/, function(match, captured) { return "//" + captured; });
return esprima.tokenize(code).some(function (t) {
return t.type === 'Keyword' && t.value === 'var'
})
}
readdirp({ root: tapdir, fileFilter: '*.js' })
.on('data', function (entry) {
var code = fs.readFileSync(entry.fullPath, 'utf-8')
if (!shouldProcess(entry.fullPath) || !containsVarKeyword(code)) return
var resultAst = redeyed(code, { Keyword: { 'var': '+:-' } }, { buildAst: true }).code
, resultTokenize = redeyed(code, { Keyword: { 'var': '+:-' } }, { buildAst: false }).code
t.assert(~resultAst.indexOf('+var-') || !(~resultAst.indexOf('var ')), 'redeyed ' + entry.path)
t.assert(~resultTokenize.indexOf('+var-') || !(~resultTokenize.indexOf('var ')), 'redeyed ' + entry.path)
})
.on('end', t.end.bind(t))
})
test('esprima', function (t) {

@@ -54,0 +17,0 @@

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