File: build/lib/squeeze-more.js

Recommend this page to a friend!
  Classes of Emil Kilhage  >  class.js  >  build/lib/squeeze-more.js  >  Download  
File: build/lib/squeeze-more.js
Role: Auxiliary script
Content type: text/plain
Description: Auxiliary script
Class: class.js
Create classes with Node.js, jQuery and JavaScript
Author: By
Last change: Update of build/lib/squeeze-more.js
Date: 1 month ago
Size: 742 bytes
 

Contents

Class file image Download
var jsp = require("./parse-js"),
    pro = require("./process"),
    slice = jsp.slice,
    member = jsp.member,
    PRECEDENCE = jsp.PRECEDENCE,
    OPERATORS = jsp.OPERATORS;

function ast_squeeze_more(ast) {
        var w = pro.ast_walker(), walk = w.walk;
        return w.with_walkers({
                "call": function(expr, args) {
                        if (expr[0] == "dot" && expr[2] == "toString" && args.length == 0) {
                                // foo.toString()  ==>  foo+""
                                return [ "binary", "+", expr[1], [ "string", "" ]];
                        }
                }
        }, function() {
                return walk(ast);
        });
};

exports.ast_squeeze_more = ast_squeeze_more;