Socket
Socket
Sign inDemoInstall

6to5

Package Overview
Dependencies
85
Maintainers
1
Versions
257
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.6.0 to 3.6.1

31

lib/6to5/transformation/file.js

@@ -281,3 +281,3 @@ "use strict";

if (!id) {
id = this.dynamicImportIds[name] = this.generateUidIdentifier(name);
id = this.dynamicImportIds[name] = this.scope.generateUidIdentifier(name);

@@ -316,3 +316,3 @@ var specifiers = [t.importSpecifier(t.identifier("default"), id)];

ref._compact = true;
var uid = this.generateUidIdentifier(name);
var uid = this.scope.generateUidIdentifier(name);
this.scope.push({

@@ -448,28 +448,1 @@ key: name,

};
File.prototype.generateUid = function (name, scope) {
name = t.toIdentifier(name).replace(/^_+/, "");
scope = scope || this.scope;
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (scope.hasBinding(uid) || scope.hasGlobal(uid));
return uid;
};
File.prototype.generateUidIdentifier = function (name, scope) {
scope = scope || this.scope;
var id = t.identifier(this.generateUid(name, scope));
scope.getFunctionParent().registerBinding("uid", id);
return id;
};
File.prototype._generateUid = function (name, i) {
var id = name;
if (i > 1) id += i;
return "_" + id;
};

5

lib/6to5/transformation/helpers/build-react-transformer.js

@@ -49,2 +49,7 @@ "use strict";

var value = node.value || t.literal(true);
if (t.isLiteral(value) && isString(value.value)) {
value.value = value.value.replace(/\n\s+/g, " ");
}
return t.inherits(t.property("init", node.name, value), node);

@@ -51,0 +56,0 @@ }

@@ -146,3 +146,3 @@ "use strict";

} else {
var ref = this.topLevelThisReference = this.file.generateUidIdentifier("this");
var ref = this.topLevelThisReference = this.scope.generateUidIdentifier("this");
this.methodNode.value.body.body.unshift(t.variableDeclaration("var", [

@@ -149,0 +149,0 @@ t.variableDeclarator(this.topLevelThisReference, t.thisExpression())

@@ -12,4 +12,5 @@ "use strict";

function DefaultFormatter(file) {
this.file = file;
this.ids = object();
this.scope = file.scope;
this.file = file;
this.ids = object();

@@ -216,5 +217,2 @@ this.hasNonDefaultExports = false;

DefaultFormatter.prototype.exportSpecifier = function (specifier, node, nodes) {
var inherits = false;
if (node.specifiers.length === 1) inherits = node;
if (node.source) {

@@ -221,0 +219,0 @@ var ref = this.getExternalReference(node, nodes);

@@ -73,3 +73,3 @@ "use strict";

AMDFormatter.prototype._getExternalReference = function (node) {
return this.file.generateUidIdentifier(node.source.value);
return this.scope.generateUidIdentifier(node.source.value);
};

@@ -76,0 +76,0 @@

@@ -96,3 +96,3 @@ "use strict";

if (this.localImportOccurences[source] > 1) {
var uid = this.file.generateUidIdentifier(source);
var uid = this.scope.generateUidIdentifier(source);
nodes.push(t.variableDeclaration("var", [

@@ -99,0 +99,0 @@ t.variableDeclarator(uid, call)

@@ -15,3 +15,3 @@ "use strict";

function SystemFormatter(file) {
this.exportIdentifier = file.generateUidIdentifier("export");
this.exportIdentifier = file.scope.generateUidIdentifier("export");
this.noInteropRequireExport = true;

@@ -33,3 +33,3 @@ this.noInteropRequireImport = true;

SystemFormatter.prototype.buildExportsWildcard = function (objectIdentifier, node) {
var leftIdentifier = this.file.generateUidIdentifier("key");
var leftIdentifier = this.scope.generateUidIdentifier("key");
var valIdentifier = t.memberExpression(objectIdentifier, leftIdentifier, true);

@@ -36,0 +36,0 @@

@@ -38,3 +38,3 @@ "use strict";

* @param {Scope} scope
* @param {Boolean} closure
* @param {Boolean} isStatement
*/

@@ -103,4 +103,3 @@

if (!t.isIdentifier(superName)) {
var superRef = this.scope.generateUidBasedOnNode(superName, this.file);
superName = superRef;
superName = this.scope.generateUidBasedOnNode(superName, this.file);
}

@@ -212,3 +211,3 @@

/**
* Push a method to it's respective mutatorMap.
* Push a method to its respective mutatorMap.
*

@@ -215,0 +214,0 @@ * @param {Node} node MethodDefinition

@@ -13,2 +13,4 @@ "use strict";

if (t.isAssignmentExpression(node) || t.isUpdateExpression(node)) {
if (t.isMemberExpression(node.left || node.argument)) return;
var ids = t.getBindingIdentifiers(node);

@@ -15,0 +17,0 @@

@@ -21,3 +21,3 @@ "use strict";

// ensure that it's a block so we can take all it's statemetns
// ensure that it's a block so we can take all its statements
t.ensureBlock(node);

@@ -24,0 +24,0 @@

@@ -6,3 +6,4 @@ var t = require("../../../types");

exports.ExpressionStatement = function (node) {
// remove consequenceless expressions such as local variables and literals
// remove consequence-less expressions such as local variables and literals
// note: will remove directives
//

@@ -37,3 +38,3 @@ // var foo = true; foo; -> var foo = true;

if (t.isLiteral(test) && test.value) {
return alternate;
return consequent;
}

@@ -71,4 +72,3 @@

if (t.blockStatement(consequent) && !consequent.body.length &&
t.isBlockStatement(alternate) && alternate.body.length) {
if (t.blockStatement(consequent) && !consequent.body.length && t.isBlockStatement(alternate) && alternate.body.length) {
node.consequent = node.alternate;

@@ -75,0 +75,0 @@ node.alternate = null;

@@ -29,3 +29,3 @@ "use strict";

exports.BindFunctionExpression = function (node, parent, scope, file) {
exports.BindFunctionExpression = function (node, parent, scope) {
var buildCall = function (args) {

@@ -38,3 +38,3 @@ var param = scope.generateUidIdentifier("val");

var temp = scope.generateTemp(file, "args");
var temp = scope.generateTemp("args");

@@ -41,0 +41,0 @@ return t.sequenceExpression([

@@ -53,8 +53,7 @@ "use strict";

*
* @param {File} file
* @param {String} [name="temp"]
*/
Scope.prototype.generateTemp = function (file, name) {
var id = file.generateUidIdentifier(name || "temp", this);
Scope.prototype.generateTemp = function (name) {
var id = this.generateUidIdentifier(name || "temp");
this.push({

@@ -74,5 +73,31 @@ key: id.name,

Scope.prototype.generateUidIdentifier = function (name) {
return this.file.generateUidIdentifier(name, this);
var id = t.identifier(this.generateUid(name));
this.getFunctionParent().registerBinding("uid", id);
return id;
};
/**
* Description
*
* @param {String} name
*/
Scope.prototype.generateUid = function (name) {
name = t.toIdentifier(name).replace(/^_+/, "");
var uid;
var i = 0;
do {
uid = this._generateUid(name, i);
i++;
} while (this.hasBinding(uid) || this.hasGlobal(uid));
return uid;
};
Scope.prototype._generateUid = function (name, i) {
var id = name;
if (i > 1) id += i;
return "_" + id;
};
/*

@@ -116,3 +141,3 @@ * Description

return this.file.generateUidIdentifier(id, this);
return this.generateUidIdentifier(id);
};

@@ -147,3 +172,3 @@

if (local.kind === "let" || local.kind === "const") {
if (local.kind === "let" || local.kind === "const" || local.kind === "module") {
throw this.file.errorWithNode(id, messages.get("scopeDuplicateDeclaration", name), TypeError);

@@ -192,12 +217,24 @@ }

if (t.isCallExpression(target)) {
// todo: resolve this to a return type
if (t.isArrayExpression(target)) {
return t.genericTypeAnnotation(t.identifier("Array"));
}
if (t.isMemberExpression(target)) {
// todo: crawl this and find the correct type, bail on anything that we cannot possibly be 100% confident on
if (t.isObjectExpression(target)) {
return;
}
if (t.isLiteral(target)) {
return;
}
if (t.isCallExpression(target) && t.isIdentifier(target.callee)) {
var funcInfo = this.getBindingInfo(target.callee.name);
if (funcInfo) {
var funcNode = funcInfo.node;
return !funcInfo.reassigned && t.isFunction(funcNode) && node.returnType;
}
}
if (t.isIdentifier(target)) {
// todo
return;
}

@@ -225,3 +262,8 @@ };

Scope.prototype.getTypeAnnotation = function (key, id, node) {
Scope.prototype.getTypeAnnotation = function (name, id, node) {
var info = {
annotation: null,
inferred: false
};
var type;

@@ -234,2 +276,3 @@

if (!type) {
info.inferred = true;
type = this.inferType(node);

@@ -240,4 +283,6 @@ }

if (t.isTypeAnnotation(type)) type = type.typeAnnotation;
return type;
info.annotation = type;
}
return info;
};

@@ -295,3 +340,10 @@

var info = this.getBindingInfo(name);
if (info) info.reassigned = true;
if (info) {
info.reassigned = true;
if (info.typeAnnotationInferred) {
// destroy the inferred typeAnnotation
info.typeAnnotation = null;
}
}
}

@@ -310,8 +362,12 @@ };

var typeInfo = this.getTypeAnnotation(name, id, node);
this.bindings[name] = {
typeAnnotation: this.getTypeAnnotation(name, id, node),
reassigned: false,
identifier: id,
scope: this,
kind: kind
typeAnnotationInferred: typeInfo.inferred,
typeAnnotation: typeInfo.annotation,
reassigned: false,
identifier: id,
scope: this,
node: node,
kind: kind
};

@@ -318,0 +374,0 @@ }

@@ -25,2 +25,5 @@ {

"ImportSpecifier": ["ModuleSpecifier"],
"ExportSpecifier": ["ModuleSpecifier"],
"BlockStatement": ["Statement", "Scopable"],

@@ -27,0 +30,0 @@ "Program": ["Scopable"],

@@ -406,3 +406,3 @@ "use strict";

* @param {Object} node
* @param {String} key
* @param {String=} key
*/

@@ -422,3 +422,3 @@

*
* @param {String} match Dot delimetered string
* @param {String} match Dot-delimited string
* @param {Boolean} [allowPartial] Allow a partial match

@@ -595,2 +595,4 @@ * @returns {Function}

ids[id.name] = id;
} else if (t.isImportSpecifier(id)) {
search.push(id.name || id.id);
} else if (t.isExportDeclaration(id)) {

@@ -614,4 +616,2 @@ if (t.isDeclaration(node.declaration)) {

ImportBatchSpecifier: ["name"],
ImportSpecifier: ["name", "id"],
ExportSpecifier: ["name", "id"],
VariableDeclarator: ["id"],

@@ -618,0 +618,0 @@ FunctionDeclaration: ["id"],

@@ -91,2 +91,3 @@ "use strict";

if (t.isIdentifier(node) && has(nodes, node.name)) {
this.skip();
return nodes[node.name];

@@ -93,0 +94,0 @@ }

{
"name": "6to5",
"description": "Turn ES6 code into readable vanilla ES5 with source maps",
"version": "3.6.0",
"version": "3.6.1",
"author": "Sebastian McKenzie <sebmck@gmail.com>",

@@ -36,3 +36,3 @@ "homepage": "https://6to5.org/",

"dependencies": {
"acorn-6to5": "0.11.1-29",
"acorn-6to5": "0.11.1-30",
"ast-types": "~0.6.1",

@@ -62,3 +62,3 @@ "chalk": "^0.5.1",

"devDependencies": {
"6to5": "3.5.3",
"6to5": "3.6.0",
"browserify": "8.1.1",

@@ -65,0 +65,0 @@ "chai": "1.10.0",

@@ -1,1 +0,1 @@

(function(global){var to5Runtime=global.to5Runtime={};to5Runtime.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};to5Runtime.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};to5Runtime.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};to5Runtime.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};to5Runtime.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};to5Runtime.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};to5Runtime.interopRequire=function(obj){return obj&&obj.__esModule?obj.default:obj};to5Runtime.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};to5Runtime.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};to5Runtime.slicedToArray=function(arr,i){if(Array.isArray(arr)){return arr}else{var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}};to5Runtime.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};to5Runtime.hasOwn=Object.prototype.hasOwnProperty;to5Runtime.slice=Array.prototype.slice;to5Runtime.bind=Function.prototype.bind;to5Runtime.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};to5Runtime.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};to5Runtime.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};to5Runtime._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};to5Runtime._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};to5Runtime.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};to5Runtime.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};to5Runtime.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};to5Runtime.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};to5Runtime.temporalUndefined={};to5Runtime.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};to5Runtime.tailCall=function(){function Tail(func,args,context){this.func=func;this.args=args;this.context=context}Tail.prototype._isTailDescriptor=true;var isRunning=false;return function(func,args,context){var result=new Tail(func,args,context);if(!isRunning){isRunning=true;do{result=result.func.apply(result.context,result.args)}while(result instanceof Tail||result&&result._isTailDescriptor);isRunning=false}return result}}()})(typeof global==="undefined"?self:global);
(function(global){var to5Runtime=global.to5Runtime={};to5Runtime.inherits=function(subClass,superClass){if(typeof superClass!=="function"&&superClass!==null){throw new TypeError("Super expression must either be null or a function, not "+typeof superClass)}subClass.prototype=Object.create(superClass&&superClass.prototype,{constructor:{value:subClass,enumerable:false,writable:true,configurable:true}});if(superClass)subClass.__proto__=superClass};to5Runtime.defaults=function(obj,defaults){var keys=Object.getOwnPropertyNames(defaults);for(var i=0;i<keys.length;i++){var key=keys[i];var value=Object.getOwnPropertyDescriptor(defaults,key);if(value&&value.configurable&&obj[key]===undefined){Object.defineProperty(obj,key,value)}}return obj};to5Runtime.prototypeProperties=function(child,staticProps,instanceProps){if(staticProps)Object.defineProperties(child,staticProps);if(instanceProps)Object.defineProperties(child.prototype,instanceProps)};to5Runtime.applyConstructor=function(Constructor,args){var instance=Object.create(Constructor.prototype);var result=Constructor.apply(instance,args);return result!=null&&(typeof result=="object"||typeof result=="function")?result:instance};to5Runtime.taggedTemplateLiteral=function(strings,raw){return Object.freeze(Object.defineProperties(strings,{raw:{value:Object.freeze(raw)}}))};to5Runtime.taggedTemplateLiteralLoose=function(strings,raw){strings.raw=raw;return strings};to5Runtime.interopRequire=function(obj){return obj&&obj.__esModule?obj.default:obj};to5Runtime.toArray=function(arr){return Array.isArray(arr)?arr:Array.from(arr)};to5Runtime.toConsumableArray=function(arr){if(Array.isArray(arr)){for(var i=0,arr2=Array(arr.length);i<arr.length;i++)arr2[i]=arr[i];return arr2}else{return Array.from(arr)}};to5Runtime.slicedToArray=function(arr,i){if(!arr||!arr[Symbol.iterator]){throw new TypeError("Invalid attempt to destructure non-iterable instance")}else if(Array.isArray(arr)){return arr}else{var _arr=[];for(var _iterator=arr[Symbol.iterator](),_step;!(_step=_iterator.next()).done;){_arr.push(_step.value);if(i&&_arr.length===i)break}return _arr}};to5Runtime.objectWithoutProperties=function(obj,keys){var target={};for(var i in obj){if(keys.indexOf(i)>=0)continue;if(!Object.prototype.hasOwnProperty.call(obj,i))continue;target[i]=obj[i]}return target};to5Runtime.hasOwn=Object.prototype.hasOwnProperty;to5Runtime.slice=Array.prototype.slice;to5Runtime.bind=Function.prototype.bind;to5Runtime.defineProperty=function(obj,key,value){return Object.defineProperty(obj,key,{value:value,enumerable:true,configurable:true,writable:true})};to5Runtime.asyncToGenerator=function(fn){return function(){var gen=fn.apply(this,arguments);return new Promise(function(resolve,reject){var callNext=step.bind(null,"next");var callThrow=step.bind(null,"throw");function step(key,arg){try{var info=gen[key](arg);var value=info.value}catch(error){reject(error);return}if(info.done){resolve(value)}else{Promise.resolve(value).then(callNext,callThrow)}}callNext()})}};to5Runtime.interopRequireWildcard=function(obj){return obj&&obj.__esModule?obj:{"default":obj}};to5Runtime._typeof=function(obj){return obj&&obj.constructor===Symbol?"symbol":typeof obj};to5Runtime._extends=Object.assign||function(target){for(var i=1;i<arguments.length;i++){var source=arguments[i];for(var key in source){if(Object.prototype.hasOwnProperty.call(source,key)){target[key]=source[key]}}}return target};to5Runtime.get=function get(object,property,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent===null){return undefined}else{return get(parent,property,receiver)}}else if("value"in desc&&desc.writable){return desc.value}else{var getter=desc.get;if(getter===undefined){return undefined}return getter.call(receiver)}};to5Runtime.set=function set(object,property,value,receiver){var desc=Object.getOwnPropertyDescriptor(object,property);if(desc===undefined){var parent=Object.getPrototypeOf(object);if(parent!==null){return set(parent,property,value,receiver)}}else if("value"in desc&&desc.writable){return desc.value=value}else{var setter=desc.set;if(setter!==undefined){return setter.call(receiver,value)}}};to5Runtime.classCallCheck=function(instance,Constructor){if(!(instance instanceof Constructor)){throw new TypeError("Cannot call a class as a function")}};to5Runtime.objectDestructuringEmpty=function(obj){if(obj==null)throw new TypeError("Cannot destructure undefined")};to5Runtime.temporalUndefined={};to5Runtime.temporalAssertDefined=function(val,name,undef){if(val===undef){throw new ReferenceError(name+" is not defined - temporal dead zone")}return true};to5Runtime.tailCall=function(){function Tail(func,args,context){this.func=func;this.args=args;this.context=context}Tail.prototype._isTailDescriptor=true;var isRunning=false;return function(func,args,context){var result=new Tail(func,args,context);if(!isRunning){isRunning=true;do{result=result.func.apply(result.context,result.args)}while(result instanceof Tail||result&&result._isTailDescriptor);isRunning=false}return result}}()})(typeof global==="undefined"?self:global);

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc