1 | module.exports =
|
2 | upcase: -> @toUpperCase()
|
3 | downcase: -> @toLowerCase()
|
4 |
|
5 | replaceAll: (val, newVal) ->
|
6 | out = @
|
7 | for x in out
|
8 | out = out.replace val, newVal
|
9 | return out
|
10 |
|
11 | startsWith: (val) -> @indexOf(val) is 0
|
12 | endsWith: (val) ->
|
13 | diff = @length - val.length
|
14 | return diff >= 0 and @indexOf(val, diff) == diff
|
15 | startsWithIgnoreCase: (val) -> @downcase().indexOf(String(val).downcase()) is 0
|
16 | endsWithIgnoreCase: (val) ->
|
17 | diff = @length - val.length
|
18 | return diff >= 0 and @downcase().indexOf(val.downcase(), diff) is diff
|
19 |
|
20 | contains: (val) -> @indexOf(val) > -1
|
21 | containsIgnoreCase: (val) -> @downcase().contains String(val).toLowerCase()
|
22 | equalsIgnoreCase: (val) -> @downcase() is String(val).toLowerCase()
|
23 |
|
24 | strip: -> @trim()
|
25 | lstrip: -> @trimLeft()
|
26 | rstrip: -> @trimRight()
|
27 |
|
28 | for key of module.exports
|
29 | Object.defineProperty String.prototype, key, value: module.exports[key]
|