Socket
Socket
Sign inDemoInstall

buble

Package Overview
Dependencies
Maintainers
2
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.16.0 to 0.17.0

src/program/types/SpreadElement.js

8

CHANGELOG.md
# buble changelog
## 0.17.0
* Update dependencies
* Transpile arrow functions unconditionally if spread arguments need transpilation ([#22](https://github.com/Rich-Harris/buble/pull/22))
* Better object spread support ([#25](https://github.com/Rich-Harris/buble/pull/25))
* Rest properties ([#30](https://github.com/Rich-Harris/buble/pull/30))
* Fix ([#24](https://github.com/Rich-Harris/buble/pull/24))
## 0.16.0

@@ -4,0 +12,0 @@

29

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

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

"type": "git",
"url": "git+https://gitlab.com/Rich-Harris/buble.git"
"url": "git+https://github.com/Rich-Harris/buble.git"
},

@@ -43,18 +43,19 @@ "keywords": [

"bugs": {
"url": "https://gitlab.com/Rich-Harris/buble/issues"
"url": "https://github.com/Rich-Harris/buble/issues"
},
"homepage": "https://gitlab.com/Rich-Harris/buble#README",
"homepage": "https://github.com/Rich-Harris/buble#README",
"devDependencies": {
"buble": "0.8.2",
"console-group": "^0.2.1",
"eslint": "^2.10.1",
"chalk": "^2.1.0",
"console-group": "^0.3.3",
"eslint": "^4.7.2",
"glob": "^7.0.3",
"mocha": "^2.4.5",
"regexpu-core": "^2.0.0",
"mocha": "^3.5.3",
"regexpu-core": "^4.1.3",
"rimraf": "^2.5.2",
"rollup": "^0.50.0",
"rollup-plugin-buble": "^0.8.0",
"rollup-plugin-commonjs": "^2.2.1",
"rollup-plugin-commonjs": "^8.2.1",
"rollup-plugin-json": "^2.0.0",
"rollup-plugin-node-resolve": "^1.5.0",
"rollup-plugin-node-resolve": "^3.0.0",
"source-map": "^0.5.6",

@@ -64,8 +65,6 @@ "source-map-support": "^0.4.0"

"dependencies": {
"acorn": "^3.3.0",
"acorn": "^5.1.2",
"acorn-jsx": "^3.0.1",
"acorn-object-spread": "^1.0.0",
"chalk": "^1.1.3",
"vlq": "0.2.1",
"magic-string": "^0.14.0",
"acorn5-object-spread": "^3.1.0",
"magic-string": "^0.22.4",
"minimist": "^1.2.0",

@@ -72,0 +71,0 @@ "os-homedir": "^1.0.1",

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

import acorn from 'acorn/dist/acorn.js';
import * as acorn from 'acorn';
import acornJsx from 'acorn-jsx/inject';
import acornObjectSpread from 'acorn-object-spread/inject';
import acornObjectSpread from 'acorn5-object-spread/inject';
import Program from './program/Program.js';

@@ -53,3 +53,3 @@ import { features, matrix } from './support.js';

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

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

@@ -127,3 +127,3 @@ import './wrap.js'; // TODO necessary for ordering. sort it out

const assignment = `${prefix}var ${this.argumentsAlias} = arguments${suffix}`;
code.insertLeft( start, assignment );
code.appendLeft( start, assignment );
});

@@ -135,3 +135,3 @@ }

const assignment = `${prefix}var ${this.thisAlias} = this${suffix}`;
code.insertLeft( start, assignment );
code.appendLeft( start, assignment );
});

@@ -144,3 +144,3 @@ }

const assignment = `${prefix}var ${i} = arguments.length, ${this.argumentsArrayAlias} = Array(${i});\n${indentation}while ( ${i}-- ) ${this.argumentsArrayAlias}[${i}] = arguments[${i}]${suffix}`;
code.insertLeft( start, assignment );
code.appendLeft( start, assignment );
});

@@ -164,9 +164,9 @@ }

if ( introStatementGenerators.length ) {
code.insertLeft( this.start, `{` ).insertRight( this.end, `${this.parent.getIndentation()}}` );
code.appendLeft( this.start, `{` ).prependRight( this.end, `${this.parent.getIndentation()}}` );
code.insertRight( expr.start, `\n${indentation}return ` );
code.insertLeft( expr.end, `;\n` );
code.prependRight( expr.start, `\n${indentation}return ` );
code.appendLeft( expr.end, `;\n` );
} else if ( transforms.arrow ) {
code.insertLeft( expr.start, `{ return ` );
code.insertLeft( expr.end, `; }` );
code.prependRight( expr.start, `{ return ` );
code.appendLeft( expr.end, `; }` );
}

@@ -176,3 +176,3 @@ }

else if ( introStatementGenerators.length ) {
code.insertLeft( this.start, `{` ).insertRight( this.end, `}` );
code.prependRight( this.start, `{` ).appendLeft( this.end, `}` );
}

@@ -208,5 +208,5 @@ }

code
.insertRight( param.left.end, lhs )
.prependRight( param.left.end, lhs )
.move( param.left.end, param.right.end, start )
.insertLeft( param.right.end, suffix );
.appendLeft( param.right.end, suffix );
});

@@ -237,5 +237,5 @@ }

if ( count ) {
code.insertLeft( start, `${prefix}var ${name} = [], ${len} = arguments.length - ${count};\n${indentation}while ( ${len}-- > 0 ) ${name}[ ${len} ] = arguments[ ${len} + ${count} ]${suffix}` );
code.prependRight( start, `${prefix}var ${name} = [], ${len} = arguments.length - ${count};\n${indentation}while ( ${len}-- > 0 ) ${name}[ ${len} ] = arguments[ ${len} + ${count} ]${suffix}` );
} else {
code.insertLeft( start, `${prefix}var ${name} = [], ${len} = arguments.length;\n${indentation}while ( ${len}-- ) ${name}[ ${len} ] = arguments[ ${len} ]${suffix}` );
code.prependRight( start, `${prefix}var ${name} = [], ${len} = arguments.length;\n${indentation}while ( ${len}-- ) ${name}[ ${len} ] = arguments[ ${len} ]${suffix}` );
}

