Socket
Socket
Sign inDemoInstall

buble

Package Overview
Dependencies
11
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.6.6 to 0.6.7

6

CHANGELOG.md
# buble changelog
## 0.6.7
* Support `static get` and `set` in classes ([#34](https://gitlab.com/Rich-Harris/buble/issues/34))
* Support spread operator in expression method call ([!14](https://gitlab.com/Rich-Harris/buble/merge_requests/14))
* Fix `for-of` loops with no space after opening paren ([#35](https://gitlab.com/Rich-Harris/buble/issues/35))
## 0.6.6

@@ -4,0 +10,0 @@

2

package.json
{
"name": "buble",
"version": "0.6.6",
"version": "0.6.7",
"description": "The blazing fast, batteries-included ES2015 compiler",

@@ -5,0 +5,0 @@ "main": "dist/buble.umd.js",

@@ -9,4 +9,2 @@ import Node from '../Node.js';

if ( lastArgument && lastArgument.type === 'SpreadElement' ) {
// TODO expression callee (`(a || b)(...values)`)
let context;

@@ -18,3 +16,7 @@

} else {
throw new CompileError( lastArgument, 'Calling members of expressions with a spread operator is not currently supported' );
const statement = this.callee.object;
const i0 = statement.getIndentation();
context = this.findScope( true ).createIdentifier( 'ref' );
code.insert( statement.start, `var ${context} = ` );
code.insert( statement.end, `;\n${i0}${context}` );
}

@@ -21,0 +23,0 @@ } else {

@@ -61,4 +61,6 @@ import Node from '../Node.js';

let gettersAndSetters = [];
let accessors;
let prototypeGettersAndSetters = [];
let staticGettersAndSetters = [];
let prototypeAccessors;
let staticAccessors;

@@ -71,18 +73,26 @@ this.body.forEach( method => {

const isAccessor = method.kind === 'get' || method.kind === 'set';
if ( method.static ) code.remove( method.start, method.start + 7 );
const isAccessor = method.kind !== 'method';
let lhs;
if ( isAccessor ) {
code.remove( method.start, method.key.end );
if ( !~gettersAndSetters.indexOf( method.key.name ) ) gettersAndSetters.push( method.key.name );
if ( !accessors ) accessors = scope.createIdentifier( 'accessors' );
}
if ( method.static ) {
if ( !~staticGettersAndSetters.indexOf( method.key.name ) ) staticGettersAndSetters.push( method.key.name );
if ( !staticAccessors ) staticAccessors = scope.createIdentifier( 'staticAccessors' );
if ( method.static ) code.remove( method.start, method.start + 7 );
lhs = `${staticAccessors}.${method.key.name}.${method.kind}`;
} else {
if ( !~prototypeGettersAndSetters.indexOf( method.key.name ) ) prototypeGettersAndSetters.push( method.key.name );
if ( !prototypeAccessors ) prototypeAccessors = scope.createIdentifier( 'prototypeAccessors' );
const lhs = method.static ?
`${name}.${method.key.name}` :
method.kind === 'method' ?
`${name}.prototype.${method.key.name}` :
`${accessors}.${method.key.name}.${method.kind}`;
lhs = `${prototypeAccessors}.${method.key.name}.${method.kind}`;
}
} else {
lhs = method.static ?
`${name}.${method.key.name}` :
`${name}.prototype.${method.key.name}`;
}

@@ -100,16 +110,23 @@ code.insert( method.start, `${lhs} = function` + ( method.value.generator ? '*' : '' ) + ( isAccessor ? '' : ' ' ) );

if ( gettersAndSetters.length ) {
const intro = `var ${accessors} = { ${
gettersAndSetters.map( name => `${name}: {}` ).join( ',' )
} };`;
if ( prototypeGettersAndSetters.length || staticGettersAndSetters.length ) {
let intro = [];
let outro = [];
const outro = `Object.defineProperties( ${name}.prototype, ${accessors} );`;
if ( prototypeGettersAndSetters.length ) {
intro.push( `var ${prototypeAccessors} = { ${prototypeGettersAndSetters.map( name => `${name}: {}` ).join( ',' )} };` );
outro.push( `Object.defineProperties( ${name}.prototype, ${prototypeAccessors} );` );
}
if ( staticGettersAndSetters.length ) {
intro.push( `var ${staticAccessors} = { ${staticGettersAndSetters.map( name => `${name}: {}` ).join( ',' )} };` );
outro.push( `Object.defineProperties( ${name}, ${staticAccessors} );` );
}
if ( constructor ) {
code.insert( constructor.end, `\n\n${indentation}${intro}` );
code.insert( constructor.end, `\n\n${indentation}${intro.join( `\n${indentation}` )}` );
} else {
code.insert( this.start, `${intro}\n\n${indentation}` );
code.insert( this.start, `${intro.join( `\n${indentation}` )}\n\n${indentation}` );
}
code.insert( this.end, `\n\n${indentation}${outro}` );
code.insert( this.end, `\n\n${indentation}${outro.join( `\n${indentation}` )}` );
}

@@ -116,0 +133,0 @@ }

@@ -28,20 +28,13 @@ import LoopStatement from './shared/LoopStatement.js';

// this is rather finicky, owing to magic-string's quirks
const bodyStart = this.body.body[0].start;
let startIndex = this.left.start;
while ( code.original[ startIndex - 1 ] !== '(' ) startIndex -= 1;
code.remove( this.left.end, this.right.start );
code.remove( startIndex, this.left.start );
code.remove( this.start + 3, startIndex );
code.insert( startIndex, ` ( var ${key} = 0, ${list} = ` );
code.move( this.left.start, this.left.end, bodyStart );
code.move( this.right.start, this.right.end, startIndex );
code.insert( startIndex, `; ${key} < ${list}.length; ${key} += 1` );
code.insert( bodyStart, ` = ${list}[${key}];\n\n${i1}` );
code.insert( this.right.start, `var ${key} = 0, ${list} = ` );
code.insert( this.right.end, `; ${key} < ${list}.length; ${key} += 1` );
super.transpile( code, transforms );
}
}

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

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

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

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

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc