From 0d0d89fd9cb52077e79c39b1c329304176b18abb Mon Sep 17 00:00:00 2001 From: Sebastian McKenzie Date: Wed, 21 Jan 2015 22:41:55 +1100 Subject: [PATCH] better names for property transformers --- ...hod-assignment.js => es5-property.mutators.js} | 13 ++----------- .../transformers/es6-property-name-shorthand.js | 10 ---------- ...property-names.js => es6-property.computed.js} | 0 .../transformers/es6-property.shorthand.js | 15 +++++++++++++++ 4 files changed, 17 insertions(+), 21 deletions(-) rename lib/6to5/transformation/transformers/{es6-property-method-assignment.js => es5-property.mutators.js} (66%) delete mode 100644 lib/6to5/transformation/transformers/es6-property-name-shorthand.js rename lib/6to5/transformation/transformers/{es6-computed-property-names.js => es6-property.computed.js} (100%) create mode 100644 lib/6to5/transformation/transformers/es6-property.shorthand.js diff --git a/lib/6to5/transformation/transformers/es6-property-method-assignment.js b/lib/6to5/transformation/transformers/es5-property.mutators.js similarity index 66% rename from lib/6to5/transformation/transformers/es6-property-method-assignment.js rename to lib/6to5/transformation/transformers/es5-property.mutators.js index 4a740e2f83..9ca360fd94 100644 --- a/lib/6to5/transformation/transformers/es6-property-method-assignment.js +++ b/lib/6to5/transformation/transformers/es5-property.mutators.js @@ -1,16 +1,7 @@ "use strict"; -var nameMethod = require("../helpers/name-method"); -var util = require("../../util"); -var t = require("../../types"); - -exports.Property = function (node, parent, scope, context, file) { - if (!node.method) return; - - node.method = false; - - nameMethod.property(node, file, scope); -}; +var util = require("../../util"); +var t = require("../../types"); exports.ObjectExpression = function (node) { var mutatorMap = {}; diff --git a/lib/6to5/transformation/transformers/es6-property-name-shorthand.js b/lib/6to5/transformation/transformers/es6-property-name-shorthand.js deleted file mode 100644 index 006fc9325b..0000000000 --- a/lib/6to5/transformation/transformers/es6-property-name-shorthand.js +++ /dev/null @@ -1,10 +0,0 @@ -"use strict"; - -var t = require("../../types"); -var _ = require("lodash"); - -exports.Property = function (node) { - if (!node.shorthand) return; - node.shorthand = false; - node.key = t.removeComments(_.clone(node.key)); -}; diff --git a/lib/6to5/transformation/transformers/es6-computed-property-names.js b/lib/6to5/transformation/transformers/es6-property.computed.js similarity index 100% rename from lib/6to5/transformation/transformers/es6-computed-property-names.js rename to lib/6to5/transformation/transformers/es6-property.computed.js diff --git a/lib/6to5/transformation/transformers/es6-property.shorthand.js b/lib/6to5/transformation/transformers/es6-property.shorthand.js new file mode 100644 index 0000000000..9792975d8d --- /dev/null +++ b/lib/6to5/transformation/transformers/es6-property.shorthand.js @@ -0,0 +1,15 @@ +"use strict"; + +var nameMethod = require("../helpers/name-method"); + +exports.Property = function (node, parent, scope, context, file) { + if (node.method) { + node.method = false; + nameMethod.property(node, file, scope); + } + + if (node.shorthand) { + node.shorthand = false; + node.key = t.removeComments(_.clone(node.key)); + } +};