@@ -250,3 +250,3 @@ });

destructure( code, this.scope, param, ref, false, introStatementGenerators );
code.insertLeft( param.start, ref );
code.prependRight( param.start, ref );
}

@@ -275,3 +275,3 @@ }

declaration.name = outerAlias;
code.overwrite( declaration.node.start, declaration.node.end, outerAlias, true );
code.overwrite( declaration.node.start, declaration.node.end, outerAlias, { storeName: true });

@@ -289,3 +289,3 @@ forStatement.aliases[ name ] = {

if ( name !== alias ) {
code.overwrite( identifier.start, identifier.end, alias, true );
code.overwrite( identifier.start, identifier.end, alias, { storeName: true });
}

@@ -303,7 +303,7 @@ }

declaration.name = alias;
code.overwrite( declaration.node.start, declaration.node.end, alias, true );
code.overwrite( declaration.node.start, declaration.node.end, alias, { storeName: true });
for ( const identifier of declaration.instances ) {
identifier.rewritten = true;
code.overwrite( identifier.start, identifier.end, alias, true );
code.overwrite( identifier.start, identifier.end, alias, { storeName: true });
}

@@ -310,0 +310,0 @@ }

@@ -14,6 +14,14 @@ export default function extractNames ( node ) {

for ( const prop of node.properties ) {
extractors[ prop.value.type ]( names, prop.value );
extractors[ prop.type ]( names, prop );
}
},
Property ( names, node ) {
extractors[ node.value.type ]( names, node.value );
},
RestElement ( names, node ) {
extractors[ node.argument.type ]( names, node.argument );
},
ArrayPattern ( names, node ) {

@@ -20,0 +28,0 @@ for ( const element of node.elements ) {

import extractNames from './extractNames.js';
import reserved from '../utils/reserved.js';
import CompileError from '../utils/CompileError.js';
const letConst = /^(?:let|const)$/;
export default function Scope ( options ) {

@@ -28,7 +25,2 @@ options = options || {};

const name = identifier.name;
const existingDeclaration = this.declarations[ name ];
if ( existingDeclaration && ( letConst.test( kind ) || letConst.test( existingDeclaration.kind ) ) ) {
// TODO warn about double var declarations?
throw new CompileError( identifier, `${name} is already declared` );
}

@@ -35,0 +27,0 @@ const declaration = { name, node: identifier, kind, instances: [] };

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

transpile ( code, transforms ) {
if ( transforms.arrow ) {
if ( transforms.arrow || this.needsArguments(transforms) ) {
// remove arrow

@@ -19,6 +19,8 @@ let charIndex = this.body.start;

super.transpile( code, transforms );
// wrap naked parameter
if ( this.params.length === 1 && this.start === this.params[0].start ) {
code.insertRight( this.params[0].start, '(' );
code.insertLeft( this.params[0].end, ')' );
code.prependRight( this.params[0].start, '(' );
code.appendLeft( this.params[0].end, ')' );
}

@@ -29,11 +31,17 @@

// standalone expression statement
code.insertRight( this.start, '(function' );
code.insertRight( this.end, ')' );
code.prependRight( this.start, '!function' );
} else {
code.insertRight( this.start, 'function ' );
code.prependRight( this.start, 'function ' );
}
}
super.transpile( code, transforms );
else {
super.transpile( code, transforms );
}
}
// Returns whether any transforms that will happen use `arguments`
needsArguments(transforms) {
return transforms.spreadRest && this.params.filter( param => param.type === 'RestElement' ).length > 0
}
}

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

if ( declaration && declaration.kind === 'const' ) {
throw new CompileError( this.left, `${this.left.name} is read-only` );
throw new CompileError( `${this.left.name} is read-only`, this.left );
}

@@ -48,3 +48,3 @@

function use ( node ) {
code.insertRight( node.start, text );
code.prependRight( node.start, text );
code.move( node.start, node.end, start );

@@ -72,2 +72,4 @@ text = '';

if ( pattern.left.type === 'Identifier' ) {
code.remove( pattern.start, pattern.right.start );
const target = pattern.left.name;

@@ -82,4 +84,5 @@ let source = ref;

write( ` : ${source}` );
}
else {
} else {
code.remove( pattern.left.end, pattern.right.start );
const target = scope.createIdentifier( 'temp' );

@@ -102,3 +105,5 @@ let source = ref;

if ( elements.length === 1 ) {
code.remove( pattern.start, elements[0].start );
destructure( elements[0], `${ref}[0]`, false );
code.remove( elements[0].end, pattern.end );
}

@@ -112,11 +117,19 @@ else {

}
let c = pattern.start;
elements.forEach( ( element, i ) => {
if ( element ) {
if ( element.type === 'RestElement' ) {
destructure( element.argument, `${ref}.slice(${i})`, false );
} else {
destructure( element, `${ref}[${i}]`, false );
}
if (!element) return;
code.remove(c, element.start);
c = element.end;
if ( element.type === 'RestElement' ) {
code.remove( element.start, element.argument.start );
destructure( element.argument, `${ref}.slice(${i})`, false );
} else {
destructure( element, `${ref}[${i}]`, false );
}
} );
});
code.remove(c, pattern.end);
}

@@ -130,3 +143,6 @@ }

const value = prop.computed || prop.key.type !== 'Identifier' ? `${ref}[${code.slice(prop.key.start, prop.key.end)}]` : `${ref}.${prop.key.name}`;
code.remove( pattern.start, prop.value.start );
destructure( prop.value, value, false );
code.remove( prop.end, pattern.end );
}

@@ -140,6 +156,15 @@ else {

}
let c = pattern.start;
props.forEach( prop => {
const value = prop.computed || prop.key.type !== 'Identifier' ? `${ref}[${code.slice(prop.key.start, prop.key.end)}]` : `${ref}.${prop.key.name}`;
code.remove(c, prop.value.start);
c = prop.end;
destructure( prop.value, value, false );
} );
});
code.remove(c, pattern.end);
}

