Skip to content

Instantly share code, notes, and snippets.

@kaichen
Created July 17, 2011 07:34
Show Gist options
  • Select an option

  • Save kaichen/1087314 to your computer and use it in GitHub Desktop.

Select an option

Save kaichen/1087314 to your computer and use it in GitHub Desktop.
window.Utils = class Utils
@className: (obj)->
regex = /^function\s*([^\(]+)/
fnSource = obj.constructor.toString()
regex.exec(fnSource)[1]
@underscore: (word) ->
hanlder = (str, p, offset, s) ->
l = p.toLowerCase()
if offset == 0 then l else "_#{l}"
word.replace(/([A-Z])/g, hanlder)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment