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.0 to 1.0.1

3

config.js

@@ -132,2 +132,3 @@ /*

, '=>': undefined
, '**': undefined

@@ -140,5 +141,7 @@ , '===': undefined

, '...': undefined
, '**=': undefined
, '>>>=': undefined
, _default: undefined

@@ -145,0 +148,0 @@ }

4

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

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

"dependencies": {
"esprima": "~2.7.0"
"esprima": "~3.0.0"
}
}

@@ -184,4 +184,4 @@ # redeyed [![build status](https://secure.travis-ci.org/thlorenz/redeyed.png?branch=master)](http://travis-ci.org/thlorenz/redeyed)

```html
<script type="text/javascript" src="https://raw.github.com/ariya/esprima/master/esprima.js"></script>
<script type="text/javascript" src="path/to/redeyed.js"></script>
<script type="text/javascript" src="https://unpkg.com/esprima"></script>
<script type="text/javascript" src="https://unpkg.com/redeyed"></script>
```

@@ -188,0 +188,0 @@

@@ -178,6 +178,4 @@ ;(function () {

// remove shebang
code = code.replace(/^\#\!.*/, '');
var ast
var hashbang = ''
, ast
, tokens

@@ -192,2 +190,8 @@ , comments

// Replace hashbang line with empty whitespaces to preserve token locations
if (code[0] === '#' && code[1] === '!') {
hashbang = code.substr(0, code.indexOf('\n') + 1);
code = Array.apply(0, Array(hashbang.length)).join(' ') + '\n' + code.substr(hashbang.length);
}
if (buildAst) {

@@ -304,5 +308,10 @@ ast = parser.parse(code, { tokens: true, comment: true, range: true, tolerant: true });

transformedCode = opts.nojoin ? undefined : splits.join('');
if (!opts.nojoin) {
transformedCode = splits.join('');
if (hashbang.length > 0) {
transformedCode = hashbang + transformedCode.substr(hashbang.length);
}
}
return {
return {
ast : ast

@@ -309,0 +318,0 @@ , tokens : tokens

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

test('removes shebang from the code before parsing it', function (t) {
test('preserves shebang', function (t) {
var code = [

@@ -19,3 +19,6 @@ '#!/usr/bin/env node'

, opts = { Keyword: { 'var': '%:^' } }
, expected = '\n%var^ util = require("util");'
, expected = [
'#!/usr/bin/env node'
, '%var^ util = require("util");'
].join('\n')
, res = redeyed(code, opts).code

@@ -22,0 +25,0 @@

@@ -10,2 +10,3 @@ 'use strict';

, redeyed = require('..')
, esprima = require('esprima')
, node_modules = path.join(__dirname, '..', 'node_modules')

@@ -17,11 +18,3 @@ , tapdir = path.join(node_modules, 'tap')

var invalidTapFiles = [
'services/localGit.js'
, 'lib/handlebars/runtime.js'
, 'handlebars/lib/precompiler.js'
, 'handlebars/compiler/javascript-compiler.js'
, 'slide/lib/async-map-ordered.js'
, 'resolve/test/precedence/'
, 'is-relative/index.js'
, 'is-buffer/test/'
, 'lodash/utility/'
]

@@ -39,11 +32,16 @@

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)) {
return
}
if (!shouldProcess(entry.fullPath) || !containsVarKeyword(code)) return
var code = fs.readFileSync(entry.fullPath, 'utf-8')
, resultAst = redeyed(code, { Keyword: { 'var': '+:-' } }, { buildAst: true }).code
var resultAst = redeyed(code, { Keyword: { 'var': '+:-' } }, { buildAst: true }).code
, resultTokenize = redeyed(code, { Keyword: { 'var': '+:-' } }, { buildAst: false }).code

@@ -50,0 +48,0 @@

@@ -33,2 +33,4 @@ 'use strict';

t.assertSurrounds('x={y,...z}', punctuator, 'x$=%${%y$,%$...%z$}%')
t.assertSurrounds('x ** y', punctuator, 'x $**% y');
t.assertSurrounds('x **= y', punctuator, 'x $**=% y');
t.end()

@@ -35,0 +37,0 @@ })

Sorry, the diff of this file is not supported yet

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