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

es6-deps

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

es6-deps - npm Package Compare versions

Comparing version 1.1.8 to 1.1.9

test/files/a.js

21

index.js

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

var path = require('path');
var strip = require('strip-comments');
var _resolve = require('resolve');

@@ -39,11 +38,17 @@

}
/*
* 消除所有带*的字符串,保证不会因为*而破坏strip-comments
* remove star and comments
*/
function rm_star(str) {
return str.split('\n').map(function (line) {
return line.replace(/'[^']+\*[^']*'/g, "''").replace(/"[^"]+\*[^"]*"/g, '""')
// .replace(/\/\*+\//, '')
.replace(/\/\S*\*+\S*\/[a-z]*/g, '');
function removeStarAndComments(str) {
var text = str.split('\n').map(function (line) {
line = line.replace(/'[^']+\*[^']*'/g, "''").replace(/"[^"]+\*[^"]*"/g, '""')
// remove line comment
.replace(/^\/\/.*$/gm, '').replace(/(?:[^\\])\/\/.*$/gm, '');
return line;
}).join('\n');
// remove block comment
text = text.replace(/^\/\*[\S\s]*?\*\//g, '').replace(/(?:[^\\])\/\*[\S\s]*?\*\//g, '');
console.log(text);
return text;
}

@@ -83,3 +88,3 @@

var deps = [];
strip(rm_star(content)).split('\n').filter(function (line) {
removeStarAndComments(content).split('\n').filter(function (line) {
return line.indexOf('require') > -1 || line.indexOf('from') > -1 || line.indexOf('import') > -1;

@@ -86,0 +91,0 @@ }).forEach(function (line) {

{
"name": "es6-deps",
"version": "1.1.8",
"version": "1.1.9",
"description": "a simple util to get es6/jsx dependencies",

@@ -12,4 +12,3 @@ "main": "index.js",

"isdir": "^2.0.1",
"resolve": "^1.1.6",
"strip-comments": "^0.3.2"
"resolve": "^1.1.6"
},

@@ -16,0 +15,0 @@ "devDependencies": {

var isdir = require('isdir');
var fs = require('fs');
var path = require('path');
var strip = require('strip-comments');
var resolve = require('resolve');

@@ -33,16 +32,26 @@

}
/*
* 消除所有带*的字符串,保证不会因为*而破坏strip-comments
* remove star and comments
*/
function rm_star(str) {
return str.split('\n')
.map(line => {
return line
function removeStarAndComments(str) {
var text = str.split('\n')
.map(function (line) {
line = line
.replace(/'[^']+\*[^']*'/g, "''")
.replace(/"[^"]+\*[^"]*"/g, '""')
// .replace(/\/\*+\//, '')
.replace(/\/\S*\*+\S*\/[a-z]*/g, '')
// remove line comment
.replace(/^\/\/.*$/gm, '')
.replace(/(?:[^\\])\/\/.*$/gm, '')
return line
})
.join('\n');
// remove block comment
text = text
.replace(/^\/\*[\S\s]*?\*\//g, '')
.replace(/(?:[^\\])\/\*[\S\s]*?\*\//g, '')
console.log(text)
return text
}
export default class {

@@ -74,3 +83,3 @@ constructor(opt) {

var deps = [];
strip(rm_star(content))
removeStarAndComments(content)
.split('\n')

@@ -77,0 +86,0 @@ .filter(line => line.indexOf('require') > -1 || line.indexOf('from') > -1 || line.indexOf('import') > -1)

@@ -11,5 +11,5 @@ require('babel/register');

describe('should get deps', function () {
before(function() {
dep.clearCache();
});
before(function() {
dep.clearCache();
});

@@ -22,2 +22,12 @@ it('basic', function() {

it('complex deps', function () {
var data = deps(file('complex.js'));
assert.ok(data.length === 4);
})
it('comment deps', function () {
var data = deps(file('comment.js'));
assert.ok(data.length === 0);
})
it('require b', function () {

@@ -24,0 +34,0 @@ var data = deps(file('r-b.js'));

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