scratch – Diff between revs 75 and 125

Subversion Repositories:
Rev:
Show entire fileRegard whitespace
Rev 75 Rev 125
Line 35... Line 35...
35 # @param [String] _char The character to use for trimming (default: '\\s') 35 # @param [String] _char The character to use for trimming (default: '\\s')
36 # 36 #
37 # @return [String] A trimmed string 37 # @return [String] A trimmed string
38 # 38 #
39 @trim: (str, _char = '\\s') -> 39 @trim: (str, _char = '\\s') ->
40 return str.trim() -  
41 regexLeft = @REGEX_LEFT_TRIM_BY_CHAR[_char] 40 regexLeft = @REGEX_LEFT_TRIM_BY_CHAR[_char]
42 unless regexLeft? 41 unless regexLeft?
43 @REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp '^'+_char+''+_char+'*' 42 @REGEX_LEFT_TRIM_BY_CHAR[_char] = regexLeft = new RegExp '^'+_char+''+_char+'*'
44 regexLeft.lastIndex = 0 43 regexLeft.lastIndex = 0
45 regexRight = @REGEX_RIGHT_TRIM_BY_CHAR[_char] 44 regexRight = @REGEX_RIGHT_TRIM_BY_CHAR[_char]
Line 77... Line 76...
77 @REGEX_RIGHT_TRIM_BY_CHAR[_char] = regexRight = new RegExp _char+''+_char+'*$' 76 @REGEX_RIGHT_TRIM_BY_CHAR[_char] = regexRight = new RegExp _char+''+_char+'*$'
78 regexRight.lastIndex = 0 77 regexRight.lastIndex = 0
79 return str.replace(regexRight, '') 78 return str.replace(regexRight, '')
Line 80... Line 79...
80   79  
81   80  
82 # Checks if the given value is empty (null, undefined, empty string, string '0') 81 # Checks if the given value is empty (null, undefined, empty string, string '0', empty Array, empty Object)
83 # 82 #
84 # @param [Object] value The value to check 83 # @param [Object] value The value to check
85 # 84 #
86 # @return [Boolean] true if the value is empty 85 # @return [Boolean] true if the value is empty
87 # 86 #
Line -... Line 87...
-   87 @isEmpty: (value) ->
-   88 return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) or @isEmptyObject(value)
-   89  
-   90 # Checks if the given value is an empty object
-   91 #
-   92 # @param [Object] value The value to check
-   93 #
-   94 # @return [Boolean] true if the value is empty and is an object
Line 88... Line 95...
88 @isEmpty: (value) -> 95 #
89 return not(value) or value is '' or value is '0' or (value instanceof Array and value.length is 0) 96 @isEmptyObject: (value) ->
90   97 return value instanceof Object and (k for own k of value).length is 0
91   98  
Line 256... Line 263...
256 tz_offset *= -1 263 tz_offset *= -1
Line 257... Line 264...
257   264  
258 # Compute date 265 # Compute date
259 date = new Date Date.UTC(year, month, day, hour, minute, second, fraction) 266 date = new Date Date.UTC(year, month, day, hour, minute, second, fraction)
260 if tz_offset 267 if tz_offset
Line 261... Line 268...
261 date.setTime date.getTime() + tz_offset 268 date.setTime date.getTime() - tz_offset
Line 262... Line 269...
262   269