UNPKG

babel-core

Version:

Turn ES6 code into readable vanilla ES5 with source maps

16 lines (13 loc) 444 B
"use strict"; var t = require("../../../types"); exports.Property = function (node) { var key = node.key; if (t.isLiteral(key) && t.isValidIdentifier(key.value)) { // "foo": "bar" -> foo: "bar" node.key = t.identifier(key.value); node.computed = false; } else if (!node.computed && t.isIdentifier(key) && !t.isValidIdentifier(key.name)) { // default: "bar" -> "default": "bar" node.key = t.literal(key.name); } };