MCPcopy Index your code
hub / github.com/cujojs/meld

github.com/cujojs/meld @1.3.2

Chat with this repo
repository ↗ · DeepWiki ↗ · release 1.3.2 ↗ · + Follow
45 symbols 79 edges 20 files 10 documented · 22% 1 cross-repo links
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

Build Status

Aspect Oriented Programming for Javascript. It allows you to change the behavior of, or add behavior to methods and functions (including constructors) non-invasively.

As a simple example, instead of changing code, you can use meld to log the result of myObject.doSomething:

var myObject = {
    doSomething: function(a, b) {
        return a + b;
    }
};

// Call a function after myObject.doSomething returns
var remover = meld.after(myObject, 'doSomething', function(result) {
    console.log('myObject.doSomething returned: ' + result);
});

myObject.doSomething(1, 2); // Logs: "myObject.doSomething returned: 3"

remover.remove();

myObject.doSomething(1, 2); // Nothing logged

Docs

Quick Start

AMD

  1. Get it using one of the following

    1. yeoman install meld, or
    2. bower install meld, or
    3. git clone https://github.com/cujojs/meld, or
    4. git submodule add https://github.com/cujojs/meld
  2. Configure your loader with a package:

    js packages: [ { name: 'meld', location: 'path/to/meld', main: 'meld' }, // ... other packages ... ]

  3. define(['meld', ...], function(meld, ...) { ... }); or require(['meld', ...], function(meld, ...) { ... });

Node

  1. npm install meld
  2. var meld = require('meld');

RingoJS

  1. ringo-admin install cujojs/meld
  2. var meld = require('meld');

Running the Unit Tests

Install buster.js

npm install -g buster

Run unit tests in Node:

buster test

What's New

1.3.0

  • meld() is now a function that adds aspects.
    • DEPRECATED: meld.add(). Use meld() instead.

1.2.2

  • Remove stray console.log.

1.2.1

  • Fix for IE8-specific issue with meld's internal use of Object.defineProperty.
  • Internally shim Object.create if not available to so that meld no longer requires an Object.create shim to advise constructors in pre-ES5 environments.

1.2.0

  • meld.joinpoint() - Access the current joinpoint from any advice type.
  • Bundled aspects:
    • trace: trace method call entry/return/throw
    • memoize: simple memoization for methods and functions
    • cache: configurable caching aspect to do more than simple memoization

1.1.0

  • Advice can be applied directly to methods on a function.
  • Removed undocumented behavior that implicitly adds constructor prototype advice: to advise a prototype, pass the prototype as the advice target.

1.0.0

See the full Changelog here

References

Core symbols most depended-on inside this repo

meld
called by 19
meld.js
adviceApi
called by 6
meld.js
addAspectToMethod
called by 4
meld.js
joinpoint
called by 3
meld.js
indent
called by 3
aspect/trace.js
callAfter
called by 2
meld.js
callNext
called by 2
meld.js
proceed
called by 2
meld.js

Shape

Function 45

Languages

TypeScript100%

Modules by API surface

meld.js26 symbols
test/constructors.js5 symbols
test/functions.js2 symbols
test/remove.js1 symbols
test/prototype.js1 symbols
test/on.js1 symbols
test/joinpoint.js1 symbols
test/before.js1 symbols
test/aspect/cache-test.js1 symbols
test/around.js1 symbols
test/afterThrowing.js1 symbols
test/afterReturning.js1 symbols

Used by 1 indexed graphs manifest dependencies, hub-wide

For agents

$ claude mcp add meld \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact