Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 240025
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T20:37:58+00:00 2026-05-11T20:37:58+00:00

Which Javascript AOP library do you use, and what are its key features ?

  • 0

Which Javascript AOP library do you use, and what are its key features ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T20:37:58+00:00Added an answer on May 11, 2026 at 8:37 pm

    Here is what I found until now :

    • dotvoid‘s implementation, clean syntax, nice to use, the article is a good introduction on why/how to use the given code, supports introductions, but is bugged,
    • Dojo has what seems to be a good built-in implementation in dojox, here is a nice introduction on how to use it,
    • there is a plugin for jQuery, jquery-aop, with a rougher syntax, passing objects and methods in a javascript object,
    • AspectJS with an even rougher syntax (need to pass type of pointcut as arguments to a single method)

    Like I said, dotvoid’s code did not work.
    I corrected a little and got something that seems to work better :

    InvalidAspect = new Error("Missing a valid aspect. Aspect is not a function.");
    InvalidObject = new Error("Missing valid object or an array of valid objects.");
    InvalidMethod = new Error("Missing valid method to apply aspect on.");
    
    function doBefore(beforeFunc,func){
        return function(){
            beforeFunc.apply(this,arguments);
            return func.apply(this,arguments);
        };  
    }
    
    function doAfter(func, afterFunc){
        return function(){
            var res = func.apply(this,arguments);
            afterFunc.apply(this,arguments);
            return res;   
        };
    }
    
    Aspects = function(){};
    Aspects.prototype={
        _addIntroduction : function(intro, obj){
             for (var m in intro.prototype) {
                  obj.prototype[m] = intro.prototype[m];
                }
            },
    
        addIntroduction : function(aspect, objs){
            var oType = typeof(objs);
    
            if (typeof(aspect) != 'function')
            throw(InvalidAspect);
    
            if (oType == 'function'){
                this._addIntroduction(aspect, objs);
            }
            else if (oType == 'object'){
                for (var n = 0; n < objs.length; n++){
                    this._addIntroduction(aspect, objs[n]);
                }
            }
            else{
                throw InvalidObject;
            }
        },
    
        addBefore : function(aspect, obj, funcs){
              var fType = typeof(funcs);
    
              if (typeof(aspect) != 'function')
                throw(InvalidAspect);
    
              if (fType != 'object')
                funcs = Array(funcs);
    
              for (var n = 0; n < funcs.length; n++){
                var fName = funcs[n];
                var old = obj.prototype[fName];
    
                if (!old)
                  throw InvalidMethod;
    
                var res = doBefore(aspect,old)
                obj.prototype[fName] = res;
            }
        },
    
        addAfter : function(aspect, obj, funcs) {
              if (typeof(aspect) != 'function')
                throw InvalidAspect;
    
              if (typeof(funcs) != 'object')
                funcs = Array(funcs);
    
              for (var n = 0; n < funcs.length; n++)
              {
                var fName = funcs[n];
                var old = obj.prototype[fName];
    
                if (!old)
                  throw InvalidMethod;
    
                var res = doAfter(old,aspect);
                obj.prototype[fName] = res;
              }
            },
    
        addAround : function(aspect, obj, funcs){
              if (typeof(aspect) != 'function')
                throw InvalidAspect;
    
              if (typeof(funcs) != 'object')
                funcs = Array(funcs);
    
              for (var n = 0; n < funcs.length; n++)
              {
                var fName = funcs[n];
                var old = obj.prototype[fName];
                if (!old)
                  throw InvalidMethod;
    
                var res = aspect(old);
                obj.prototype[fName] = res;
              }
    
              return true;
            }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 119k
  • Answers 119k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Assuming this is a standard Apache log, and assuming you… May 11, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer From Wikipedia: In software, a stack overflow occurs when too… May 11, 2026 at 11:49 pm
  • Editorial Team
    Editorial Team added an answer Option 1: c:...>dumpbin /summary whatever.exe Look for a ".textbss" section.… May 11, 2026 at 11:49 pm

Related Questions

Which javascript major modes exist in Emacs, and what are their key-features ?
Duplicate: Best javascript compressor Which javascript minification library produces better results? What is the
I have a sample application which has something like below. <a href=javascript:{} id=anchorlnk>Go</a> which
Possible Duplicates: How to determine which html page element has focus? How do I

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.