Skip to content
Toggle navigation
Toggle navigation
This project
Loading...
Sign in
brainfood
/
rivets
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Graphs
Network
Create a new issue
Commits
Issue Boards
Files
Commits
Network
Compare
Branches
Tags
3e12fd20
authored
2012-07-10 00:09:56 -0400
by
Chad Hietala
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
Added polyfills for Array::map and String::trim
1 parent
4f048110
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
24 additions
and
0 deletions
src/rivets.coffee
src/rivets.coffee
View file @
3e12fd2
...
...
@@ -6,6 +6,30 @@
# The Rivets namespace.
Rivets
=
{}
# Polyfill For String::trim
unless
String
::
trim
String
::
trim
=
->
return
@
.
replace
(
/^\s\*/
,
''
).
replace
(
/\s\s*$/
,
''
)
# Polyfill For Array::map
unless
Array
::
map
Array
::
map
=
(
callback
)
->
if
this
is
null
throw
new
TypeError
"Can't convert
#{
this
}
to object"
O
=
Object
(
this
)
len
=
O
.
length
>>>
0
throw
new
TypeError
"
#{
callback
}
is not a function"
unless
typeof
callback
is
'function'
T
=
arguments
[
1
]
A
=
new
Array
(
len
)
k
=
0
;
while
k
<
len
A
[
k
]
=
callbackfn
.
call
(
T
,
O
[
k
],
k
,
O
)
if
k
of
O
k
++
return
A
# A single binding between a model attribute and a DOM element.
class
Rivets
.
Binding
# All information about the binding is passed into the constructor; the DOM
...
...
Please
register
or
sign in
to post a comment