Showing 179 scripts

Sort by name or size

Reiterate

Reiterate

If you’re familiar with Ruby and Rails, you probably know all about Symbol#to_proc and Methodphitamine. I wanted some similar goodness for Prototype, so I could stop writing

var value = radioGroup.find(function(radio) {
  return radio.checked;
}).value;

var divs = someDivs.findAll(function(div) {
  return div.hasClassName('myClass') 
    && div.visible();
});
and instead write

var value = radioGroup.find('checked').value;

var divs = someDivs.findAll({
  hasClassName: 'myClass', 
  visible: true
});
So I went about writing it. It started off with a simple patch over at Rails Trac that extended the idea behind Enumerable#pluck to lots of other methods, but then I got carried away. You can now use strings, arrays and hashes instead of iterator functions to make your code more readable.
Website:
Reiterate
Author:
James Colgan
Size:
5 KB
Last modified:
11/30/2007
License:
n/a
Tags:
syntactic sugar
Rating:
2
(2/5 from 1 vote)
Your rating:
Please sign in or register to rate this script
Select multiple tags with Ctrl+click (Cmd+click on Mac)

Found a bug or have a suggestion?Let us know

bitsonnet corp · © 2007-2014 · all rights reserved

Sign In / Register / Forgot password