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

ascjs

Package Overview
Dependencies
Maintainers
1
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ascjs - npm Package Compare versions

Comparing version 0.1.9 to 1.0.0

82

index.js

@@ -1,2 +0,8 @@

const cherow = require('cherow');
const esprima = require('esprima');
const defaultOptions = {
sourceType: 'module',
jsx: true,
range: true,
tolerant: true
};

@@ -7,2 +13,9 @@ const babelified = `Object.defineProperty(exports, '__esModule', {value: true}).default`;

const slice = (code, info) => code.slice(info.range[0], info.range[1]);
const chunk = (info, esm, cjs) => ({
start: info.range[0],
end: info.range[1],
esm, cjs
});
const replace = {

@@ -12,4 +25,4 @@

const source = item.source;
const name = code.slice(source.start, source.end);
const esm = code.slice(item.start, item.end);
const name = slice(code, source);
const esm = slice(code, item);
const SEPS = /\{(\s+)/.test(esm) ? RegExp.$1 : '';

@@ -52,8 +65,3 @@ const SEPE = /(\s+)\}/.test(esm) ? RegExp.$1 : '';

}
return {
start: item.start,
end: item.end,
esm,
cjs: imported.join('\n')
};
return chunk(item, esm, imported.join('\n'));
},

@@ -63,11 +71,7 @@

const source = item.source;
const esm = code.slice(item.start, item.end);
const esm = slice(code, item);
const cjs = `(m => Object.keys(m).map(k => k !== 'default' && (exports[k] = m[k])))\n(require(${
code.slice(source.start, source.end
)}));`;
return {
start: item.start,
end: item.end,
esm, cjs
};
slice(code, source)
}));`;
return chunk(item, esm, cjs);
},

@@ -77,3 +81,3 @@

const declaration = item.declaration;
const esm = code.slice(item.start, item.end);
const esm = slice(code, item);
let cjs;

@@ -93,7 +97,3 @@ switch (declaration.type) {

}
return {
start: item.start,
end: item.end,
esm, cjs
};
return chunk(item, esm, cjs);
},

@@ -104,3 +104,3 @@

const source = item.source;
const esm = code.slice(item.start, item.end);
const esm = slice(code, item);
const EOL = /;$/.test(esm) ? ';\n' : '\n';

@@ -122,22 +122,25 @@ let cjs = source ? '(m => {\n' : '';

if (source) cjs += `})(require(${
code.slice(source.start, source.end)
slice(code, source)
}));\n`;
return {
start: item.start,
end: item.end,
esm,
cjs: cjs.trim()
};
return chunk(item, esm, cjs.trim());
}
};
const parse = code => {
const parse = (code, options) => {
const out = [];
const chunks = [];
code = code.toString();
cherow.parseModule(code, parse.options).body.forEach(item => {
if (replace.hasOwnProperty(item.type)) {
chunks.push(replace[item.type](code, item));
esprima.parse(
code,
Object.assign(
{},
defaultOptions,
options
),
item => {
if (replace.hasOwnProperty(item.type)) {
chunks.push(replace[item.type](code, item));
}
}
});
);
const length = chunks.length;

@@ -156,9 +159,2 @@ let c = 0;

parse.options = {
jsx: true,
next: true,
ranges: true,
v8: true
};
module.exports = parse;
{
"name": "ascjs",
"version": "0.1.9",
"version": "1.0.0",
"description": "ES2015 to CommonJS import/export transformer",

@@ -30,3 +30,3 @@ "bin": "bin.js",

"dependencies": {
"cherow": "0.9.9"
"esprima": "^4.0.0"
},

@@ -33,0 +33,0 @@ "devDependencies": {

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