@@ -152,16 +177,16 @@ }

}
destructure( this.left, assign, true );
code.remove( this.left.end, this.right.start );
if ( this.unparenthesizedParent().type === 'ExpressionStatement' ) {
// no rvalue needed for expression statement
code.insertRight( start, `${text})` );
code.prependRight( start, `${text})` );
} else {
// destructuring is part of an expression - need an rvalue
code.insertRight( start, `${text}, ${assign})` );
code.prependRight( start, `${text}, ${assign})` );
}
code.remove( start, this.right.start );
const statement = this.findNearest( /(?:Statement|Declaration)$/ );
code.insertLeft( statement.start, `var ${temporaries.join( ', ' )};\n${statement.getIndentation()}` );
code.appendLeft( statement.start, `var ${temporaries.join( ', ' )};\n${statement.getIndentation()}` );
}

@@ -215,3 +240,3 @@

if ( needsObjectVar && needsPropertyVar ) {
code.insertRight( statement.start, `var ${object} = ` );
code.prependRight( statement.start, `var ${object} = ` );
code.overwrite( left.object.end, left.property.start, `;\n${i0}var ${property} = ` );

@@ -222,13 +247,13 @@ code.overwrite( left.property.end, left.end, `;\n${i0}${object}[${property}]` );

else if ( needsObjectVar ) {
code.insertRight( statement.start, `var ${object} = ` );
code.insertLeft( left.object.end, `;\n${i0}` );
code.insertLeft( left.object.end, object );
code.prependRight( statement.start, `var ${object} = ` );
code.appendLeft( left.object.end, `;\n${i0}` );
code.appendLeft( left.object.end, object );
}
else if ( needsPropertyVar ) {
code.insertRight( left.property.start, `var ${property} = ` );
code.insertLeft( left.property.end, `;\n${i0}` );
code.prependRight( left.property.start, `var ${property} = ` );
code.appendLeft( left.property.end, `;\n${i0}` );
code.move( left.property.start, left.property.end, this.start );
code.insertLeft( left.object.end, `[${property}]` );
code.appendLeft( left.object.end, `[${property}]` );
code.remove( left.object.end, left.property.start );

@@ -245,7 +270,7 @@ code.remove( left.property.end, left.end );

if ( declarators.length ) {
code.insertRight( statement.start, `var ${declarators.join( ', ' )};\n${i0}` );
code.prependRight( statement.start, `var ${declarators.join( ', ' )};\n${i0}` );
}
if ( needsObjectVar && needsPropertyVar ) {
code.insertRight( left.start, `( ${object} = ` );
code.prependRight( left.start, `( ${object} = ` );
code.overwrite( left.object.end, left.property.start, `, ${property} = ` );

@@ -256,9 +281,9 @@ code.overwrite( left.property.end, left.end, `, ${object}[${property}]` );

else if ( needsObjectVar ) {
code.insertRight( left.start, `( ${object} = ` );
code.insertLeft( left.object.end, `, ${object}` );
code.prependRight( left.start, `( ${object} = ` );
code.appendLeft( left.object.end, `, ${object}` );
}
else if ( needsPropertyVar ) {
code.insertRight( left.property.start, `( ${property} = ` );
code.insertLeft( left.property.end, `, ` );
code.prependRight( left.property.start, `( ${property} = ` );
code.appendLeft( left.property.end, `, ` );
code.move( left.property.start, left.property.end, left.start );

@@ -271,3 +296,3 @@

if ( needsPropertyVar ) {
code.insertLeft( this.end, ` )` );
code.appendLeft( this.end, ` )` );
}

@@ -279,5 +304,5 @@ }

code.insertRight( this.right.start, `Math.pow( ${base}, ` );
code.insertLeft( this.right.end, ` )` );
code.prependRight( this.right.start, `Math.pow( ${base}, ` );
code.appendLeft( this.right.end, ` )` );
}
}

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

if ( this.operator === '**' && transforms.exponentiation ) {
code.insertRight( this.start, `Math.pow( ` );
code.prependRight( this.start, `Math.pow( ` );
code.overwrite( this.left.end, this.right.start, `, ` );
code.insertLeft( this.end, ` )` );
code.appendLeft( this.end, ` )` );
}

@@ -11,0 +11,0 @@ super.transpile( code, transforms );

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

if ( this.loop && this.loop.shouldRewriteAsFunction ) {
if ( this.label ) throw new CompileError( this, 'Labels are not currently supported in a loop with locally-scoped variables' );
if ( this.label ) throw new CompileError( 'Labels are not currently supported in a loop with locally-scoped variables', this );
code.overwrite( this.start, this.start + 5, `return 'break'` );

@@ -21,0 +21,0 @@ }

@@ -60,5 +60,5 @@ import Node from '../Node.js';

const i0 = lastStatementInBlock.getIndentation();
code.insertRight( callExpression.start, `(${context} = ` );
code.insertLeft( callExpression.end, `)` );
code.insertLeft( lastStatementInBlock.end, `\n${i0}var ${context};` );
code.prependRight( callExpression.start, `(${context} = ` );
code.appendLeft( callExpression.end, `)` );
code.appendLeft( lastStatementInBlock.end, `\n${i0}var ${context};` );
}

@@ -69,3 +69,3 @@ } else {

code.insertLeft( this.callee.end, '.apply' );
code.appendLeft( this.callee.end, '.apply' );

@@ -77,6 +77,6 @@ if ( _super ) {

if ( firstArgument.type !== 'SpreadElement' ) {
code.insertRight( firstArgument.start, `[ ` );
code.prependRight( firstArgument.start, `[ ` );
}
code.insertLeft( this.arguments[ this.arguments.length - 1 ].end, ' )' );
code.appendLeft( this.arguments[ this.arguments.length - 1 ].end, ' )' );
}

@@ -86,11 +86,11 @@ }

