Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

meld

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

meld

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

  • 1.1.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1.4K
increased by362.18%
Maintainers
1
Weekly downloads
 
Created
Source

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

Changelog

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

0.8.0

  • 1.0.0 Release Candidate 1
  • Documentation! Check out the new reference and api docs.
  • Deprecated browser global - meld.js will drop support for browser global for 1.0.0 and will support modular environments only.

0.7.2

  • Fix for context when advising constructors: this is now the constructed instance in all advice functions.

0.7.1

  • Fix for global name when using meld as a browser global. Thanks @scothis
  • Update unit tests to run in browser using buster server, in addition to node. Thanks again, @scothis :)

0.7.0

  • Advice can be applied directly to functions without a context.
  • Advice can be applied to constructors.
  • joinpoint.proceed() can be called multiple times. This makes it possible to implement "retry" types of advice.

0.6.0

0.5.4

  • Optimizations to run time advice invocation, especially around advice
  • Fix for passing new args to joinpoint.proceed() in around advice
  • Added joinpoint.proceedApply(array) for proceeding and supplying new arguments as an array
  • Ported unit tests to BusterJS

0.5.3

  • First official release as part of cujojs
  • Minor doc and package.json tweaks

0.5.2

  • Revert to larger, more builder-friendly module boilerplate. No functional change.

0.5.1

  • Minor corrections and updates to package.json

0.5.0

  • Rewritten Advisor that allows entire aspects to be unwoven (removed) easily.

Beers to:

Keywords

FAQs

Package last updated on 18 Dec 2012

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc