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.3.3 to 0.3.4-1

4

package.json
{
"name": "jsdc",
"version": "0.3.3",
"version": "0.3.4-1",
"description": "transform ecmascript6 to ecmascript5",

@@ -50,3 +50,3 @@ "maintainers": [

"dependencies": {
"homunculus": "^0.2.7-3"
"homunculus": "^0.2.7-4"
},

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

@@ -123,5 +123,5 @@ # Javascript Downcast

```js
var a = function(){var __0__={
__1__: 1
};__0__['a'+'b']=__0__.__1__;delete __0__.__1__;return __0__}()
var a = function(){var _0_={
_1_: 1
};_0_['a'+'b']=_0_._1_;delete _0_._1_;return _0_}()
```

@@ -175,5 +175,5 @@ > 实现方法是先用个临时唯一变量替换掉表达式,最后再将它还原回来。

```js
var b;!function() {
!function() {
let a = 1;
b=function (){}
function b(){}
}();

@@ -219,2 +219,3 @@ ```

```
> 函数和`Generator`函数均默认块级作用域。

@@ -405,3 +406,3 @@ ### 默认参数值

```js
function A(){}!function(){var _=Object.create(B.prototype);_.constructor=A;A.prototype=_;}();
!function(){var _=Object.create(B.prototype);_.constructor=A;A.prototype=_;}();
function A(){B.call(this)}

@@ -439,5 +440,5 @@ Object.keys(B).forEach(function(k){A[k]=B[k]});

```js
var o = function(){function __0__(){}
__0__.prototype.method = function(){}
return __0__}()
var o = function(){function _0_(){}
_0_.prototype.method = function(){}
return _0_}()
```

@@ -483,12 +484,12 @@ > 由于表达式没有名字(也可以有),所以需要封装成立即执行的匿名函数并返回一个`class`声明。

```js
var a;!function(){var __0__=require("a");a=__0__.a}();
var a;!function(){var _0_=require("a");a=_0_.a}();
```
> 类似`__0__`变量是自动生成的,数字会自动累加,且不会和已有变量冲突。
> 类似`_0_`变量是自动生成的,数字会自动累加,且不会和已有变量冲突。
在冲突时会自动跳过:
```js
import __0__ from "a"
import _0_ from "a"
```
```js
var __0__;!function(){var __1__=require("a");__0__=__1__.a}();
var _0_;!function(){var _1_=require("a");_0_=_1_.a}();
```

@@ -500,3 +501,3 @@ `import`还可以指定多个id:

```js
var a;var b;!function(){var __0__=require("a");a=__0__.a;b=__0__.b;}();
var a;var b;!function(){var _0_=require("a");a=_0_.a;b=_0_.b;}();
```

@@ -508,3 +509,3 @@ `import`可以用`{}`来赋值,注意里面`as`声明变量名的方法:

```js
var a;var c;!function(){var __0__=require("a");a=__0__.a;c=__0__.b;}();
var a;var c;!function(){var _0_=require("a");a=_0_.a;c=_0_.b;}();
```

@@ -516,3 +517,3 @@ `export * from ""`会将模块的导出赋给module.exports:

```js
!function(){var __0__=require("a");Object.keys(__0__).forEach(function(k){module.exports[k]=temp[k];});}();
!function(){var _0_=require("a");Object.keys(_0_).forEach(function(k){module.exports[k]=temp[k];});}();
```

@@ -549,5 +550,5 @@ `export`一个`var`语句时会自动赋值同名变量:

```js
var a = function(){var k;var __0__=[];for(k in o){k=o[k];__0__.push(k)}return __0__}()
var a = function(){var k;var _0_=[];for(k in o){k=o[k];_0_.push(k)}return _0_}()
```
> 注意再次出现的临时变量`__0__`和上面提到的一致,不会冲突。
> 注意再次出现的临时变量`_0_`和上面提到的一致,不会冲突。

@@ -559,3 +560,3 @@ `if`语句可以替代`Array.filter`方法:

```js
var a = function(){var k;var __0__=[];for(k in o){k=o[k];if(k)__0__.push(k)}return __0__}()
var a = function(){var k;var _0_=[];for(k in o){k=o[k];if(k)_0_.push(k)}return _0_}()
```

@@ -567,3 +568,3 @@ 嵌套组合使用也是可以的:

```js
var a = function(){var a;var c;var __0__=[];for(a in b){a=b[a];for(c in a){c=a[c];if(c)__0__.push(c)}}return __0__}()
var a = function(){var a;var c;var _0_=[];for(a in b){a=b[a];for(c in a){c=a[c];if(c)_0_.push(c)}}return _0_}()
```

@@ -668,3 +669,3 @@

```js
var a=function(){return function(){return {next:__0__}};function __0__(){
var a=function(){return function(){return {next:_0_}};function _0_(){
arguments[0];return {value:1,done:false}

@@ -682,3 +683,3 @@ arguments[0];return {value:2,done:false}

```js
var a=function(){var __1__=0;return function(){return {next:__0__}};function __0__(){
var a=function(){var _1_=0;return function(){return {next:_0_}};function _0_(){
arguments[0];return {value:1,done:false}

@@ -696,4 +697,4 @@ arguments[0];return {value:2,done:false}

```js
var a=function(){var __1__=0;return function(){return {next:__0__}};function __0__(){
switch(__1__++){case 0:arguments[0];return {value:1,done:false}
var a=function(){var _1_=0;return function(){return {next:_0_}};function _0_(){
switch(_1_++){case 0:arguments[0];return {value:1,done:false}
case 1:arguments[0];return {value:1,done:false}}

@@ -711,4 +712,4 @@ }}();

```js
var a=function(){var __1__=0;return function(){return {next:__0__}};var a;function __0__(){
switch(__1__++){case 0:a = 1;
var a=function(){var _1_=0;return function(){return {next:_0_}};var a;function _0_(){
switch(_1_++){case 0:a = 1;
arguments[0];return {value:a++,done:false};

@@ -731,4 +732,4 @@ case 1:arguments[0];return {value:a++,done:false;}

```js
var a=function(){var __6__=0;return function(){return {next:__7__}};var a;function __7__(){
switch(__6__++){case 0:a = 1;
var a=function(){var _6_=0;return function(){return {next:_7_}};var a;function _7_(){
switch(_6_++){case 0:a = 1;
arguments[0];return {value:a++,done:false};

@@ -745,4 +746,4 @@ case 1:arguments[0];return {value:a++,done:true};default:;;return{done:true}}

```js
var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){
switch(__0__++){case 0:arguments[0];var __2__=b();if(!__2__.done)__0__--;return __2__;default:;return{done:true}}
var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){
switch(_0_++){case 0:arguments[0];var _2_=b();if(!_2_.done)_0_--;return _2_;default:;return{done:true}}
}}();

@@ -756,3 +757,3 @@ ```

```js
~function(){var __0__=0;return function (){return{next:__1__}};function __1__(){
~function(){var _0_=0;return function (){return{next:_1_}};function _1_(){
}}()

@@ -767,3 +768,3 @@ ```

```js
var a;!function(){var __0__= [1];a=__0__[0];}()
var a;!function(){var _0_= [1];a=_0_[0];}()
```

@@ -777,3 +778,3 @@ > 变量名会被前置,同时包裹执行一个匿名函数,将变量名赋值对应到正确的索引。

```js
var c;var b;var a;!function(){var __1__= [1];a=__1__[0];b=__1__[1];c=__1__[3]}()
var c;var b;var a;!function(){var _1_= [1];a=_1_[0];b=_1_[1];c=_1_[3]}()
```

@@ -785,3 +786,3 @@ 也可以是对象:

```js
var a;!function(){var __0__= {"a":1};a=__0__["a"]}()
var a;!function(){var _0_= {"a":1};a=_0_["a"]}()
```

@@ -795,10 +796,10 @@ > 注意变量名和键名要一致。

```js
var a;!function(){var __0__= {"a":1,"b":2};a=__0__["a"];c=__0__["b"]}()
var a;!function(){var _0_= {"a":1,"b":2};a=_0_["a"];c=_0_["b"]}()
```
它们甚至可以互相嵌套递归:
```js
var [a,{b},{c:[d]} = [1,{"b":2},{"c":[3]}
var [a,{b},{c:[d]}] = [1,{"b":2},{"c":[3]}]
```
```js
var d;var b;var a;!function(){var __0__= [1,{"b":2},{"c":[3]}];a=__0__[0];var __1__=__0__[1];b=__1__["b"];var __2__=__0__[2];var __3__=__2__["c"];d=__3__[0]}()
var d;var b;var a;!function(){var _0_= [1,{"b":2},{"c":[3]}];a=_0_[0];var _1_=_0_[1];b=_1_["b"];var _2_=_0_[2];var _3_=_2_["c"];d=_3_[0]}()
```

@@ -810,3 +811,3 @@ 解构还允许在未定义的情况下默认赋值:

```js
var a;!function(){var __0__= [];a=__0__[0];if(a===void 0)a=1}()
var a;!function(){var _0_= [];a=_0_[0];if(a===void 0)a=1}()
```

@@ -818,3 +819,10 @@ 表达式赋值也可以:

```js
(!function(){var __0__= {};a=__0__["a"];if(a===void 0)a=1}())
(!function(){var _0_= {};a=_0_["a"];if(a===void 0)a=1}())
```
数组解构最后允许`rest`运算符:
```js
var [a, ...b] = [1, 2, 3]
```
```js
var b;var a;!function(){var _0_= [1, 2, 3];a=_0_[0];b=_0_.slice(1)}()
```

@@ -83,2 +83,7 @@ var homunculus = require('homunculus');

if(start) {
//忽略前面的,改为;
var prev = node.prev();
if(prev.token().content() == ',') {
self.jsdc.append(';');
}
self.jsdc.append('!function(){var ');

@@ -118,2 +123,10 @@ var temp = self.jsdc.uid();

self.jsdc.appendBefore('}()');
//忽略后面的,改为;
var next = node.next();
if(next.token().content() == ',') {
next = next.next();
if(next.first().name() == JsNode.BINDID) {
self.jsdc.appendBefore(';var ');
}
}
}

@@ -120,0 +133,0 @@ break;

@@ -207,7 +207,3 @@ var homunculus = require('homunculus');

break;
case JsNode.FNDECL:
this.scope.prefn(node);
break;
case JsNode.GENDECL:
this.scope.pregen(node);
this.gen.parse(node, true);

@@ -371,8 +367,7 @@ break;

var temp;
while(temp = '__' + uid++ + '__') {
while(temp = '_' + uid++ + '_') {
if(!this.ids.hasOwnProperty(temp)) {
break;
return temp;
}
}
return temp;
},

@@ -379,0 +374,0 @@ define: function(d) {

@@ -25,4 +25,7 @@ var homunculus = require('homunculus');

if(!isToken) {
//每个{}作用域记录是否有lexdecl
if(node.name() == JsNode.LEXDECL) {
var name = node.name();
//每个{}作用域记录是否有lexdecl或fn或generator
if(name == JsNode.LEXDECL
|| name == JsNode.FNDECL
|| name == JsNode.GENDECL) {
var parent = self.closest(node);

@@ -34,3 +37,3 @@ //全局lexdecl没有作用域无需记录,fnbody的也无需记录

}
else if(node.name() == JsNode.BLOCKSTMT
else if(name == JsNode.BLOCKSTMT
&& !NOT_ABS_BLOCK.hasOwnProperty(node.parent().name())) {

@@ -70,40 +73,16 @@ self.hash[node.first().nid()] = true;

});
self.jsdc.ignore(varstmt.first().token());
if(vardecl.first().name() == JsNode.BINDID) {
self.jsdc.ignore(varstmt.first().token());
}
else {
//destruct需忽略前后可能的,再改为; var也需忽略
self.jsdc.ignore(vardecl.prev());
var next = vardecl.next();
if(next.token().content() == ',') {
self.jsdc.ignore(next);
}
}
}
});
},
prefn: function(fndecl) {
var parent = this.closest(fndecl);
if(parent
&& this.hash[parent.nid()]) {
//插入声明的变量到作用域开始,并改写为var形式
var i = this.index[this.index.length - 1];
this.history[i] = this.history[i] || {};
var his = this.history[i];
var id = fndecl.leaf(1).first().token().content();
if(!his.hasOwnProperty(id)) {
his[id] = true;
this.jsdc.insert('var ' + id + ';', i);
}
this.jsdc.ignore(fndecl.leaf(1));
this.jsdc.append(id + '=');
}
},
pregen: function(gendecl) {
var parent = this.closest(gendecl);
if(parent
&& this.hash[parent.nid()]) {
//插入声明的变量到作用域开始,并改写为var形式
var i = this.index[this.index.length - 1];
this.history[i] = this.history[i] || {};
var his = this.history[i];
var id = gendecl.leaf(2).first().token().content();
if(!his.hasOwnProperty(id)) {
his[id] = true;
this.jsdc.insert('var ' + id + ';', i);
}
this.jsdc.ignore(gendecl.leaf(2));
this.jsdc.append(id + '=');
}
},
join: function(node) {

@@ -110,0 +89,0 @@ var first = node.first();

@@ -187,3 +187,3 @@ var expect = require('expect.js');

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){a=function (){}}();');
expect(res).to.eql('!function(){function a(){}}();');
});

@@ -203,3 +203,3 @@ it('block with varstmt', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){a;a=function (){}}();');
expect(res).to.eql('var a;!function(){a;function a(){}}();');
});

@@ -246,2 +246,12 @@ it('var in method', function() {

});
it('function in block', function() {
var s = '{function a(){}}';
var res = Jsdc.parse(s);
expect(res).to.eql('!function(){function a(){}}();');
});
it('function in ifstmt', function() {
var s = 'if(true){function a(){}}';
var res = Jsdc.parse(s);
expect(res).to.eql('if(true){!function(){function a(){}}();}');
});
});

@@ -391,3 +401,3 @@ describe('init params', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){function __0__(){}return __0__}()');
expect(res).to.eql('!function(){function _0_(){}return _0_}()');
});

@@ -404,3 +414,3 @@ it('classexpr withname', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){function __0__(){}__0__.prototype.a = function(){}return __0__}()');
expect(res).to.eql('!function(){function _0_(){}_0_.prototype.a = function(){}return _0_}()');
});

@@ -411,3 +421,3 @@ it('classexpr extends', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){function __0__(){A.call(this)}!function(){var _=Object.create(A.prototype);_.constructor=__0__;__0__.prototype=_}();Object.keys(A).forEach(function(k){__0__[k]=A[k]});return __0__}()');
expect(res).to.eql('!function(){function _0_(){A.call(this)}!function(){var _=Object.create(A.prototype);_.constructor=_0_;_0_.prototype=_}();Object.keys(A).forEach(function(k){_0_[k]=A[k]});return _0_}()');
});

@@ -418,3 +428,3 @@ it('classexpr constructor', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){function __0__(){}return __0__}()');
expect(res).to.eql('!function(){function _0_(){}return _0_}()');
});

@@ -443,3 +453,3 @@ it('classexpr withname constructor', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){function __0__(){A.call(this)}!function(){var _=Object.create(A.prototype);_.constructor=__0__;__0__.prototype=_}();Object.keys(A).forEach(function(k){__0__[k]=A[k]});return __0__}()');
expect(res).to.eql('!function(){function _0_(){A.call(this)}!function(){var _=Object.create(A.prototype);_.constructor=_0_;_0_.prototype=_}();Object.keys(A).forEach(function(k){_0_[k]=A[k]});return _0_}()');
});

@@ -487,3 +497,3 @@ });

var res = Jsdc.parse(s);
expect(res).to.eql('define(function(require,exports,module){var a;!function(){var __0__=require("a");a=__0__.a;}();});');
expect(res).to.eql('define(function(require,exports,module){var a;!function(){var _0_=require("a");a=_0_.a;}();});');
});

@@ -494,3 +504,3 @@ it('import multi id', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('define(function(require,exports,module){var a;var b;!function(){var __0__=require("a");a=__0__.a;b=__0__.b;}();});');
expect(res).to.eql('define(function(require,exports,module){var a;var b;!function(){var _0_=require("a");a=_0_.a;b=_0_.b;}();});');
});

@@ -501,3 +511,3 @@ it('import {}', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('define(function(require,exports,module){var a;var b;!function(){var __0__=require("a");a=__0__.a;b=__0__.b;}();});');
expect(res).to.eql('define(function(require,exports,module){var a;var b;!function(){var _0_=require("a");a=_0_.a;b=_0_.b;}();});');
});

@@ -508,3 +518,3 @@ it('import {} as', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('define(function(require,exports,module){var a;var c;!function(){var __0__=require("a");a=__0__.a;c=__0__.b;}();});');
expect(res).to.eql('define(function(require,exports,module){var a;var c;!function(){var _0_=require("a");a=_0_.a;c=_0_.b;}();});');
});

@@ -515,3 +525,3 @@ it('export *', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('define(function(require,exports,module){!function(){var __0__=require("a");Object.keys(__0__).forEach(function(k){module.exports[k]=__0__[k];});}();});');
expect(res).to.eql('define(function(require,exports,module){!function(){var _0_=require("a");Object.keys(_0_).forEach(function(k){module.exports[k]=_0_[k];});}();});');
});

@@ -555,7 +565,7 @@ it('export var', function() {

it('avoid of id __\d__', function() {
var s = 'import {a as __0__} from "a"';
var s = 'import {a as _0_} from "a"';
Jsdc.reset();
Jsdc.define(false);
var res = Jsdc.parse(s);
expect(res).to.eql('var __0__;!function(){var __1__=require("a");__0__=__1__.a;}();');
expect(res).to.eql('var _0_;!function(){var _1_=require("a");_0_=_1_.a;}();');
});

@@ -567,3 +577,3 @@ it('set no define', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;var c;!function(){var __0__=require("a");a=__0__.a;c=__0__.b;}();');
expect(res).to.eql('var a;var c;!function(){var _0_=require("a");a=_0_.a;c=_0_.b;}();');
});

@@ -583,3 +593,3 @@ it('insert define before blank but not comment', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var k;var __0__=[];for(k in o){k=o[k];__0__.push(k)}return __0__}()');
expect(res).to.eql('var a = function(){var k;var _0_=[];for(k in o){k=o[k];_0_.push(k)}return _0_}()');
});

@@ -590,3 +600,3 @@ it('with cmphif', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var k;var __0__=[];for(k in o){k=o[k];if(k)__0__.push(k)}return __0__}()');
expect(res).to.eql('var a = function(){var k;var _0_=[];for(k in o){k=o[k];if(k)_0_.push(k)}return _0_}()');
});

@@ -597,3 +607,3 @@ it('multi cmphfor', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var a;var c;var __0__=[];for(a in b){a=b[a];for(c in a){c=a[c];__0__.push(c)}}return __0__}()');
expect(res).to.eql('var a = function(){var a;var c;var _0_=[];for(a in b){a=b[a];for(c in a){c=a[c];_0_.push(c)}}return _0_}()');
});

@@ -604,3 +614,3 @@ it('multi cmphfor with cmphif', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var a;var c;var __0__=[];for(a in b){a=b[a];for(c in a){c=a[c];if(c)__0__.push(c)}}return __0__}()');
expect(res).to.eql('var a = function(){var a;var c;var _0_=[];for(a in b){a=b[a];for(c in a){c=a[c];if(c)_0_.push(c)}}return _0_}()');
});

@@ -611,3 +621,3 @@ it('multi variable', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var k;var __0__=[];for(k in o){k=o[k];__0__.push(k)}return __0__}(), b');
expect(res).to.eql('var a = function(){var k;var _0_=[];for(k in o){k=o[k];_0_.push(k)}return _0_}(), b');
});

@@ -646,3 +656,3 @@ });

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:;return{done:true}}}}();');
});

@@ -653,3 +663,3 @@ it('normal', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:arguments[0];return{value:1,done:true};default:;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:arguments[0];return{value:1,done:true};default:;return{done:true}}}}();');
});

@@ -660,3 +670,3 @@ it('multi yield', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:arguments[0];return{value:1,done:false};case 1:arguments[0];return{value:2,done:true};default:;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:arguments[0];return{value:1,done:false};case 1:arguments[0];return{value:2,done:true};default:;return{done:true}}}}();');
});

@@ -667,3 +677,3 @@ it('with var state', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};var a;function __1__(){switch(__0__++){case 0:a = 1;arguments[0];return{value:a++,done:false};case 1:arguments[0];return{value:a++,done:true};default:;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};var a;function _1_(){switch(_0_++){case 0:a = 1;arguments[0];return{value:a++,done:false};case 1:arguments[0];return{value:a++,done:true};default:;return{done:true}}}}();');
});

@@ -674,3 +684,3 @@ it('scope in genaretor', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};var a;function __1__(){switch(__0__++){case 0:!function(){a}();;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};var a;function _1_(){switch(_0_++){case 0:!function(){a}();;return{done:true}}}}();');
});

@@ -681,3 +691,3 @@ it('let scope', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:!function(){var a}();;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:!function(){var a}();;return{done:true}}}}();');
});

@@ -688,3 +698,3 @@ it('ignore fndecl', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:function a(){};return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:function a(){};return{done:true}}}}();');
});

@@ -695,3 +705,3 @@ it('in block', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:;return{done:true}}}}();}();');
expect(res).to.eql('!function(){var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:;return{done:true}}}}();}();');
});

@@ -702,3 +712,3 @@ it('yield a generator', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a=function(){var __0__=0;return function(){return{next:__1__}};function __1__(){switch(__0__++){case 0:arguments[0];var __2__=b();if(!__2__.done)__0__--;return __2__;default:;return{done:true}}}}();');
expect(res).to.eql('var a=function(){var _0_=0;return function(){return{next:_1_}};function _1_(){switch(_0_++){case 0:arguments[0];var _2_=b();if(!_2_.done)_0_--;return _2_;default:;return{done:true}}}}();');
});

@@ -709,3 +719,3 @@ it('generator expr', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('~function(){var __0__=0;return function(){return{next:__1__}};function __1__(){}}()');
expect(res).to.eql('~function(){var _0_=0;return function(){return{next:_1_}};function _1_(){}}()');
});

@@ -716,3 +726,3 @@ it('generator expr with name', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('~function(){var __0__=0;return function(){return{next:__1__}};function __1__(){}}()');
expect(res).to.eql('~function(){var _0_=0;return function(){return{next:_1_}};function _1_(){}}()');
});

@@ -725,3 +735,3 @@ });

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;a=__0__[0]}()');
expect(res).to.eql('var a;!function(){var _0_= o;a=_0_[0]}()');
});

@@ -732,3 +742,3 @@ it('multi in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];b=__0__[1]}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];b=_0_[1]}()');
});

@@ -739,3 +749,3 @@ it('comma placeholder in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];b=__0__[2]}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];b=_0_[2]}()');
});

@@ -746,3 +756,3 @@ it('multi var in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;b=__0__[0];a=__0__[0]}()');
expect(res).to.eql('var a;!function(){var _0_= o;b=_0_[0];a=_0_[0]}()');
});

@@ -753,3 +763,3 @@ it('single in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;a=__0__["a"]}()');
expect(res).to.eql('var a;!function(){var _0_= o;a=_0_["a"]}()');
});

@@ -760,3 +770,3 @@ it('multi in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__["a"];b=__0__["b"]}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_["a"];b=_0_["b"]}()');
});

@@ -767,3 +777,3 @@ it('alias in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;a=__0__["a"];c=__0__["b"]}()');
expect(res).to.eql('var a;!function(){var _0_= o;a=_0_["a"];c=_0_["b"]}()');
});

@@ -774,3 +784,3 @@ it('multi var in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;b=__0__["b"];a=__0__["a"]}()');
expect(res).to.eql('var a;!function(){var _0_= o;b=_0_["b"];a=_0_["a"]}()');
});

@@ -781,3 +791,3 @@ it('array in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0]}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0]}()');
});

@@ -788,3 +798,3 @@ it('array in array 2', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var c;var b;var a;!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0];var __2__=__1__[1];c=__2__[0]}()');
expect(res).to.eql('var c;var b;var a;!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0];var _2_=_1_[1];c=_2_[0]}()');
});

@@ -795,3 +805,3 @@ it('object in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__["b"]}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_["b"]}()');
});

@@ -802,3 +812,3 @@ it('array in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var c;var a;!function(){var __0__= o;a=__0__["a"];var __1__=__0__["b"];c=__1__[0]}()');
expect(res).to.eql('var c;var a;!function(){var _0_= o;a=_0_["a"];var _1_=_0_["b"];c=_1_[0]}()');
});

@@ -809,3 +819,3 @@ it('object in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var c;var a;!function(){var __0__= o;a=__0__["a"];var __1__=__0__["b"];c=__1__["c"]}()');
expect(res).to.eql('var c;var a;!function(){var _0_= o;a=_0_["a"];var _1_=_0_["b"];c=_1_["c"]}()');
});

@@ -816,3 +826,3 @@ it('object in object 2', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var d;var a;!function(){var __0__= o;a=__0__["a"];var __1__=__0__["b"];var __2__=__1__["c"];d=__2__["d"]}()');
expect(res).to.eql('var d;var a;!function(){var _0_= o;a=_0_["a"];var _1_=_0_["b"];var _2_=_1_["c"];d=_2_["d"]}()');
});

@@ -823,3 +833,3 @@ it('object in object 3', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;a=__0__["a"];var __1__=__0__["b"];d=__1__["c"]}()');
expect(res).to.eql('var a;!function(){var _0_= o;a=_0_["a"];var _1_=_0_["b"];d=_1_["c"]}()');
});

@@ -830,3 +840,3 @@ it('assingexpr single in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0]}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0]}()');
});

@@ -837,3 +847,3 @@ it('assingexpr multi in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];b=__0__[1]}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];b=_0_[1]}()');
});

@@ -844,3 +854,3 @@ it('multi assingexpr in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;b=__0__[0];a=__0__[0]}()');
expect(res).to.eql('!function(){var _0_= o;b=_0_[0];a=_0_[0]}()');
});

@@ -851,3 +861,3 @@ it('multi assingexpr multi in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;c=__0__[0];d=__0__[1];a=__0__[0];b=__0__[1]}()');
expect(res).to.eql('!function(){var _0_= o;c=_0_[0];d=_0_[1];a=_0_[0];b=_0_[1]}()');
});

@@ -858,3 +868,3 @@ it('assingexpr comma placeholder in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];b=__0__[2]}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];b=_0_[2]}()');
});

@@ -865,3 +875,3 @@ it('assingexpr single in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__["a"]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_["a"]}())');
});

@@ -872,3 +882,3 @@ it('assingexpr multi in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__["a"];b=__0__["b"]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_["a"];b=_0_["b"]}())');
});

@@ -879,3 +889,3 @@ it('multi assingexpr in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;b=__0__["b"];a=__0__["a"]}())');
expect(res).to.eql('(!function(){var _0_= o;b=_0_["b"];a=_0_["a"]}())');
});

@@ -886,3 +896,3 @@ it('multi assingexpr multi in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;c=__0__["c"];d=__0__["d"];a=__0__["a"];b=__0__["b"]}())');
expect(res).to.eql('(!function(){var _0_= o;c=_0_["c"];d=_0_["d"];a=_0_["a"];b=_0_["b"]}())');
});

@@ -893,3 +903,3 @@ it('assingexpr alias in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__["a"];c=__0__["b"]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_["a"];c=_0_["b"]}())');
});

@@ -900,3 +910,3 @@ it('assingexpr array in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0]}())');
});

@@ -907,3 +917,3 @@ it('assingexpr object in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__["b"]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_["b"]}())');
});

@@ -914,3 +924,3 @@ it('assingexpr array in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__["a"];var __1__=__0__["b"];c=__1__[0]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_["a"];var _1_=_0_["b"];c=_1_[0]}())');
});

@@ -921,3 +931,3 @@ it('assingexpr object in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;a=__0__["a"];var __1__=__0__["b"];c=__1__["c"]}())');
expect(res).to.eql('(!function(){var _0_= o;a=_0_["a"];var _1_=_0_["b"];c=_1_["c"]}())');
});

@@ -928,3 +938,3 @@ it('init array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a;!function(){var __0__= o;a=__0__[0];if(a===void 0)a=1}()');
expect(res).to.eql('var a;!function(){var _0_= o;a=_0_[0];if(a===void 0)a=1}()');
});

@@ -935,3 +945,3 @@ it('init object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var x;!function(){var __0__= o;x=__0__["x"];if(x===void 0)x=1}()');
expect(res).to.eql('var x;!function(){var _0_= o;x=_0_["x"];if(x===void 0)x=1}()');
});

@@ -942,3 +952,3 @@ it('init array in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0];if(b===void 0)b=1}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0];if(b===void 0)b=1}()');
});

@@ -949,3 +959,3 @@ it('init object in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__["b"];if(b===void 0)b=1}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_["b"];if(b===void 0)b=1}()');
});

@@ -956,3 +966,3 @@ it('init array in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var z;var x;!function(){var __0__= o;x=__0__["x"];var __1__=__0__["y"];z=__1__[0];if(z===void 0)z=1}()');
expect(res).to.eql('var z;var x;!function(){var _0_= o;x=_0_["x"];var _1_=_0_["y"];z=_1_[0];if(z===void 0)z=1}()');
});

@@ -963,3 +973,3 @@ it('init object in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var z;var x;!function(){var __0__= o;x=__0__["x"];var __1__=__0__["y"];z=__1__["z"];if(z===void 0)z=1}()');
expect(res).to.eql('var z;var x;!function(){var _0_= o;x=_0_["x"];var _1_=_0_["y"];z=_1_["z"];if(z===void 0)z=1}()');
});

@@ -970,3 +980,3 @@ it('assingexpr init array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];if(a===void 0)a=1}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];if(a===void 0)a=1}()');
});

@@ -977,3 +987,3 @@ it('assingexpr init object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;x=__0__["x"];if(x===void 0)x=1}())');
expect(res).to.eql('(!function(){var _0_= o;x=_0_["x"];if(x===void 0)x=1}())');
});

@@ -984,3 +994,3 @@ it('assingexpr init array in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0];if(b===void 0)b=1}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0];if(b===void 0)b=1}()');
});

@@ -991,3 +1001,3 @@ it('assingexpr init object in array', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__["b"];if(b===void 0)b=1}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_["b"];if(b===void 0)b=1}()');
});

@@ -998,3 +1008,3 @@ it('assingexpr init array in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;x=__0__["x"];var __1__=__0__["y"];z=__1__[0];if(z===void 0)z=1}())');
expect(res).to.eql('(!function(){var _0_= o;x=_0_["x"];var _1_=_0_["y"];z=_1_[0];if(z===void 0)z=1}())');
});

@@ -1005,3 +1015,3 @@ it('assingexpr init object in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;x=__0__["x"];var __1__=__0__["y"];z=__1__["z"];if(z===void 0)z=1}())');
expect(res).to.eql('(!function(){var _0_= o;x=_0_["x"];var _1_=_0_["y"];z=_1_["z"];if(z===void 0)z=1}())');
});

@@ -1012,3 +1022,3 @@ it('assingexpr init object in object in object', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('(!function(){var __0__= o;x=__0__["x"];var __1__=__0__["y"];var __2__=__1__["m"];n=__2__["n"]p=__1__["o"]}())');
expect(res).to.eql('(!function(){var _0_= o;x=_0_["x"];var _1_=_0_["y"];var _2_=_1_["m"];n=_2_["n"]p=_1_["o"]}())');
});

@@ -1019,3 +1029,3 @@ it('varstmt arr destruct first start with id', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var __0__= e = o;c=__0__[0];b=__0__[0];return __0__}()');
expect(res).to.eql('var a = function(){var _0_= e = o;c=_0_[0];b=_0_[0];return _0_}()');
});

@@ -1026,3 +1036,3 @@ it('varstmt obj destruct first start with id', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var a = function(){var __0__= e = o;c=__0__["c"];b=__0__["b"];return __0__}()');
expect(res).to.eql('var a = function(){var _0_= e = o;c=_0_["c"];b=_0_["b"];return _0_}()');
});

@@ -1033,3 +1043,3 @@ it('array var rest', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var __0__= o;a=__0__[0];b=__0__.slice(1)}()');
expect(res).to.eql('var b;var a;!function(){var _0_= o;a=_0_[0];b=_0_.slice(1)}()');
});

@@ -1040,3 +1050,3 @@ it('array in array var rest', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var c;var b;var a;!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0];c=__1__.slice(1)}()');
expect(res).to.eql('var c;var b;var a;!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0];c=_1_.slice(1)}()');
});

@@ -1047,3 +1057,3 @@ it('array expr spread', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];b=__0__.slice(1)}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];b=_0_.slice(1)}()');
});

@@ -1054,3 +1064,3 @@ it('array in array expr spread', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0];c=__1__.slice(1)}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0];c=_1_.slice(1)}()');
});

@@ -1061,4 +1071,28 @@ it('array in array in array expr spread', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('!function(){var __0__= o;a=__0__[0];var __1__=__0__[1];b=__1__[0];var __2__=__1__[1];c=__2__.slice(0)}()');
expect(res).to.eql('!function(){var _0_= o;a=_0_[0];var _1_=_0_[1];b=_1_[0];var _2_=_1_[1];c=_2_.slice(0)}()');
});
it('var id,destruct', function() {
var s = 'var a,[b]=1';
Jsdc.reset();
var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var _0_=1;b=_0_[0]}()');
});
it('var id,destruct,id', function() {
var s = 'var a,[b]=[1],c';
Jsdc.reset();
var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var _0_=[1];b=_0_[0]}();var c');
});
it('var id,destruct,destruct', function() {
var s = 'var a,[b]=[1],[c]=[2]';
Jsdc.reset();
var res = Jsdc.parse(s);
expect(res).to.eql('var c;var b;var a;!function(){var _0_=[1];b=_0_[0]}();!function(){var _1_=[2];c=_1_[0]}()');
});
it('var destruct,destruct,id', function() {
var s = 'var [a]=[0],[b]=[1],c';
Jsdc.reset();
var res = Jsdc.parse(s);
expect(res).to.eql('var b;var a;!function(){var _0_=[0];a=_0_[0]}();!function(){var _1_=[1];b=_1_[0]}();var c');
});
});

@@ -1117,5 +1151,5 @@ describe('Unicode string', function() {

var res = Jsdc.parse(s);
expect(res).to.eql('var o = function(){var __0__={__1__:1};__0__[a]=__0__.__1__;delete __0__.__1__;return __0__}()');
expect(res).to.eql('var o = function(){var _0_={_1_:1};_0_[a]=_0_._1_;delete _0_._1_;return _0_}()');
});
});
});

@@ -84,2 +84,7 @@ define(function(require, exports, module) {

if(start) {
//忽略前面的,改为;
var prev = node.prev();
if(prev.token().content() == ',') {
self.jsdc.append(';');
}
self.jsdc.append('!function(){var ');

@@ -119,2 +124,10 @@ var temp = self.jsdc.uid();

self.jsdc.appendBefore('}()');
//忽略后面的,改为;
var next = node.next();
if(next.token().content() == ',') {
next = next.next();
if(next.first().name() == JsNode.BINDID) {
self.jsdc.appendBefore(';var ');
}
}
}

@@ -121,0 +134,0 @@ break;

@@ -208,7 +208,3 @@ define(function(require, exports, module) {

break;
case JsNode.FNDECL:
this.scope.prefn(node);
break;
case JsNode.GENDECL:
this.scope.pregen(node);
this.gen.parse(node, true);

@@ -372,8 +368,7 @@ break;

var temp;
while(temp = '__' + uid++ + '__') {
while(temp = '_' + uid++ + '_') {
if(!this.ids.hasOwnProperty(temp)) {
break;
return temp;
}
}
return temp;
},

@@ -380,0 +375,0 @@ define: function(d) {

@@ -26,4 +26,7 @@ define(function(require, exports, module) {

if(!isToken) {
//每个{}作用域记录是否有lexdecl
if(node.name() == JsNode.LEXDECL) {
var name = node.name();
//每个{}作用域记录是否有lexdecl或fn或generator
if(name == JsNode.LEXDECL
|| name == JsNode.FNDECL
|| name == JsNode.GENDECL) {
var parent = self.closest(node);

@@ -35,3 +38,3 @@ //全局lexdecl没有作用域无需记录,fnbody的也无需记录

}
else if(node.name() == JsNode.BLOCKSTMT
else if(name == JsNode.BLOCKSTMT
&& !NOT_ABS_BLOCK.hasOwnProperty(node.parent().name())) {

@@ -71,40 +74,16 @@ self.hash[node.first().nid()] = true;

});
self.jsdc.ignore(varstmt.first().token());
if(vardecl.first().name() == JsNode.BINDID) {
self.jsdc.ignore(varstmt.first().token());
}
else {
//destruct需忽略前后可能的,再改为; var也需忽略
self.jsdc.ignore(vardecl.prev());
var next = vardecl.next();
if(next.token().content() == ',') {
self.jsdc.ignore(next);
}
}
}
});
},
prefn: function(fndecl) {
var parent = this.closest(fndecl);
if(parent
&& this.hash[parent.nid()]) {
//插入声明的变量到作用域开始,并改写为var形式
var i = this.index[this.index.length - 1];
this.history[i] = this.history[i] || {};
var his = this.history[i];
var id = fndecl.leaf(1).first().token().content();
if(!his.hasOwnProperty(id)) {
his[id] = true;
this.jsdc.insert('var ' + id + ';', i);
}
this.jsdc.ignore(fndecl.leaf(1));
this.jsdc.append(id + '=');
}
},
pregen: function(gendecl) {
var parent = this.closest(gendecl);
if(parent
&& this.hash[parent.nid()]) {
//插入声明的变量到作用域开始,并改写为var形式
var i = this.index[this.index.length - 1];
this.history[i] = this.history[i] || {};
var his = this.history[i];
var id = gendecl.leaf(2).first().token().content();
if(!his.hasOwnProperty(id)) {
his[id] = true;
this.jsdc.insert('var ' + id + ';', i);
}
this.jsdc.ignore(gendecl.leaf(2));
this.jsdc.append(id + '=');
}
},
join: function(node) {

@@ -111,0 +90,0 @@ var first = node.first();

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