else if ( this.arguments.length === 1 ) {
code.insertRight( firstArgument.start, `${context}, ` );
code.prependRight( firstArgument.start, `${context}, ` );
} else {
if ( firstArgument.type === 'SpreadElement' ) {
code.insertLeft( firstArgument.start, `${context}, ` );
code.appendLeft( firstArgument.start, `${context}, ` );
} else {
code.insertLeft( firstArgument.start, `${context}, [ ` );
code.appendLeft( firstArgument.start, `${context}, [ ` );
}
code.insertLeft( this.arguments[ this.arguments.length - 1 ].end, ' )' );
code.appendLeft( this.arguments[ this.arguments.length - 1 ].end, ' )' );
}

@@ -97,0 +97,0 @@ }

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

if ( !inFunctionExpression ) code.insertLeft( constructor.end, ';' );
if ( !inFunctionExpression ) code.appendLeft( constructor.end, ';' );
}

@@ -136,4 +136,4 @@

if ( fake_computed ) {
code.insertRight( method.key.start, '[' );
code.insertLeft( method.key.end, ']' );
code.prependRight( method.key.start, '[' );
code.appendLeft( method.key.end, ']' );
} else {

@@ -145,11 +145,11 @@ while ( code.original[c] !== ']' ) c += 1;

code.insertRight( method.start, lhs );
const funcName = method.computed || isAccessor || !namedFunctions ? '' : `${methodName} `;
const rhs = ( isAccessor ? `.${method.kind}` : '' ) + ` = function` + ( method.value.generator ? '* ' : ' ' ) + funcName;
code.remove( c, method.value.start );
code.insertRight( method.value.start, rhs );
code.insertLeft( method.end, ';' );
code.prependRight( method.value.start, rhs );
code.appendLeft( method.end, ';' );
if ( method.value.generator ) code.remove( method.start, method.key.start );
code.prependRight( method.start, lhs );
});

@@ -179,8 +179,8 @@

if ( constructor ) {
code.insertLeft( constructor.end, introBlock );
code.appendLeft( constructor.end, introBlock );
} else {
code.insertRight( this.start, introBlock );
code.prependRight( this.start, introBlock );
}
code.insertLeft( this.end, outroBlock );
code.appendLeft( this.end, outroBlock );
}

@@ -187,0 +187,0 @@

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

code.remove( this.id.end, this.superClass.start );
code.insertLeft( this.id.end, ` = (function (${superName}) {\n${i1}` );
code.appendLeft( this.id.end, ` = (function (${superName}) {\n${i1}` );
} else {

@@ -42,3 +42,3 @@ code.overwrite( this.id.end, this.superClass.start, ' = ' );

if ( this.id.end === this.body.start ) {
code.insertLeft( this.id.end, ' = ' );
code.appendLeft( this.id.end, ' = ' );
} else {

@@ -52,7 +52,7 @@ code.overwrite( this.id.end, this.body.start, ' = ' );

if ( this.superClass ) {
code.insertLeft( this.end, `\n\n${i1}return ${this.name};\n${i0}}(` );
code.appendLeft( this.end, `\n\n${i1}return ${this.name};\n${i0}}(` );
code.move( this.superClass.start, this.superClass.end, this.end );
code.insertRight( this.end, `));${syntheticDefaultExport}` );
code.prependRight( this.end, `));${syntheticDefaultExport}` );
} else if ( syntheticDefaultExport ) {
code.insertRight( this.end, syntheticDefaultExport );
code.prependRight( this.end, syntheticDefaultExport );
}

@@ -59,0 +59,0 @@ }

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

code.remove( this.superClass.end, this.body.start );
code.insertLeft( this.start, `(function (${superName}) {\n${i1}` );
code.appendLeft( this.start, `(function (${superName}) {\n${i1}` );
} else {

@@ -34,7 +34,7 @@ code.overwrite( this.start, this.body.start, `(function () {\n${i1}` );

if ( this.superClass ) {
code.insertLeft( this.end, outro );
code.appendLeft( this.end, outro );
code.move( this.superClass.start, this.superClass.end, this.end );
code.insertRight( this.end, '))' );
code.prependRight( this.end, '))' );
} else {
code.insertLeft( this.end, `\n\n${i1}return ${this.name};\n${i0}}())` );
code.appendLeft( this.end, `\n\n${i1}return ${this.name};\n${i0}}())` );
}

@@ -41,0 +41,0 @@ }

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

if ( loop.shouldRewriteAsFunction ) {
if ( this.label ) throw new CompileError( this, 'Labels are not currently supported in a loop with locally-scoped variables' );
if ( this.label ) throw new CompileError( 'Labels are not currently supported in a loop with locally-scoped variables', this );
code.overwrite( this.start, this.start + 8, 'return' );

@@ -12,0 +12,0 @@ }

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

initialise ( transforms ) {
if ( transforms.moduleExport ) throw new CompileError( this, 'export is not supported' );
if ( transforms.moduleExport ) throw new CompileError( 'export is not supported', this );
super.initialise( transforms );
}
}

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

initialise ( transforms ) {
if ( transforms.moduleExport ) throw new CompileError( this, 'export is not supported' );
if ( transforms.moduleExport ) throw new CompileError( 'export is not supported', this );
super.initialise( transforms );
}
}

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

initialise ( transforms ) {
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' );
if ( transforms.forOf && !transforms.dangerousForOf ) throw new CompileError( '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', this );
super.initialise( transforms );

@@ -13,6 +13,4 @@ }

transpile ( code, transforms ) {
if ( !transforms.dangerousForOf ) {
super.transpile( code, transforms );
return;
}
super.transpile( code, transforms );
if ( !transforms.dangerousForOf ) return;

@@ -23,3 +21,3 @@ // edge case (#80)

code.remove( this.start, this.left.start );
code.insertLeft( this.left.end, ';' );
code.appendLeft( this.left.end, ';' );
code.remove( this.left.end, this.end );

@@ -41,4 +39,4 @@ } else {

if ( this.body.synthetic ) {
code.insertRight( this.left.start, `{\n${i1}` );
code.insertLeft( this.body.body[0].end, `\n${i0}}` );
code.prependRight( this.left.start, `{\n${i1}` );
code.appendLeft( this.body.body[0].end, `\n${i0}}` );
}

@@ -52,4 +50,4 @@

code.insertRight( this.right.start, `var ${key} = 0, ${list} = ` );
code.insertLeft( this.right.end, `; ${key} < ${list}.length; ${key} += 1` );
code.prependRight( this.right.start, `var ${key} = 0, ${list} = ` );
code.appendLeft( this.right.end, `; ${key} < ${list}.length; ${key} += 1` );

@@ -72,10 +70,8 @@ // destructuring. TODO non declaration destructuring

code.insertLeft( this.left.start + this.left.kind.length + 1, ref );
code.insertLeft( this.left.end, ` = ${list}[${key}];\n${i1}` );
code.appendLeft( this.left.start + this.left.kind.length + 1, ref );
code.appendLeft( this.left.end, ` = ${list}[${key}];\n${i1}` );
} else {
code.insertLeft( this.left.end, ` = ${list}[${key}];\n\n${i1}` );
code.appendLeft( this.left.end, ` = ${list}[${key}];\n\n${i1}` );
}
super.transpile( code, transforms );
}
}

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

if ( this.body.synthetic ) {
code.insertLeft( this.body.body[0].end, `; ${updates.join(` `)}` );
code.appendLeft( this.body.body[0].end, `; ${updates.join(` `)}` );
} else {
const lastStatement = this.body.body[ this.body.body.length - 1 ];
code.insertLeft( lastStatement.end, `\n\n${i1}${updates.join(`\n${i1}`)}` );
code.appendLeft( lastStatement.end, `\n\n${i1}${updates.join(`\n${i1}`)}` );
}

@@ -34,0 +34,0 @@ }

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

if ( this.generator && transforms.generator ) {
throw new CompileError( this, 'Generators are not supported' );
throw new CompileError( 'Generators are not supported', this );
}

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

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

if ( this.generator && transforms.generator ) {
throw new CompileError( this, 'Generators are not supported' );
throw new CompileError( 'Generators are not supported', this );
}

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

@@ -40,5 +40,5 @@ import Node from '../Node.js';

if ( this.alias ) {
code.overwrite( this.start, this.end, this.alias, true );
code.overwrite( this.start, this.end, this.alias, { storeName: true, contentOnly: true });
}
}
}

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

|| this.consequent.type === 'BlockStatement' && this.consequent.synthetic ) {
code.insertLeft( this.consequent.start, '{ ' );
code.insertRight( this.consequent.end, ' }' );
code.appendLeft( this.consequent.start, '{ ' );
code.prependRight( this.consequent.end, ' }' );
}

@@ -19,4 +19,4 @@

|| this.alternate.type === 'BlockStatement' && this.alternate.synthetic ) ) {
code.insertLeft( this.alternate.start, '{ ' );
code.insertRight( this.alternate.end, ' }' );
code.appendLeft( this.alternate.start, '{ ' );
code.prependRight( this.alternate.end, ' }' );
}

@@ -23,0 +23,0 @@

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

initialise ( transforms ) {
if ( transforms.moduleImport ) throw new CompileError( this, 'import is not supported' );
if ( transforms.moduleImport ) throw new CompileError( 'import is not supported', this );
super.initialise( transforms );
}
}

@@ -36,3 +36,3 @@ import ArrayExpression from './ArrayExpression.js';

import ReturnStatement from './ReturnStatement.js';
import SpreadProperty from './SpreadProperty.js';
import SpreadElement from './SpreadElement.js';
import Super from './Super.js';

@@ -83,3 +83,3 @@ import TaggedTemplateExpression from './TaggedTemplateExpression.js';

ReturnStatement,
SpreadProperty,
SpreadElement,
Super,

@@ -86,0 +86,0 @@ TaggedTemplateExpression,

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

const tail = code.original[ c ] === '\n' && child.type !== 'Literal' ? '' : ' ';
code.insertLeft( c, `,${tail}` );
code.appendLeft( c, `,${tail}` );
}

@@ -41,0 +41,0 @@

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

transpile ( code, transforms ) {
super.transpile( code, transforms );
code.overwrite( this.start, this.name.start, `${this.program.jsx}( ` );
const html = this.name.type === 'JSXIdentifier' && this.name.name[0] === this.name.name[0].toLowerCase();
if ( html ) code.insertRight( this.name.start, `'` );
if ( html ) code.prependRight( this.name.start, `'` );

@@ -33,3 +35,3 @@ const len = this.attributes.length;

if ( attr.start === c )
code.insertRight( c, ', ' );
code.prependRight( c, ', ' );
else

@@ -44,7 +46,7 @@ code.overwrite( c, attr.start, ', ' );

if ( !lastAttr || lastAttr.type === 'JSXSpreadAttribute' ) {
code.insertRight( attr.start, '{ ' );
code.prependRight( attr.start, '{ ' );
}
if ( !nextAttr || nextAttr.type === 'JSXSpreadAttribute' ) {
code.insertLeft( attr.end, ' }' );
code.appendLeft( attr.end, ' }' );
}

@@ -63,3 +65,3 @@ }

if (!this.program.options.objectAssign) {
throw new CompileError( this, 'Mixed JSX attributes ending in spread requires specified objectAssign option with \'Object.assign\' or polyfill helper.' );
throw new CompileError( 'Mixed JSX attributes ending in spread requires specified objectAssign option with \'Object.assign\' or polyfill helper.', this );
}

@@ -74,14 +76,12 @@ before = html ? `', ${this.program.options.objectAssign}({},` : `, ${this.program.options.objectAssign}({},`;

code.insertRight( this.name.end, before );
code.prependRight( this.name.end, before );
if ( after ) {
code.insertLeft( this.attributes[ len - 1 ].end, after );
code.appendLeft( this.attributes[ len - 1 ].end, after );
}
} else {
code.insertLeft( this.name.end, html ? `', null` : `, null` );
code.appendLeft( this.name.end, html ? `', null` : `, null` );
c = this.name.end;
}
super.transpile( code, transforms );
if ( this.selfClosing ) {

@@ -88,0 +88,0 @@ code.overwrite( c, this.end, this.attributes.length ? `)` : ` )` );

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

if ( leading === '0b' || leading === '0o' ) {
code.overwrite( this.start, this.end, String( this.value ), true );
code.overwrite( this.start, this.end, String( this.value ), {
storeName: true,
contentOnly: true
});
}

@@ -24,5 +27,7 @@ }

