• Stars
    star
    645
  • Rank 67,201 (Top 2 %)
  • Language
    JavaScript
  • License
    Other
  • Created almost 12 years ago
  • Updated almost 5 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

AOP for JS with before, around, on, afterReturning, afterThrowing, after advice, and pointcuts

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:

    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

More Repositories

1

most

Ultra-high performance reactive programming
JavaScript
3,491
star
2

when

A solid, fast Promises/A+ and when() implementation, plus other async goodies.
JavaScript
3,450
star
3

curl

curl.js is small, fast, extensible module loader that handles AMD, CommonJS Modules/1.1, CSS, HTML/text, and legacy scripts.
JavaScript
1,889
star
4

rest

RESTful HTTP client for JavaScript
JavaScript
1,001
star
5

wire

A light, fast, flexible Javascript IOC container
JavaScript
863
star
6

jiff

JSON Patch and diff based on rfc6902
JavaScript
588
star
7

poly

Small, fast, awesome. The only ES5-ish set of polyfills (shims) you can mix-and-match because they're individual modules.
JavaScript
139
star
8

msgs

Message oriented programming
JavaScript
121
star
9

seed

Starter kit for building cujo.js apps
JavaScript
67
star
10

cram

Simple, yet powerful, AMD and CommonJS module bundler.
JavaScript
59
star
11

cola

Extensible, two-way data binding.
JavaScript
41
star
12

promise-perf-tests

(No longer maintained) Basic performance tests for promise implementations
JavaScript
31
star
13

most-w3msg

cujojs/most W3C Messaging - reactive event streams for WebSocket, Worker, EventSource, MessagePort, etc
JavaScript
30
star
14

canhaz

a project and code bootstrapping tool that will save you tons of typing. Stop typing boilerplate, canhaz it instead!
Shell
27
star
15

cujo

The Unframework
24
star
16

cujojs.github.com

The cujojs website
JavaScript
24
star
17

aop

Small AOP lib for JS with before, around, afterReturning, afterThrowing, after advice and a simple API
JavaScript
15
star
18

pile

Simple data structures for JS
JavaScript
10
star
19

robo

A simple, asynchronous finite state machine
JavaScript
8
star
20

most-dom

most.js DOM extras - signals from form values, streams from event delegation, etc.
JavaScript
6
star
21

shim

A collection of UMD modules that shim (aka "polyfill") old environments to support modern (aka "ES5-ish" and "ES6-ish") javascript.
JavaScript
4
star
22

latr

Higher-order promise and async task management modules.
JavaScript
3
star