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

jsdc

Package Overview
Dependencies
Maintainers
1
Versions
65
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

jsdc - npm Package Compare versions

Comparing version 0.4.6 to 0.4.7

2

package.json
{
"name": "jsdc",
"version": "0.4.6",
"version": "0.4.7",
"description": "compiler ecmascript6 to ecmascript5",

@@ -5,0 +5,0 @@ "maintainers": [

@@ -256,2 +256,11 @@ Javascript Downcast

```
在数组中则会自动展开,支持string预判断:
```js
var codeUnits = [..."this is a string"];
var codeUnits = [...a];
```
```js
var codeUnits = [].concat("this is a string".split(""));
var codeUnits = [].concat(Object.prototype.toString.call(a)=="[object String]"?a.split(""):a);
```

@@ -258,0 +267,0 @@ ### template模板

@@ -406,2 +406,3 @@ var homunculus = require('homunculus');

if(start) {
first.destruct = true;
!ret && this.jsdc.ignore(first, 'destruct2');

@@ -445,2 +446,11 @@ if(assignexpr.parent().name() == JsNode.ASSIGNEXPR) {

}
self.getArray(first.leaves()).forEach(function(leaf) {
if(leaf.name() == JsNode.TOKEN) {
return;
}
leaf = leaf.first();
if(leaf.name() == JsNode.ARRLTR) {
self.destructExpr(leaf, true);
}
});
}

@@ -642,2 +652,15 @@ else {

var self = this;
if(data === true) {
node.destruct = true;
self.getArray(node.leaves()).forEach(function(leaf) {
if(leaf.name() == JsNode.TOKEN) {
return;
}
leaf = leaf.first();
if(leaf.name() == JsNode.ARRLTR) {
self.destructExpr(leaf, true);
}
});
return;
}
switch(node.name()) {

@@ -644,0 +667,0 @@ case JsNode.ARRLTR:

@@ -308,2 +308,5 @@ var homunculus = require('homunculus');

break;
case JsNode.ARRLTR:
this.rest.arrltr(node, true);
break;
}

@@ -373,2 +376,5 @@ eventbus.emit(node.nid(), [node, true]);

break;
case JsNode.ARRLTR:
this.rest.arrltr(node);
break;
}

@@ -375,0 +381,0 @@ eventbus.emit(node.nid(), [node]);

@@ -12,2 +12,3 @@ var homunculus = require('homunculus');

this.hash2 = {};
this.hash3 = {};
}).methods({

@@ -71,2 +72,40 @@ param: function(fmparams) {

}
},
arrltr: function(node, start) {
if(node.destruct) {
return;
}
if(start) {
var last = node.last();
var spread = last.prev();
if(spread && spread.name() == JsNode.SPREAD) {
var token = spread.last().last().token();
this.hash3[node.nid()] = {
isStr: token.type() == Token.STRING,
value: token.content()
};
this.jsdc.ignore(spread, 'rest3', true);
var prev = spread.prev();
if(prev && prev.name() == JsNode.TOKEN && prev.token().content() == ',') {
this.jsdc.ignore(prev, 'rest4', true);
}
}
}
else if(this.hash3.hasOwnProperty(node.nid())) {
var o = this.hash3[node.nid()];
this.jsdc.appendBefore('.concat(');
if(o.isStr) {
this.jsdc.appendBefore(o.value);
this.jsdc.appendBefore('.split("")');
}
else {
this.jsdc.appendBefore('Object.prototype.toString.call(');
this.jsdc.appendBefore(o.value);
this.jsdc.appendBefore(')=="[object String]"?');
this.jsdc.appendBefore(o.value);
this.jsdc.appendBefore('.split(""):');
this.jsdc.appendBefore(o.value);
}
this.jsdc.appendBefore(')');
}
}

@@ -73,0 +112,0 @@ });

@@ -407,2 +407,3 @@ define(function(require, exports, module) {

if(start) {
first.destruct = true;
!ret && this.jsdc.ignore(first, 'destruct2');

@@ -446,2 +447,11 @@ if(assignexpr.parent().name() == JsNode.ASSIGNEXPR) {

}
self.getArray(first.leaves()).forEach(function(leaf) {
if(leaf.name() == JsNode.TOKEN) {
return;
}
leaf = leaf.first();
if(leaf.name() == JsNode.ARRLTR) {
self.destructExpr(leaf, true);
}
});
}

@@ -643,2 +653,15 @@ else {

var self = this;
if(data === true) {
node.destruct = true;
self.getArray(node.leaves()).forEach(function(leaf) {
if(leaf.name() == JsNode.TOKEN) {
return;
}
leaf = leaf.first();
if(leaf.name() == JsNode.ARRLTR) {
self.destructExpr(leaf, true);
}
});
return;
}
switch(node.name()) {

@@ -645,0 +668,0 @@ case JsNode.ARRLTR:

@@ -309,2 +309,5 @@ define(function(require, exports, module) {

break;
case JsNode.ARRLTR:
this.rest.arrltr(node, true);
break;
}

@@ -374,2 +377,5 @@ eventbus.emit(node.nid(), [node, true]);

break;
case JsNode.ARRLTR:
this.rest.arrltr(node);
break;
}

@@ -376,0 +382,0 @@ eventbus.emit(node.nid(), [node]);

@@ -13,2 +13,3 @@ define(function(require, exports, module) {

this.hash2 = {};
this.hash3 = {};
}).methods({

@@ -72,2 +73,40 @@ param: function(fmparams) {

}
},
arrltr: function(node, start) {
if(node.destruct) {
return;
}
if(start) {
var last = node.last();
var spread = last.prev();
if(spread && spread.name() == JsNode.SPREAD) {
var token = spread.last().last().token();
this.hash3[node.nid()] = {
isStr: token.type() == Token.STRING,
value: token.content()
};
this.jsdc.ignore(spread, 'rest3', true);
var prev = spread.prev();
if(prev && prev.name() == JsNode.TOKEN && prev.token().content() == ',') {
this.jsdc.ignore(prev, 'rest4', true);
}
}
}
else if(this.hash3.hasOwnProperty(node.nid())) {
var o = this.hash3[node.nid()];
this.jsdc.appendBefore('.concat(');
if(o.isStr) {
this.jsdc.appendBefore(o.value);
this.jsdc.appendBefore('.split("")');
}
else {
this.jsdc.appendBefore('Object.prototype.toString.call(');
this.jsdc.appendBefore(o.value);
this.jsdc.appendBefore(')=="[object String]"?');
this.jsdc.appendBefore(o.value);
this.jsdc.appendBefore('.split(""):');
this.jsdc.appendBefore(o.value);
}
this.jsdc.appendBefore(')');
}
}

@@ -74,0 +113,0 @@ });

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