if ( transforms.stickyRegExp && /y/.test( flags ) ) throw new CompileError( this, 'Regular expression sticky flag is not supported' );
if ( transforms.stickyRegExp && /y/.test( flags ) ) throw new CompileError( 'Regular expression sticky flag is not supported', this );
if ( transforms.unicodeRegExp && /u/.test( flags ) ) {
code.overwrite( this.start, this.end, `/${rewritePattern( pattern, flags )}/${flags.replace( 'u', '' )}` );
code.overwrite( this.start, this.end, `/${rewritePattern( pattern, flags )}/${flags.replace( 'u', '' )}`, {
contentOnly: true
});
}

@@ -29,0 +34,0 @@ }

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

code.overwrite( this.object.end, this.property.start, `['` );
code.insertLeft( this.property.end, `']` );
code.appendLeft( this.property.end, `']` );
}

@@ -11,0 +11,0 @@

@@ -29,5 +29,5 @@ import Node from '../Node.js';

if ( hasSpreadElements ) {
code.insertRight( this.start + 'new'.length, ' (Function.prototype.bind.apply(' );
code.prependRight( this.start + 'new'.length, ' (Function.prototype.bind.apply(' );
code.overwrite( this.callee.end, firstArgument.start, ', [ null ].concat( ' );
code.insertLeft( this.end, ' ))' );
code.appendLeft( this.end, ' ))' );
}

@@ -34,0 +34,0 @@ }

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

for ( let prop of this.properties ) {
if ( prop.type === 'SpreadProperty' ) {
if ( prop.type === 'SpreadElement' ) {
spreadPropertyCount += 1;

@@ -26,3 +26,3 @@ } else if ( prop.computed ) {

if ( !this.program.options.objectAssign ) {
throw new CompileError( this, 'Object spread operator requires specified objectAssign option with \'Object.assign\' or polyfill helper.' );
throw new CompileError( 'Object spread operator requires specified objectAssign option with \'Object.assign\' or polyfill helper.', this );
}

@@ -40,7 +40,7 @@ // enclose run of non-spread properties in curlies

if ( !lastProp || lastProp.type !== 'Property' || lastProp.computed ) {
code.insertRight( prop.start, '{' );
code.prependRight( prop.start, '{' );
}
if ( !nextProp || nextProp.type !== 'Property' || nextProp.computed ) {
code.insertLeft( prop.end, '}' );
code.appendLeft( prop.end, '}' );
}

@@ -87,5 +87,5 @@ }

const statement = this.findNearest( /(?:Statement|Declaration)$/ );
code.insertLeft( statement.end, `\n${i0}var ${name};` );
code.appendLeft( statement.end, `\n${i0}var ${name};` );
code.insertRight( this.start, `( ${name} = ` );
code.prependRight( this.start, `( ${name} = ` );
}

@@ -109,3 +109,3 @@

} else {
code.insertRight( prop.start, propId );
code.prependRight( prop.start, propId );
}

@@ -118,3 +118,3 @@

if ( prop.value.start > c ) code.remove( c, prop.value.start );
code.insertLeft( c, ' = ' );
code.appendLeft( c, ' = ' );
code.move( moveStart, prop.end, end );

@@ -131,3 +131,3 @@

if ( prop.method && transforms.conciseMethodProperty ) {
code.insertRight( prop.value.start, 'function ' );
code.prependRight( prop.value.start, 'function ' );
}

@@ -145,3 +145,3 @@ } else {

if ( !isSimpleAssignment ) {
code.insertLeft( lastComputedProp.end, `, ${name} )` );
code.appendLeft( lastComputedProp.end, `, ${name} )` );
}

@@ -148,0 +148,0 @@ }

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

transpile ( code, transforms ) {
super.transpile( code, transforms );
if ( transforms.conciseMethodProperty && !this.computed && this.parent.type !== 'ObjectPattern' ) {
if ( this.shorthand ) {
code.insertRight( this.start, `${this.key.name}: ` );
code.prependRight( this.start, `${this.key.name}: ` );
} else if ( this.method ) {

@@ -30,3 +32,3 @@ let name = '';

if ( this.value.generator ) code.remove( this.start, this.key.start );
code.insertLeft( this.key.end, `: function${this.value.generator ? '*' : ''}${name}` );
code.appendLeft( this.key.end, `: function${this.value.generator ? '*' : ''}${name}` );
}

@@ -36,8 +38,6 @@ }

if ( transforms.reservedProperties && reserved[ this.key.name ] ) {
code.insertRight( this.key.start, `'` );
code.insertLeft( this.key.end, `'` );
code.prependRight( this.key.start, `'` );
code.appendLeft( this.key.end, `'` );
}
super.transpile( code, transforms );
}
}

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

if ( this.argument ) {
if ( shouldWrap ) code.insertRight( this.argument.start, `{ v: ` );
if ( shouldWrap ) code.prependRight( this.argument.start, `{ v: ` );
this.argument.transpile( code, transforms );
if ( shouldWrap ) code.insertLeft( this.argument.end, ` }` );
if ( shouldWrap ) code.appendLeft( this.argument.end, ` }` );
} else if ( shouldWrap ) {
code.insertLeft( this.start + 6, ' {}' );
code.appendLeft( this.start + 6, ' {}' );
}
}
}

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

code.insertRight( this.body.start, before );
code.insertLeft( this.body.end, after );
code.prependRight( this.body.start, before );
code.appendLeft( this.body.end, after );
code.move( this.start, this.body.start, this.body.end );

@@ -75,3 +75,3 @@

code.insertRight( this.body.end, insert );
code.prependRight( this.body.end, insert );
} else {

@@ -83,8 +83,8 @@ const callExpression = `${loop}(${argString});`;

} else {
code.insertRight( this.body.end, callExpression );
code.prependRight( this.body.end, callExpression );
}
}
} else if ( needsBlock ) {
code.insertLeft( this.body.start, '{ ' );
code.insertRight( this.body.end, ' }' );
code.appendLeft( this.body.start, '{ ' );
code.prependRight( this.body.end, ' }' );
}

