- ARCHIVE / JavaScript
- Using ChainCollector to respond to Ajax calls
Saq made a couple of comments on my ChainCollector article about how to queue up functions to respond to Ajax calls, and whether I could write something up to shed a bit of light on how this might be done. Today, I’m going to implement some methods that allow to GET from/POST to a URL, [...]
- PackR, now with class methods
Quick note: at the suggestion of Aman Gupta, PackR now supports Packr.pack, Packr.minify and Packr.pack_file as class methods, so you don’t need to create an instance of PackR before doing anything. Originally, I wanted PackR’s design to mirror the JavaScript version to make maintainance easier, but these methods are a tiny addition so I’m happy [...]
- Methodize and functionize
Though the API docs seem to make no mention of it, there is this little gem sitting in Prototype 1.6.0:
Function.prototype.methodize = function() {
if (this._methodized) return this._methodized;
var __method = this;
return this._methodized = function() {
return __method.apply(null, [this].concat($A(arguments)));
};
};
What that does is it returns a new function [...] - Reiterate 1.3
Tiny update: after adding 16 characters (”this._object || “), Reiterate is now compatible with Prototype 1.6.0’s revised Hash API. Also, the gzipped copy is now even smaller, thanks to a different compression strategy. Essentially, when using Packer (or PackR for that matter), using ’shrink variables’ plus gzip compression will result in the smallest an fastest-to-execute [...]
- Where’s my inheritance?
Update: from what I can gather from going through the source code, $super in Prototype actually refers to the method in the parent class, rather than the old method in the current class. My point about the other libraries mentioned below stands, though. Also, my apologies to Dan, whom I cornered at @media Ajax and [...]
- JS.Class updates
Yes, it only came out a couple days ago, but it’s a 0.9.x release, so it’s still being developed. If you downloaded JS.Class over the last couple days, I strongly recommend you upgrade to the latest version.
First off, it improves performance substantially over the initial release by inspecting method definitions to find out if they [...] - Announcement: JS.Class
After mentioning Prototype’s inheritance model the other day, one rather important thing struck me about it. I was going to borrow their model for some of my own work when I realised that, if you use Prototype’s $super feature, your code will break if you compress it using a variable-shrinking algorithm (all the decent compressors [...]
- Prototype’s Function#wrap
So Prototype 1.6 has finally hit the streets, and it looks to be a very nice piece of work. Though I’m no longer using Prototype at my day job (we use YUI, plus a layer of syntactic sugar that I’m in the process of writing), I’m interested to see what is possible with the JavaScript [...]
- Asynchronous function chaining in JavaScript
Update, 25 February 2008: This class is now available as part of JS.Class (it’s called MethodChain now). It also forms a key part of Ojay, an expressive wrapper for YUI.
Update, 12 Dec 2007: Another implementation change. A blank ChainCollector instance now has the following properties: then, and, ____ (formerly __enqueue) and fire. The method queue [...] - Emulating JavaScript’s String#replace in Ruby
Update: turns out this is a lot easier than the method presented below: see Christoffer Sawicki’s implementation. Consider my method an example of what happens when you’re trying to port features from one language to another and end up looking in all the wrong places for a solution.
I know what you’re thinking: we already have [...]