var es = require("../es");

function Negate(transform, node) {
    var expr = transform(node.expr);
    if (typeof node.expr.data === "number") {
        var literal = es.Literal(node.loc, node.expr.data);
        return es.UnaryExpression(node.loc, true, "-", literal);
    } else {
        var negate = es.Identifier(node.loc, "$negate");
        return es.CallExpression(null, negate, [expr]);
    }
}

module.exports = Negate;

var es = require("../es");

function Negate(transform, node) {
    var expr = transform(node.expr);
    if (node.expr.type === "Number") {
        return es.UnaryExpression(node.loc, true, "-", transform(node.expr));
    } else {
        var negate = es.Identifier(node.loc, "$negate");
        return es.CallExpression(null, negate, [expr]);
    }
}

module.exports = Negate;

Use proper type checking and transform function
Use proper type checking and transform function

As per Brians requests
