rewrite by coffee-script

rewrite by coffee-script
change wrap function interface.