@@ -91,0 +91,0 @@

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

initialise ( transforms ) {
if ( transforms.moduleImport ) throw new CompileError( this, 'Modules are not supported' );
if ( transforms.moduleImport ) throw new CompileError( 'Modules are not supported', this );
super.initialise( transforms );
}
}

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

if ( !this.superClassName ) throw new CompileError( this, 'super used in base class' );
if ( !this.superClassName ) throw new CompileError( 'super used in base class', this );

@@ -20,3 +20,3 @@ this.isCalled = this.parent.type === 'CallExpression' && this === this.parent.callee;

if ( this.method.kind !== 'constructor' && this.isCalled ) {
throw new CompileError( this, 'super() not allowed outside class constructor' );
throw new CompileError( 'super() not allowed outside class constructor', this );
}

@@ -27,3 +27,3 @@

if ( !this.isCalled && !this.isMember ) {
throw new CompileError( this, 'Unexpected use of `super` (expected `super(...)` or `super.*`)' );
throw new CompileError( 'Unexpected use of `super` (expected `super(...)` or `super.*`)', this );
}

@@ -53,3 +53,3 @@ }

code.overwrite( this.start, this.end, expression, true );
code.overwrite( this.start, this.end, expression, { storeName: true, contentOnly: true });

@@ -60,3 +60,3 @@ const callExpression = this.isCalled ? this.parent : this.parent.parent;

if ( !this.noCall ) { // special case – `super( ...args )`
code.insertLeft( callExpression.callee.end, '.call' );
code.appendLeft( callExpression.callee.end, '.call' );
}

@@ -67,5 +67,5 @@

if ( callExpression.arguments.length ) {
code.insertLeft( callExpression.arguments[0].start, `${thisAlias}, ` );
code.appendLeft( callExpression.arguments[0].start, `${thisAlias}, ` );
} else {
code.insertLeft( callExpression.end - 1, `${thisAlias}` );
code.appendLeft( callExpression.end - 1, `${thisAlias}` );
}

@@ -72,0 +72,0 @@ }

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

if ( transforms.templateString && !transforms.dangerousTaggedTemplateString ) {
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' );
throw new CompileError( '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', this );
}

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

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

if ( parenthesise ) code.insertRight( this.start, '(' );
if ( parenthesise ) code.appendRight( this.start, '(' );

@@ -42,18 +42,17 @@ let lastIndex = this.start;

ordered.forEach( ( node, i ) => {
let prefix = i === 0 ?
parenthesise ? '(' : '' :
' + ';
if ( node.type === 'TemplateElement' ) {
let replacement = '';
if ( i ) replacement += ' + ';
replacement += JSON.stringify( node.value.cooked );
code.overwrite( lastIndex, node.end, replacement );
code.overwrite( lastIndex, node.end, prefix + JSON.stringify( node.value.cooked ) );
} else {
const parenthesise = node.type !== 'Identifier'; // TODO other cases where it's safe
let replacement = '';
if ( i ) replacement += ' + ';
if ( parenthesise ) replacement += '(';
if ( parenthesise ) prefix += '(';
code.overwrite( lastIndex, node.start, replacement );
code.remove( lastIndex, node.start );
if ( parenthesise ) code.insertLeft( node.end, ')' );
if ( prefix ) code.prependRight( node.start, prefix );
if ( parenthesise ) code.appendLeft( node.end, ')' );
}

@@ -64,6 +63,4 @@

let close = '';
if ( parenthesise ) close += ')';
code.overwrite( lastIndex, this.end, close );
if ( parenthesise ) code.appendLeft( lastIndex, ')' );
code.remove( lastIndex, this.end );
}

@@ -70,0 +67,0 @@

@@ -21,5 +21,8 @@ import Node from '../Node.js';

if ( this.alias ) {
code.overwrite( this.start, this.end, this.alias, true );
code.overwrite( this.start, this.end, this.alias, {
storeName: true,
contentOnly: true
});
}
}
}

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

if ( declaration && declaration.kind === 'const' ) {
throw new CompileError( this, `${this.argument.name} is read-only` );
throw new CompileError( `${this.argument.name} is read-only`, this );
}

@@ -12,0 +12,0 @@

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

kind = 'var';
code.overwrite( this.start, this.start + this.kind.length, kind, true );
code.overwrite( this.start, this.start + this.kind.length, kind, { storeName: true });
}

@@ -26,2 +26,4 @@

this.declarations.forEach( ( declarator, i ) => {
declarator.transpile( code, transforms );
if ( declarator.id.type === 'Identifier' ) {

@@ -52,4 +54,4 @@ if ( i > 0 && this.declarations[ i - 1 ].id.type !== 'Identifier' ) {

statementGenerators.push( ( start, prefix, suffix ) => {
code.insertRight( declarator.id.end, `var ${name}` );
code.insertLeft( declarator.init.end, `${suffix}` );
code.prependRight( declarator.id.end, `var ${name}` );
code.appendLeft( declarator.init.end, `${suffix}` );
code.move( declarator.id.end, declarator.end, start );

@@ -72,4 +74,2 @@ });

declarator.transpile( code, transforms );
c = declarator.end;

@@ -79,4 +79,4 @@ lastDeclaratorIsPattern = declarator.id.type !== 'Identifier';

if ( lastDeclaratorIsPattern ) {
code.remove( c, this.end );
if ( lastDeclaratorIsPattern && this.end > c ) {
code.overwrite( c, this.end, '', { contentOnly: true });
}

@@ -83,0 +83,0 @@ }

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

if ( inLoop && ! /Function/.test( inLoop.type ) && ! this.isLeftDeclaratorOfLoop() ) {
code.insertLeft( this.id.end, ' = (void 0)' );
code.appendLeft( this.id.end, ' = (void 0)' );
}

@@ -21,0 +21,0 @@ }

@@ -5,9 +5,11 @@ import locate from './locate.js';

export default class CompileError extends Error {
constructor ( node, message ) {
super();
constructor ( message, node ) {
super( message );
this.name = 'CompileError';
if ( !node ) { return; }
const source = node.program.magicString.original;
const loc = locate( source, node.start );
this.name = 'CompileError';
this.message = message + ` (${loc.line}:${loc.column})`;

@@ -14,0 +16,0 @@

@@ -16,4 +16,4 @@ import { findIndex } from './array.js';

statementGenerators.push( ( start, prefix, suffix ) => {
code.insertRight( node.start, inline ? prefix : `${prefix}var ` );
code.insertLeft( node.end, ` = ${ref}${suffix}` );
code.prependRight( node.start, inline ? prefix : `${prefix}var ` );
code.appendLeft( node.end, ` = ${ref}${suffix}` );
code.move( node.start, node.end, start );

@@ -29,5 +29,5 @@ });

statementGenerators.push( ( start, prefix, suffix ) => {
code.insertRight( node.left.end, `${prefix}if ( ${name} === void 0 ) ${name}` );
code.prependRight( node.left.end, `${prefix}if ( ${name} === void 0 ) ${name}` );
code.move( node.left.end, node.right.end, start );
code.insertLeft( node.right.end, suffix );
code.appendLeft( node.right.end, suffix );
});

@@ -61,5 +61,24 @@ }

const nonRestKeys = [];
node.properties.forEach( prop => {
let value = prop.computed || prop.key.type !== 'Identifier' ? `${ref}[${code.slice(prop.key.start, prop.key.end)}]` : `${ref}.${prop.key.name}`;
handleProperty( code, scope, c, prop.value, value, inline, statementGenerators );
let value;
let content
if (prop.type === "Property") {
const isComputedKey = prop.computed || prop.key.type !== 'Identifier'
const key = isComputedKey ? code.slice(prop.key.start, prop.key.end) : prop.key.name
value = isComputedKey ? `${ref}[${key}]` : `${ref}.${key}`;
content = prop.value;
nonRestKeys.push(isComputedKey ? key : '"' + key + '"')
} else if (prop.type === "RestElement") {
content = prop.argument
value = scope.createIdentifier( 'rest' );
const n = scope.createIdentifier( 'n' );
statementGenerators.push( ( start, prefix, suffix ) => {
code.overwrite(prop.start, c = prop.argument.start, `${prefix}var ${value} = {}; for (var ${n} in ${ref}) if([${nonRestKeys.join(", ")}].indexOf(${n}) === -1) ${value}[${n}] = ${ref}[${n}]${suffix}`)
code.move(prop.start, c, start)
} );
} else {
throw new CompileError( this, `Unexpected node of type ${prop.type} in object pattern`)
}
handleProperty( code, scope, c, content, value, inline, statementGenerators );
c = prop.end;

@@ -94,7 +113,7 @@ });

if ( inline ) {
code.insertRight( node.right.start, `${name} = ${value} === undefined ? ` );
code.insertLeft( node.right.end, ` : ${value}` );
code.prependRight( node.right.start, `${name} = ${value} === undefined ? ` );
code.appendLeft( node.right.end, ` : ${value}` );
} else {
code.insertRight( node.right.start, `${prefix}var ${name} = ${value}; if ( ${name} === void 0 ) ${name} = ` );
code.insertLeft( node.right.end, suffix );
code.prependRight( node.right.start, `${prefix}var ${name} = ${value}; if ( ${name} === void 0 ) ${name} = ` );
code.appendLeft( node.right.end, suffix );
}

@@ -119,28 +138,20 @@

let ref = value;
if ( node.properties.length > 1 ) {
const ref = scope.createIdentifier( value );
ref = scope.createIdentifier( value );
statementGenerators.push( ( start, prefix, suffix ) => {
// this feels a tiny bit hacky, but we can't do a
// straightforward insertLeft and keep correct order...
code.insertRight( node.start, `${prefix}var ${ref} = ` );
// straightforward appendLeft and keep correct order...
code.prependRight( node.start, `${prefix}var ${ref} = ` );
code.overwrite( node.start, c = node.start + 1, value );
code.insertLeft( c, suffix );
code.appendLeft( c, suffix );
code.overwrite( node.start, c = node.start + 1, `${prefix}var ${ref} = ${value}${suffix}` );
code.move( node.start, c, start );
});
node.properties.forEach( prop => {
const value = prop.computed || prop.key.type !== 'Identifier' ? `${ref}[${code.slice(prop.key.start, prop.key.end)}]` : `${ref}.${prop.key.name}`;
handleProperty( code, scope, c, prop.value, value, inline, statementGenerators );
c = prop.end;
});
} else {
const prop = node.properties[0];
const value_suffix = prop.computed || prop.key.type !== 'Identifier' ? `[${code.slice(prop.key.start, prop.key.end)}]` : `.${prop.key.name}`;
handleProperty( code, scope, c, prop.value, `${value}${value_suffix}`, inline, statementGenerators );
c = prop.end;
}
code.remove( c, node.end );
destructureObjectPattern( code, scope, node, ref, inline, statementGenerators );
break;

@@ -156,5 +167,5 @@ }

statementGenerators.push( ( start, prefix, suffix ) => {
code.insertRight( node.start, `${prefix}var ${ref} = ` );
code.overwrite( node.start, c = node.start + 1, value );
code.insertLeft( c, suffix );
code.prependRight( node.start, `${prefix}var ${ref} = ` );
code.overwrite( node.start, c = node.start + 1, value, { contentOnly: true });
code.appendLeft( c, suffix );

@@ -161,0 +172,0 @@ code.move( node.start, c, start );

@@ -28,4 +28,4 @@ export function isArguments ( node ) {

} else {
code.insertRight( element.start, '[' );
code.insertRight( element.end, ']' );
code.prependRight( element.start, '[' );
code.prependRight( element.end, ']' );
}

@@ -54,4 +54,4 @@ }

} else {
code.insertLeft( element.start, '[' );
code.insertLeft( element.end, ']' );
code.appendLeft( element.start, '[' );
code.appendLeft( element.end, ']' );
}

@@ -58,0 +58,0 @@ }

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