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

buble

Package Overview
Dependencies
Maintainers
1
Versions
109
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

buble - npm Package Compare versions

Comparing version 0.5.6 to 0.5.7

src/program/types/BinaryExpression.js

2

bin/runBuble.js

@@ -22,3 +22,3 @@ var fs = require( 'fs' );

fs.readdirSync( from ).forEach( file => {
fs.readdirSync( from ).forEach( function ( file ) {
compile( path.resolve( from, file ), path.resolve( to, file ), command, options );

@@ -25,0 +25,0 @@ });

# buble changelog
## 0.5.7
* Exponentiation operator support ([#24](https://gitlab.com/Rich-Harris/buble/issues/24))
* More informative error messages for for-of and tagged template strings
## 0.5.6

@@ -4,0 +9,0 @@

{
"name": "buble",
"version": "0.5.6",
"version": "0.5.7",
"description": "The blazing fast, batteries-included ES2015 compiler",

@@ -19,3 +19,3 @@ "main": "dist/buble.umd.js",

"build:es": "rollup -c -f es6 -o dist/buble.es.js",
"test": "mocha test/test.js",
"test": "mocha test/test.js --compilers js:buble/register",
"pretest": "npm run build:umd",

@@ -48,2 +48,3 @@ "prepublish": "npm test && npm run build:es && npm run build:browser"

"devDependencies": {
"buble": "0.5.6",
"eslint": "^2.6.0",

@@ -50,0 +51,0 @@ "glob": "^7.0.3",

@@ -14,4 +14,4 @@ import { parse } from 'acorn';

let bitmask = targets.length ?
0b111111111111111111111111111111 :
0b100000000000000000000000000000;
0b1111111111111111111111111111111 :
0b1000000000000000000000000000000;

@@ -46,3 +46,3 @@ Object.keys( target ).forEach( environment => {

ast = parse( source, {
ecmaVersion: 6,
ecmaVersion: 7,
preserveParens: true,

@@ -49,0 +49,0 @@ sourceType: 'module'

@@ -243,2 +243,4 @@ import wrap from './wrap.js';

declaration.name = outerAlias;
forStatement.aliases[ name ] = {

@@ -249,3 +251,3 @@ outer: outerAlias,

declaration.instances.forEach( identifier => {
for ( const identifier of declaration.instances ) {
const alias = forStatement.body.contains( identifier ) ?

@@ -258,3 +260,3 @@ innerAlias :

}
});
}

@@ -269,5 +271,7 @@ cont = true;

if ( name !== alias ) {
declaration.instances.forEach( identifier => {
declaration.name = alias;
for ( const identifier of declaration.instances ) {
code.overwrite( identifier.start, identifier.end, alias, true );
});
}
}

@@ -274,0 +278,0 @@ }

@@ -13,11 +13,11 @@ export default function extractNames ( node ) {

ObjectPattern ( names, param ) {
param.properties.forEach( prop => {
for ( const prop of param.properties ) {
extractors[ prop.value.type ]( names, prop.value );
});
}
},
ArrayPattern ( names, param ) {
param.elements.forEach( element => {
for ( const element of param.elements ) {
if ( element ) extractors[ element.type ]( names, element );
});
}
},

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

@@ -37,5 +37,5 @@ import wrap from './wrap.js';

this.keys.forEach( key => {
for ( const key of this.keys ) {
this[ key ] = wrap( raw[ key ], this );
});
}

@@ -85,3 +85,3 @@ this.program.magicString.addSourcemapLocation( this.start );

initialise ( transforms ) {
this.keys.forEach( key => {
for ( var key of this.keys ) {
const value = this[ key ];

@@ -94,3 +94,3 @@

}
});
}
}

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

transpile ( code, transforms ) {
this.keys.forEach( key => {
for ( const key of this.keys ) {
const value = this[ key ];

@@ -112,4 +112,4 @@

}
});
}
}
}

@@ -19,7 +19,7 @@ import MagicString from 'magic-string';

this.indentExclusions = {};
this.templateElements.forEach( node => {
for ( const node of this.templateElements ) {
for ( let i = node.start; i < node.end; i += 1 ) {
this.indentExclusions[ node.start + i ] = true;
}
});
}

@@ -26,0 +26,0 @@ this.body.transpile( this.magicString, transforms );

@@ -25,3 +25,3 @@ import extractNames from './extractNames.js';

addDeclaration ( node, kind ) {
extractNames( node ).forEach( name => {
for ( const name of extractNames( node ) ) {
const existingDeclaration = this.declarations[ name ];

@@ -33,3 +33,3 @@ if ( existingDeclaration && ( letConst.test( kind ) || letConst.test( existingDeclaration.kind ) ) ) {

const declaration = { node, kind, instances: [] };
const declaration = { name, node, kind, instances: [] };
this.declarations[ name ] = declaration;

@@ -41,3 +41,3 @@

}
});
}
},

@@ -44,0 +44,0 @@

@@ -25,2 +25,107 @@ import Node from '../Node.js';

}
transpile ( code, transforms ) {
if ( this.operator === '**=' && transforms.exponentiation ) {
const scope = this.findScope( false );
const getAlias = name => {
const declaration = scope.findDeclaration( name );
return declaration ? declaration.name : name;
};
// first, the easy part – `**=` -> `=`
let charIndex = this.left.end;
while ( code.original[ charIndex ] !== '*' ) charIndex += 1;
code.remove( charIndex, charIndex + 2 );
// how we do the next part depends on a number of factors – whether
// this is a top-level statement, and whether we're updating a
// simple or complex reference
let base;
let left = this.left;
while ( left.type === 'ParenthesizedExpression' ) left = left.expression;
if ( left.type === 'Identifier' ) {
base = getAlias( left.name );
} else if ( left.type === 'MemberExpression' ) {
let object;
let needsObjectVar = false;
let property;
let needsPropertyVar = false;
let dotProperty = false;
const statement = this.findNearest( /(?:Statement|Declaration)$/ );
const i0 = statement.getIndentation();
if ( left.property.type === 'Identifier' ) {
property = left.computed ? getAlias( left.property.name ) : left.property.name;
dotProperty = !left.computed;
} else {
property = scope.createIdentifier( 'property' );
needsPropertyVar = true;
}
if ( left.object.type === 'Identifier' ) {
object = getAlias( left.object.name );
} else {
object = scope.createIdentifier( 'object' );
needsObjectVar = true;
}
if ( left.start === statement.start ) {
if ( needsObjectVar && needsPropertyVar ) {
code.insert( statement.start, `var ${object} = ` );
code.overwrite( left.object.end, left.property.start, `;\n${i0}var ${property} = ` );
code.overwrite( left.property.end, left.end, `;\n${i0}${object}[${property}]` );
}
else if ( needsObjectVar ) {
code.insert( statement.start, `var ${object} = ` );
code.insert( left.object.end, `;\n${i0}` );
code.insert( left.object.end, object );
}
else if ( needsPropertyVar ) {
code.insert( statement.start, `var ${property} = ` );
code.move( left.property.start, left.property.end, statement.start );
code.insert( statement.start, `;\n${i0}` );
code.overwrite( left.object.end, left.property.start, `[${property}]` );
code.remove( left.property.end, left.end );
}
}
else {
let declarators = [];
if ( needsObjectVar ) declarators.push( object );
if ( needsPropertyVar ) declarators.push( property );
code.insert( statement.start, `var ${declarators.join( ', ' )};\n${i0}` );
code.insert( left.start, `( ` );
if ( needsObjectVar ) {
code.insert( left.start, `${object} = ` );
code.insert( left.object.end, `, ` );
}
if ( needsPropertyVar ) {
code.insert( left.object.end, `${property} = ` );
code.move( left.property.start, left.property.end, left.object.end );
}
code.remove( left.object.end, left.property.start );
code.overwrite( left.property.end, left.end, `, ${object}${ dotProperty ? `.${property}` : `[${property}]` }` );
code.insert( this.end, ` )` );
}
base = object + ( left.computed ? `[${property}]` : `.${property}` );
}
code.insert( this.right.start, `Math.pow( ${base}, ` );
code.insert( this.right.end, ` )` );
}
super.transpile( code, transforms );
}
}

@@ -6,3 +6,3 @@ import LoopStatement from './shared/LoopStatement.js';

initialise ( transforms ) {
if ( transforms.forOf && !transforms.dangerousForOf ) throw new CompileError( this, 'for...of statements are not supported' );
if ( transforms.forOf && !transforms.dangerousForOf ) throw new CompileError( this, 'for...of statements are not supported. Use `transforms: { forOf: false }` to skip transformation and disable this error, or `transforms: { dangerousForOf: true }` if you know what you\'re doing' );
super.initialise( transforms );

@@ -9,0 +9,0 @@ }

import ArrayExpression from './ArrayExpression.js';
import ArrowFunctionExpression from './ArrowFunctionExpression.js';
import AssignmentExpression from './AssignmentExpression.js';
import BinaryExpression from './BinaryExpression.js';
import BreakStatement from './BreakStatement.js';

@@ -39,2 +40,3 @@ import CallExpression from './CallExpression.js';

AssignmentExpression,
BinaryExpression,
BreakStatement,

@@ -41,0 +43,0 @@ CallExpression,

@@ -7,3 +7,3 @@ import Node from '../Node.js';

if ( transforms.templateString && !transforms.dangerousTaggedTemplateString ) {
throw new CompileError( this, 'Tagged template strings are not supported' );
throw new CompileError( this, 'Tagged template strings are not supported. Use `transforms: { templateString: false }` to skip transformation and disable this error, or `transforms: { dangerousTaggedTemplateString: true }` if you know what you\'re doing' );
}

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

export const matrix = {
chrome: {
48: 0b101111011111100111110101111101,
49: 0b101111111111100111111111111111,
50: 0b111111111111100111111111111111
48: 0b1001111011111100111110101111101,
49: 0b1001111111111100111111111111111,
50: 0b1011111111111100111111111111111
},
firefox: {
43: 0b100111111101100000110111011101,
44: 0b100111111101100000110111011101,
45: 0b100111111101100000110111011101
43: 0b1000111111101100000110111011101,
44: 0b1000111111101100000110111011101,
45: 0b1000111111101100000110111011101
},
safari: {
8: 0b100000000000000000000000000000,
9: 0b101111001101100000011101011110
8: 0b1000000000000000000000000000000,
9: 0b1001111001101100000011101011110
},
ie: {
8: 0b000000000000000000000000000000,
9: 0b100000000000000000000000000000,
10: 0b100000000000000000000000000000,
11: 0b100000000000000111000001100000
8: 0b0000000000000000000000000000000,
9: 0b1000000000000000000000000000000,
10: 0b1000000000000000000000000000000,
11: 0b1000000000000000111000001100000
},
edge: {
12: 0b111110110111100011010001011101,
13: 0b111111110111100011111001011111
12: 0b1011110110111100011010001011101,
13: 0b1011111110111100011111001011111
},
node: {
'0.10': 0b100000000101000000000001000000,
'0.12': 0b100001000101000000010001000100,
4: 0b101111000111100111111001111111,
5: 0b101111000111100111111001111111
'0.10': 0b1000000000101000000000001000000,
'0.12': 0b1000001000101000000010001000100,
4: 0b1001111000111100111111001111111,
5: 0b1001111000111100111111001111111
}

@@ -65,2 +65,5 @@ };

// ES2016
'exponentiation',
// additional transforms, not from

@@ -67,0 +70,0 @@ // https://featuretests.io

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
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc