A functional rules system for javascript