Google Groups Home
Help | Sign in
[467] I started on this a while ago.
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  1 message - Collapse all
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
ca...@geeknest.com  
View profile
 More options Dec 20 2005, 6:29 pm
From: ca...@geeknest.com
Date: Tue, 20 Dec 2005 18:29:01 -0500 (EST)
Local: Tues, Dec 20 2005 6:29 pm
Subject: [svn openjsan.org] [467] I started on this a while ago.
Revision: 467
Author:   theory
Date:     2005-12-20 18:28:55 -0500 (Tue, 20 Dec 2005)

Log Message:
-----------
I started on this a while ago. I dunno if I will ever release it, but at least
now it is here so that I can hack on it in the future if I want to.

Added Paths:
-----------
    users/theory/Method/
    users/theory/Method/trunk/
    users/theory/Method/trunk/lib/
    users/theory/Method/trunk/lib/Method.js
Added: users/theory/Method/trunk/lib/Method.js
===================================================================
--- users/theory/Method/trunk/lib/Method.js     2005-10-25 17:27:15 UTC (rev 466)
+++ users/theory/Method/trunk/lib/Method.js     2005-12-20 23:28:55 UTC (rev 467)
@@ -0,0 +1,59 @@
+Method = function () {};
+
+/*
+
+=head2 Method.bind( object )
+
+The C<bind()> function provides the ability ability to create a closure over a
+method useful for passing to C<setTimeout()>.
+
+  var obj = new Some.Class();
+
+  var closure = Method.bind(obj.someMethod, obj);
+  window.setTimeout( closure, 10 );
+
+  window.setTimeout(object.someMethodbind.bind(obj));
+  window.setTimeout(function () { obj.someMethod() });
+
+=cut
+
+*/
+
+Method.closure = function (fn, obj) {
+    return function () { fn.apply(obj, arguments) };
+};
+
+Method.bind = Method.closure;
+
+/*
+
+=head2 Method.continuation( object )
+
+The C<continuation()> function provides the ability ability to create a
+continuation over a method. This can be useful if you need to pass the same
+arguments to a method call over and over again.
+
+  var obj = new Some.Class();
+
+  var cont = Method.continuation(obj.someMethod, obj, 1, 2, 3);
+  cont(4, 5); // Calls obj.someMethod(1, 2, 3, 4, 5);
+
+=cut
+
+*/
+
+Method.continuation = function (fn, obj) {
+    var args = [];
+    for (var i = 2; i < arguments.length; i++) {
+        args.push(arguments[i]);
+    }
+    return function () {
+        var pass = args.slice(0, args.length);
+        for (var j = 0; j < arguments.length; j++) {
+            pass.push(arguments[j]);
+        }
+        fn.apply(obj, pass);
+    };
+}
+
+// PHP: Need shared library built.
\ No newline at end of file


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google