npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

meld

v1.3.2

Published

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

Downloads

10,766

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:

    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