Coder Social home page Coder Social logo

add-func-name's Introduction

add-func-name

Synopsis

Add temp name to anonymous function for debugging.

Motivation

Google Chrome's developer tool is awesome, but it is difficult to find where the closure is created? This tool save your time for reducing memory leak and debugging.

This tool adds names to anonymous functions.

Installation

$ npm install add-func-name

Usage

$ add-func-name [option] input_folder

option

  • -e name, --exclude=name

    Filter file or/and folder by name. You can use this option several times.

  • -o, --output

    Output folder

  • -r, --replace

    Replace exisiting source code.

  • -q, --quiet

    Stop console output

  • -h, --help

    Display help

Usage Sample

$ add-func-name -e node_modules -o sample_output sample

Sample Output

Sample Input

// anonymous immidiate function
(function () {

var express = require('../../');
var app = express();

// anonymous fuction for event handler
app.get('/', function (req, res){
    res.send('Hello World');
});

// anonymous function in object notation
var obj = {
    hello: function () {
        console.log("hello");
    }
};

// anonymous function assigned to variable
var good_morning = function () {
    console.log("good morning");
}

app.listen(3000);
console.log('Express started on port 3000');

})();
'''

### Sample Output

It uses esprima and it removes comment. So resulting files don't have comment.

```js
(function ANONYMOUS_FUNC_0() {
    var express = require('../../');
    var app = express();
    app.get('/', function ANONYMOUS_FUNC_1(req, res) {
        res.send('Hello World');
    });
    var obj = {
            hello: function ANONYMOUS_FUNC_hello_2() {
                console.log('hello');
            }
        };
    var good_morning = function ANONYMOUS_FUNC_good_morning_3() {
        console.log('good morning');
    };
    app.listen(3000);
    console.log('Express started on port 3000');
}());

Development

JSX

Don't be afraid JSX! If you have an experience of JavaScript, you can learn JSX quickly.

  • Static type system and unified class syntax.
  • All variables and methods belong to class.
  • JSX includes optimizer. You don't have to write tricky unreadalbe code for speed.
  • You can use almost all JavaScript API as you know. Some functions become static class functions. See reference.

Setup

To create development environment, call following command:

$ npm install

Repository

Run Test

$ grunt test

Build

# Build application or library for JS project
$ grunt build

# Generate API reference
$ grunt doc

Author

License

GPL-V3

Complete license is written in LICENSE.md.

Thanks

  • esprima
  • escodegen
  • JSX
  • grunt-jsx
  • grunt

add-func-name's People

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.