Clean up for coffeescript convention

This commit is contained in:
Tery Lim 2014-07-04 22:23:47 +08:00
parent 2855d2a402
commit 329f0e7e22

View file

@ -1,5 +1,5 @@
module.exports.clone = (obj) ->
return obj if obj is null or typeof (obj) isnt "object"
return obj if obj is null or typeof (obj) isnt 'object'
temp = obj.constructor()
for key of obj
temp[key] = module.exports.clone(obj[key])
@ -25,7 +25,7 @@ module.exports.normalizeFunc = (func_thing, object) ->
if _.isString(func_thing)
func = object[func_thing]
if not func
console.error("Could not find method", func_thing, 'in object', @)
console.error "Could not find method #{func_thing} in object #{@}"
return => null # always return a func, or Mediator will go boom
func_thing = func
return func_thing
@ -36,7 +36,7 @@ module.exports.hexToHSL = (hex) ->
hexToR = (h) -> parseInt (cutHex(h)).substring(0, 2), 16
hexToG = (h) -> parseInt (cutHex(h)).substring(2, 4), 16
hexToB = (h) -> parseInt (cutHex(h)).substring(4, 6), 16
cutHex = (h) -> (if (h.charAt(0) is "#") then h.substring(1, 7) else h)
cutHex = (h) -> (if (h.charAt(0) is '#') then h.substring(1, 7) else h)
module.exports.hslToHex = (hsl) ->
'#' + (toHex(n) for n in hslToRgb(hsl...)).join('')
@ -57,10 +57,10 @@ module.exports.i18n = (say, target, language=me.lang(), fallback='en') ->
if target of locale
result = locale[target]
else continue
return result if localeName == language
generalResult = result if localeName == generalName
fallbackResult = result if localeName == fallback
fallforwardResult = result if localeName.indexOf(language) == 0 and not fallforwardResult?
return result if localeName is language
generalResult = result if localeName is generalName
fallbackResult = result if localeName is fallback
fallforwardResult = result if localeName.indexOf(language) is 0 and not fallforwardResult?
return generalResult if generalResult?
return fallforwardResult if fallforwardResult?