public
Description: JavaScript utilities for Metaobject Programming
Homepage:
Clone URL: git://github.com/osteele/mop-js.git
mop-js /
name age message
file .gitmodules Sun Apr 13 04:25:26 -0700 2008 add jsspec as submodule [osteele]
file CHANGES Fri Apr 18 21:07:36 -0700 2008 added MOP.{Class,Object}.* Moved MOP.delegate ... [osteele]
file MIT-LICENSE Fri Apr 04 15:25:44 -0700 2008 initial [osteele]
file README Loading commit data...
directory examples/
submodule jsspec - f5758f9 Sun Apr 13 04:25:26 -0700 2008 add jsspec as submodule [osteele]
directory lib/
directory specs/ Fri Apr 18 21:07:36 -0700 2008 added MOP.{Class,Object}.* Moved MOP.delegate ... [osteele]
README
== JavaScript MOP Utilities

Defines some utilities for JavaScript metaprogramming:

  MOP.delegate(target, propertyName, methods)
    For each name in `methods`, defines a method on `target` with this
    name, that delegates to the method of the `propertyName` property
    of `target` with the same name.

And these for asynchronous metaprogramming:

  new MOP.MethodReplacer(object, methods)
    When a new MethodReplacer is constructed, it replaces each method
    on `object` by the method in `methods` with the same key value, if
    such a method exists.  A MethodReplacer has a single method,
    `restore`, which restores each method to its pre-replacement
    value.

  new MOP.QueueBall(object, methodNames)
    When a new QueueBall is constructed, it replaces each method named
    by `methodNames` with a method that enqueues the method call (the
    name of the method and its arguments).  A QueueBall has a single
    method, `replayMethodCalls`, which plays back the method calls and
    restores the methods.

  MOP.withMethodOverridesCallback(object, methods, fn)
    Calls `fn` on `object`, within a dynamic scope within which the
    methods in `methods` have temporarily replaced the like-named
    methods on `object`.  The scope is terminated by the argument to
    the call to `fn`; this argument should be treated as a
    continuation, and restores the methods.

  MOP.withDeferredMethods(object, methodNames, fn)
    Calls `fn` on `object`, within a dynamic scope within which the
    methods in `methodNames` have been enqueued.  The scope is
    terminated by the argument to the call to `fn`; this argument
    should be treated as a continuation, and ends the queue, replaying
    the methods.


See the specs for examples.


== License

Copyright 2007-2008 by Oliver Steele.  Available under the MIT License.