babel-generator
Advanced tools
Comparing version 6.23.0 to 7.0.0-alpha.1
@@ -5,6 +5,2 @@ "use strict"; | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _trimRight = require("trim-right"); | ||
@@ -16,2 +12,4 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var SPACES_RE = /^[ \t]+$/; | ||
@@ -21,3 +19,4 @@ | ||
function Buffer(map) { | ||
(0, _classCallCheck3.default)(this, Buffer); | ||
_classCallCheck(this, Buffer); | ||
this._map = null; | ||
@@ -204,3 +203,2 @@ this._buf = []; | ||
exports.default = Buffer; | ||
module.exports = exports["default"]; | ||
exports.default = Buffer; |
@@ -90,8 +90,3 @@ "use strict"; | ||
if (node.kind === "constructorCall") { | ||
this.word("call"); | ||
this.space(); | ||
} | ||
this._method(node); | ||
} |
@@ -16,3 +16,3 @@ "use strict"; | ||
exports.DeclareVariable = DeclareVariable; | ||
exports.ExistentialTypeParam = ExistentialTypeParam; | ||
exports.ExistsTypeAnnotation = ExistsTypeAnnotation; | ||
exports.FunctionTypeAnnotation = FunctionTypeAnnotation; | ||
@@ -31,3 +31,3 @@ exports.FunctionTypeParam = FunctionTypeParam; | ||
Object.defineProperty(exports, "NumericLiteralTypeAnnotation", { | ||
Object.defineProperty(exports, "NumberLiteralTypeAnnotation", { | ||
enumerable: true, | ||
@@ -142,3 +142,3 @@ get: function get() { | ||
function ExistentialTypeParam() { | ||
function ExistsTypeAnnotation() { | ||
this.token("*"); | ||
@@ -209,6 +209,8 @@ } | ||
function _variance(node) { | ||
if (node.variance === "plus") { | ||
this.token("+"); | ||
} else if (node.variance === "minus") { | ||
this.token("-"); | ||
if (node.variance) { | ||
if (node.variance.kind === "plus") { | ||
this.token("+"); | ||
} else if (node.variance.kind === "minus") { | ||
this.token("-"); | ||
} | ||
} | ||
@@ -336,7 +338,3 @@ } | ||
if (props.length !== 1) { | ||
if (_this.format.flowCommaSeparator) { | ||
_this.token(","); | ||
} else { | ||
_this.semicolon(); | ||
} | ||
_this.token(","); | ||
_this.space(); | ||
@@ -343,0 +341,0 @@ } |
"use strict"; | ||
exports.__esModule = true; | ||
var _getIterator2 = require("babel-runtime/core-js/get-iterator"); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
exports.JSXAttribute = JSXAttribute; | ||
@@ -21,5 +16,2 @@ exports.JSXIdentifier = JSXIdentifier; | ||
exports.JSXEmptyExpression = JSXEmptyExpression; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function JSXAttribute(node) { | ||
@@ -79,3 +71,3 @@ this.print(node.name, node); | ||
this.indent(); | ||
for (var _iterator = node.children, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { | ||
for (var _iterator = node.children, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
@@ -82,0 +74,0 @@ |
@@ -66,8 +66,2 @@ "use strict"; | ||
this.token("*"); | ||
if (node.exported) { | ||
this.space(); | ||
this.word("as"); | ||
this.space(); | ||
this.print(node.exported, node); | ||
} | ||
this.space(); | ||
@@ -74,0 +68,0 @@ this.word("from"); |
"use strict"; | ||
exports.__esModule = true; | ||
exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForAwaitStatement = exports.ForOfStatement = exports.ForInStatement = undefined; | ||
var _getIterator2 = require("babel-runtime/core-js/get-iterator"); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
exports.ThrowStatement = exports.BreakStatement = exports.ReturnStatement = exports.ContinueStatement = exports.ForOfStatement = exports.ForInStatement = undefined; | ||
exports.WithStatement = WithStatement; | ||
@@ -30,4 +25,2 @@ exports.IfStatement = IfStatement; | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function WithStatement(node) { | ||
@@ -116,9 +109,7 @@ this.word("with"); | ||
this.space(); | ||
if (op === "await") { | ||
if (op === "of" && node.await) { | ||
this.word("await"); | ||
this.space(); | ||
op = "of"; | ||
} | ||
this.token("("); | ||
this.print(node.left, node); | ||
@@ -136,3 +127,2 @@ this.space(); | ||
var ForOfStatement = exports.ForOfStatement = buildForXStatement("of"); | ||
var ForAwaitStatement = exports.ForAwaitStatement = buildForXStatement("await"); | ||
@@ -254,3 +244,3 @@ function DoWhileStatement(node) { | ||
function variableDeclarationIdent() { | ||
function variableDeclarationIndent() { | ||
this.token(","); | ||
@@ -263,3 +253,3 @@ this.newline(); | ||
function constDeclarationIdent() { | ||
function constDeclarationIndent() { | ||
this.token(","); | ||
@@ -279,3 +269,3 @@ this.newline(); | ||
if (!t.isFor(parent)) { | ||
for (var _iterator = node.declarations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { | ||
for (var _iterator = node.declarations, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
@@ -302,3 +292,3 @@ | ||
if (hasInits) { | ||
separator = node.kind === "const" ? constDeclarationIdent : variableDeclarationIdent; | ||
separator = node.kind === "const" ? constDeclarationIndent : variableDeclarationIndent; | ||
} | ||
@@ -305,0 +295,0 @@ |
"use strict"; | ||
exports.__esModule = true; | ||
exports.ArrayPattern = exports.ObjectPattern = exports.RestProperty = exports.SpreadProperty = exports.SpreadElement = undefined; | ||
exports.ArrayPattern = exports.ObjectPattern = exports.SpreadElement = undefined; | ||
exports.Identifier = Identifier; | ||
@@ -30,10 +30,2 @@ exports.RestElement = RestElement; | ||
function Identifier(node) { | ||
if (node.variance) { | ||
if (node.variance === "plus") { | ||
this.token("+"); | ||
} else if (node.variance === "minus") { | ||
this.token("-"); | ||
} | ||
} | ||
this.word(node.name); | ||
@@ -48,4 +40,2 @@ } | ||
exports.SpreadElement = RestElement; | ||
exports.SpreadProperty = RestElement; | ||
exports.RestProperty = RestElement; | ||
function ObjectExpression(node) { | ||
@@ -52,0 +42,0 @@ var props = node.properties; |
@@ -6,14 +6,2 @@ "use strict"; | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _possibleConstructorReturn2 = require("babel-runtime/helpers/possibleConstructorReturn"); | ||
var _possibleConstructorReturn3 = _interopRequireDefault(_possibleConstructorReturn2); | ||
var _inherits2 = require("babel-runtime/helpers/inherits"); | ||
var _inherits3 = _interopRequireDefault(_inherits2); | ||
exports.default = function (ast, opts, code) { | ||
@@ -44,7 +32,13 @@ var gen = new Generator(ast, opts, code); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; } | ||
function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; } | ||
var Generator = function (_Printer) { | ||
(0, _inherits3.default)(Generator, _Printer); | ||
_inherits(Generator, _Printer); | ||
function Generator(ast, opts, code) { | ||
(0, _classCallCheck3.default)(this, Generator); | ||
_classCallCheck(this, Generator); | ||
@@ -57,3 +51,3 @@ opts = opts || {}; | ||
var _this = (0, _possibleConstructorReturn3.default)(this, _Printer.call(this, format, map, tokens)); | ||
var _this = _possibleConstructorReturn(this, _Printer.call(this, format, map, tokens)); | ||
@@ -88,3 +82,3 @@ _this.ast = ast; | ||
concise: opts.concise, | ||
quotes: opts.quotes || findCommonStringDelimiter(code, tokens), | ||
quotes: findCommonStringDelimiter(code, tokens), | ||
jsonCompatibleStrings: opts.jsonCompatibleStrings, | ||
@@ -95,4 +89,3 @@ indent: { | ||
base: 0 | ||
}, | ||
flowCommaSeparator: opts.flowCommaSeparator | ||
} | ||
}; | ||
@@ -163,3 +156,3 @@ | ||
function CodeGenerator(ast, opts, code) { | ||
(0, _classCallCheck3.default)(this, CodeGenerator); | ||
_classCallCheck(this, CodeGenerator); | ||
@@ -166,0 +159,0 @@ this._generator = new Generator(ast, opts, code); |
"use strict"; | ||
exports.__esModule = true; | ||
var _getIterator2 = require("babel-runtime/core-js/get-iterator"); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
var _keys = require("babel-runtime/core-js/object/keys"); | ||
var _keys2 = _interopRequireDefault(_keys); | ||
exports.needsWhitespace = needsWhitespace; | ||
@@ -20,3 +11,3 @@ exports.needsWhitespaceBefore = needsWhitespaceBefore; | ||
var _whitespace2 = _interopRequireDefault(_whitespace); | ||
var whitespace = _interopRequireWildcard(_whitespace); | ||
@@ -33,4 +24,2 @@ var _parentheses = require("./parentheses"); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
function expandAliases(obj) { | ||
@@ -48,3 +37,3 @@ var newObj = {}; | ||
for (var _iterator = (0, _keys2.default)(obj), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { | ||
for (var _iterator = Object.keys(obj), _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
@@ -66,3 +55,3 @@ | ||
if (aliases) { | ||
for (var _iterator2 = aliases, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) { | ||
for (var _iterator2 = aliases, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : _iterator2[Symbol.iterator]();;) { | ||
var _ref2; | ||
@@ -92,4 +81,4 @@ | ||
var expandedParens = expandAliases(parens); | ||
var expandedWhitespaceNodes = expandAliases(_whitespace2.default.nodes); | ||
var expandedWhitespaceList = expandAliases(_whitespace2.default.list); | ||
var expandedWhitespaceNodes = expandAliases(whitespace.nodes); | ||
var expandedWhitespaceList = expandAliases(whitespace.list); | ||
@@ -96,0 +85,0 @@ function find(obj, node, parent, printStack) { |
@@ -8,2 +8,3 @@ "use strict"; | ||
exports.ObjectExpression = ObjectExpression; | ||
exports.DoExpression = DoExpression; | ||
exports.Binary = Binary; | ||
@@ -70,2 +71,6 @@ exports.BinaryExpression = BinaryExpression; | ||
function DoExpression(node, parent, printStack) { | ||
return isFirstInStatement(printStack); | ||
} | ||
function Binary(node, parent) { | ||
@@ -72,0 +77,0 @@ if ((t.isCallExpression(parent) || t.isNewExpression(parent)) && parent.callee === node) { |
"use strict"; | ||
exports.__esModule = true; | ||
exports.list = exports.nodes = undefined; | ||
var _map = require("lodash/map"); | ||
@@ -54,3 +57,3 @@ | ||
exports.nodes = { | ||
var nodes = exports.nodes = { | ||
AssignmentExpression: function AssignmentExpression(node) { | ||
@@ -120,3 +123,3 @@ var state = crawl(node.right); | ||
exports.nodes.ObjectProperty = exports.nodes.ObjectTypeProperty = exports.nodes.ObjectMethod = exports.nodes.SpreadProperty = function (node, parent) { | ||
nodes.ObjectProperty = nodes.ObjectTypeProperty = nodes.ObjectMethod = function (node, parent) { | ||
if (parent.properties[0] === node) { | ||
@@ -129,3 +132,3 @@ return { | ||
exports.list = { | ||
var list = exports.list = { | ||
VariableDeclaration: function VariableDeclaration(node) { | ||
@@ -150,3 +153,3 @@ return (0, _map2.default)(node.declarations, "init"); | ||
[type].concat(t.FLIPPED_ALIAS_KEYS[type] || []).forEach(function (type) { | ||
exports.nodes[type] = function () { | ||
nodes[type] = function () { | ||
return amounts; | ||
@@ -153,0 +156,0 @@ }; |
@@ -5,22 +5,2 @@ "use strict"; | ||
var _assign = require("babel-runtime/core-js/object/assign"); | ||
var _assign2 = _interopRequireDefault(_assign); | ||
var _getIterator2 = require("babel-runtime/core-js/get-iterator"); | ||
var _getIterator3 = _interopRequireDefault(_getIterator2); | ||
var _stringify = require("babel-runtime/core-js/json/stringify"); | ||
var _stringify2 = _interopRequireDefault(_stringify); | ||
var _weakSet = require("babel-runtime/core-js/weak-set"); | ||
var _weakSet2 = _interopRequireDefault(_weakSet); | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _find = require("lodash/find"); | ||
@@ -58,2 +38,6 @@ | ||
var _generators = require("./generators"); | ||
var generatorFunctions = _interopRequireWildcard(_generators); | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } } | ||
@@ -63,2 +47,4 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var SCIENTIFIC_NOTATION = /e/i; | ||
@@ -70,3 +56,4 @@ var ZERO_DECIMAL_INTEGER = /\.0+$/; | ||
function Printer(format, map, tokens) { | ||
(0, _classCallCheck3.default)(this, Printer); | ||
_classCallCheck(this, Printer); | ||
this.inForStatementInitCounter = 0; | ||
@@ -79,3 +66,3 @@ this._printStack = []; | ||
this._printAuxAfterOnNextUserNode = false; | ||
this._printedComments = new _weakSet2.default(); | ||
this._printedComments = new WeakSet(); | ||
this._endsWithInteger = false; | ||
@@ -284,3 +271,3 @@ this._endsWithWord = false; | ||
if (!printMethod) { | ||
throw new ReferenceError("unknown node of type " + (0, _stringify2.default)(node.type) + " with constructor " + (0, _stringify2.default)(node && node.constructor.name)); | ||
throw new ReferenceError("unknown node of type " + JSON.stringify(node.type) + " with constructor " + JSON.stringify(node && node.constructor.name)); | ||
} | ||
@@ -527,3 +514,3 @@ | ||
for (var _iterator = comments, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : (0, _getIterator3.default)(_iterator);;) { | ||
for (var _iterator = comments, _isArray = Array.isArray(_iterator), _i = 0, _iterator = _isArray ? _iterator : _iterator[Symbol.iterator]();;) { | ||
var _ref; | ||
@@ -551,2 +538,3 @@ | ||
Object.assign(Printer.prototype, generatorFunctions); | ||
@@ -556,9 +544,2 @@ function commaSeparator() { | ||
this.space(); | ||
} | ||
var _arr = [require("./generators/template-literals"), require("./generators/expressions"), require("./generators/statements"), require("./generators/classes"), require("./generators/methods"), require("./generators/modules"), require("./generators/types"), require("./generators/flow"), require("./generators/base"), require("./generators/jsx")]; | ||
for (var _i2 = 0; _i2 < _arr.length; _i2++) { | ||
var generator = _arr[_i2]; | ||
(0, _assign2.default)(Printer.prototype, generator); | ||
} | ||
module.exports = exports["default"]; | ||
} |
@@ -5,14 +5,4 @@ "use strict"; | ||
var _keys = require("babel-runtime/core-js/object/keys"); | ||
var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; | ||
var _keys2 = _interopRequireDefault(_keys); | ||
var _typeof2 = require("babel-runtime/helpers/typeof"); | ||
var _typeof3 = _interopRequireDefault(_typeof2); | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
var _sourceMap = require("source-map"); | ||
@@ -24,5 +14,7 @@ | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var SourceMap = function () { | ||
function SourceMap(opts, code) { | ||
(0, _classCallCheck3.default)(this, SourceMap); | ||
_classCallCheck(this, SourceMap); | ||
@@ -48,4 +40,4 @@ this._cachedMap = null; | ||
map.setSourceContent(_this._opts.sourceFileName, code); | ||
} else if ((typeof code === "undefined" ? "undefined" : (0, _typeof3.default)(code)) === "object") { | ||
(0, _keys2.default)(code).forEach(function (sourceFileName) { | ||
} else if ((typeof code === "undefined" ? "undefined" : _typeof(code)) === "object") { | ||
Object.keys(code).forEach(function (sourceFileName) { | ||
map.setSourceContent(sourceFileName, code[sourceFileName]); | ||
@@ -95,3 +87,2 @@ }); | ||
exports.default = SourceMap; | ||
module.exports = exports["default"]; | ||
exports.default = SourceMap; |
@@ -5,11 +5,7 @@ "use strict"; | ||
var _classCallCheck2 = require("babel-runtime/helpers/classCallCheck"); | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
var _classCallCheck3 = _interopRequireDefault(_classCallCheck2); | ||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } | ||
var Whitespace = function () { | ||
function Whitespace(tokens) { | ||
(0, _classCallCheck3.default)(this, Whitespace); | ||
_classCallCheck(this, Whitespace); | ||
@@ -95,3 +91,2 @@ this.tokens = tokens; | ||
exports.default = Whitespace; | ||
module.exports = exports["default"]; | ||
exports.default = Whitespace; |
{ | ||
"name": "babel-generator", | ||
"version": "6.23.0", | ||
"version": "7.0.0-alpha.1", | ||
"description": "Turns an AST into code.", | ||
@@ -14,5 +14,4 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>", | ||
"dependencies": { | ||
"babel-messages": "^6.23.0", | ||
"babel-runtime": "^6.22.0", | ||
"babel-types": "^6.23.0", | ||
"babel-messages": "7.0.0-alpha.1", | ||
"babel-types": "7.0.0-alpha.1", | ||
"detect-indent": "^4.0.0", | ||
@@ -25,5 +24,5 @@ "jsesc": "^1.3.0", | ||
"devDependencies": { | ||
"babel-helper-fixtures": "^6.22.0", | ||
"babylon": "^6.11.0" | ||
"babel-helper-fixtures": "7.0.0-alpha.1", | ||
"babylon": "7.0.0-beta.4" | ||
} | ||
} |
@@ -38,5 +38,3 @@ # babel-generator | ||
concise | boolean | `false` | Set to `true` to reduce whitespace (but not as much as `opts.compact`) | ||
quotes | `'single'` or `'double'` | autodetect based on `ast.tokens` | The type of quote to use in the output | ||
filename | string | | Used in warning messages | ||
flowCommaSeparator | boolean | `false` | Set to `true` to use commas instead of semicolons as Flow property separators | ||
jsonCompatibleStrings | boolean | `false` | Set to true to run `jsesc` with "json": true to print "\u00A9" vs. "©"; | ||
@@ -43,0 +41,0 @@ Options for source maps: |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
92283
7
21
2741
1
84
+ Addedbabel-messages@7.0.0-alpha.1(transitive)
+ Addedbabel-types@7.0.0-alpha.1(transitive)
- Removedbabel-runtime@^6.22.0
- Removedbabel-messages@6.23.0(transitive)
- Removedbabel-runtime@6.26.0(transitive)
- Removedbabel-types@6.26.0(transitive)
- Removedcore-js@2.6.12(transitive)
- Removedregenerator-runtime@0.11.1(transitive)
Updatedbabel-messages@7.0.0-alpha.1
Updatedbabel-types@7.0.0-alpha.1