Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
R
rsvp.js
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boris Kocherov
rsvp.js
Commits
1d3b8e6c
Commit
1d3b8e6c
authored
Dec 30, 2012
by
tomhuda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Update to latest Promises/A+ spec
parent
f3efd67e
Changes
7
Hide whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
51 additions
and
28 deletions
+51
-28
Rakefile
Rakefile
+6
-6
browser/rsvp.amd.js
browser/rsvp.amd.js
+6
-3
browser/rsvp.js
browser/rsvp.js
+6
-3
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
lib/rsvp.js
lib/rsvp.js
+9
-5
tests/index.html
tests/index.html
+14
-5
tests/rsvp.js
tests/rsvp.js
+9
-5
No files found.
Rakefile
View file @
1d3b8e6c
...
...
@@ -46,20 +46,20 @@ task :push => :dist do
sh
"git commit -m 'Updates build artifacts'"
end
file
"promise-tests"
do
sh
"git clone https://github.com/
domenic/promise-tests.git
"
file
"promise
s
-tests"
do
sh
"git clone https://github.com/
promises-aplus/promises-tests
"
end
task
:update_tests
=>
"promise-tests"
do
cd
"promise-tests"
do
task
:update_tests
=>
"promise
s
-tests"
do
cd
"promise
s
-tests"
do
sh
"git pull"
sh
"npm install"
end
end
task
:test
=>
[
:update_tests
,
"tests/rsvp.js"
]
do
cd
"promise-tests"
do
sh
"node ./lib/cli.js
all
../tests/test-adapter.js"
cd
"promise
s
-tests"
do
sh
"node ./lib/cli.js ../tests/test-adapter.js"
end
end
...
...
browser/rsvp.amd.js
View file @
1d3b8e6c
...
...
@@ -148,16 +148,19 @@ define("rsvp",
var
noop
=
function
()
{};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
value
,
error
;
var
value
,
error
,
succeeded
,
failed
;
if
(
callback
)
{
try
{
value
=
callback
(
event
.
detail
);
succeeded
=
true
;
}
catch
(
e
)
{
failed
=
true
;
error
=
e
;
}
}
else
{
value
=
event
.
detail
;
succeeded
=
true
;
}
if
(
value
instanceof
Promise
)
{
...
...
@@ -166,9 +169,9 @@ define("rsvp",
},
function
(
error
)
{
promise
.
reject
(
error
);
});
}
else
if
(
callback
&&
value
)
{
}
else
if
(
callback
&&
succeeded
)
{
promise
.
resolve
(
value
);
}
else
if
(
error
)
{
}
else
if
(
failed
)
{
promise
.
reject
(
error
);
}
else
{
promise
[
type
](
value
);
...
...
browser/rsvp.js
View file @
1d3b8e6c
...
...
@@ -146,16 +146,19 @@
var
noop
=
function
()
{};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
value
,
error
;
var
value
,
error
,
succeeded
,
failed
;
if
(
callback
)
{
try
{
value
=
callback
(
event
.
detail
);
succeeded
=
true
;
}
catch
(
e
)
{
failed
=
true
;
error
=
e
;
}
}
else
{
value
=
event
.
detail
;
succeeded
=
true
;
}
if
(
value
instanceof
Promise
)
{
...
...
@@ -164,9 +167,9 @@
},
function
(
error
)
{
promise
.
reject
(
error
);
});
}
else
if
(
callback
&&
value
)
{
}
else
if
(
callback
&&
succeeded
)
{
promise
.
resolve
(
value
);
}
else
if
(
error
)
{
}
else
if
(
failed
)
{
promise
.
reject
(
error
);
}
else
{
promise
[
type
](
value
);
...
...
browser/rsvp.min.js
View file @
1d3b8e6c
(
function
(
e
){
"
use strict
"
;
function
v
(
e
,
t
){
r
.
async
(
function
(){
e
.
trigger
(
"
promise:resolved
"
,{
detail
:
t
}),
e
.
isResolved
=!
0
,
e
.
resolvedValue
=
t
})}
function
m
(
e
,
t
){
r
.
async
(
function
(){
e
.
trigger
(
"
promise:failed
"
,{
detail
:
t
}),
e
.
isRejected
=!
0
,
e
.
rejectedValue
=
t
})}
var
t
=
typeof
window
!=
"
undefined
"
?
window
:{},
n
=
t
.
MutationObserver
||
t
.
WebKitMutationObserver
,
r
,
i
;
if
(
typeof
process
!=
"
undefined
"
&&
{}.
toString
.
call
(
process
)
===
"
[object process]
"
)
i
=
function
(
e
,
t
){
process
.
nextTick
(
function
(){
e
.
call
(
t
)})};
else
if
(
n
){
var
s
=
[],
o
=
new
n
(
function
(){
var
e
=
s
.
slice
();
s
=
[],
e
.
forEach
(
function
(
e
){
var
t
=
e
[
0
],
n
=
e
[
1
];
t
.
call
(
n
)})}),
u
=
document
.
createElement
(
"
div
"
);
o
.
observe
(
u
,{
attributes
:
!
0
}),
i
=
function
(
e
,
t
){
s
.
push
([
e
,
t
]),
u
.
setAttribute
(
"
drainQueue
"
,
"
drainQueue
"
)}}
else
i
=
function
(
e
,
t
){
setTimeout
(
function
(){
e
.
call
(
t
)},
1
)};
var
a
=
function
(
e
,
t
){
this
.
type
=
e
;
for
(
var
n
in
t
){
if
(
!
t
.
hasOwnProperty
(
n
))
continue
;
this
[
n
]
=
t
[
n
]}},
f
=
function
(
e
,
t
){
for
(
var
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
if
(
e
[
n
][
0
]
===
t
)
return
n
;
return
-
1
},
l
=
function
(
e
){
var
t
=
e
.
_promiseCallbacks
;
return
t
||
(
t
=
e
.
_promiseCallbacks
=
{}),
t
},
c
=
{
mixin
:
function
(
e
){
return
e
.
on
=
this
.
on
,
e
.
off
=
this
.
off
,
e
.
trigger
=
this
.
trigger
,
e
},
on
:
function
(
e
,
t
,
n
){
var
r
=
l
(
this
),
i
,
s
;
e
=
e
.
split
(
/
\s
+/
),
n
=
n
||
this
;
while
(
s
=
e
.
shift
())
i
=
r
[
s
],
i
||
(
i
=
r
[
s
]
=
[]),
f
(
i
,
t
)
===-
1
&&
i
.
push
([
t
,
n
])},
off
:
function
(
e
,
t
){
var
n
=
l
(
this
),
r
,
i
,
s
;
e
=
e
.
split
(
/
\s
+/
);
while
(
i
=
e
.
shift
()){
if
(
!
t
){
n
[
i
]
=
[];
continue
}
r
=
n
[
i
],
s
=
f
(
r
,
t
),
s
!==-
1
&&
r
.
splice
(
s
,
1
)}},
trigger
:
function
(
e
,
t
){
var
n
=
l
(
this
),
r
,
i
,
s
,
o
,
u
;
if
(
r
=
n
[
e
])
for
(
var
f
=
0
,
c
=
r
.
length
;
f
<
c
;
f
++
)
i
=
r
[
f
],
s
=
i
[
0
],
o
=
i
[
1
],
typeof
t
!=
"
object
"
&&
(
t
=
{
detail
:
t
}),
u
=
new
a
(
e
,
t
),
s
.
call
(
o
,
u
)}},
h
=
function
(){
this
.
on
(
"
promise:resolved
"
,
function
(
e
){
this
.
trigger
(
"
success
"
,{
detail
:
e
.
detail
})},
this
),
this
.
on
(
"
promise:failed
"
,
function
(
e
){
this
.
trigger
(
"
error
"
,{
detail
:
e
.
detail
})},
this
)},
p
=
function
(){},
d
=
function
(
e
,
t
,
n
,
r
){
var
i
,
s
;
if
(
n
)
try
{
i
=
n
(
r
.
detail
)}
catch
(
o
){
s
=
o
}
else
i
=
r
.
detail
;
i
instanceof
h
?
i
.
then
(
function
(
e
){
t
.
resolve
(
e
)},
function
(
e
){
t
.
reject
(
e
)}):
n
&&
i
?
t
.
resolve
(
i
):
s
?
t
.
reject
(
s
):
t
[
e
](
i
)};
h
.
prototype
=
{
then
:
function
(
e
,
t
){
var
n
=
new
h
;
return
this
.
isResolved
&&
r
.
async
(
function
(){
d
(
"
resolve
"
,
n
,
e
,{
detail
:
this
.
resolvedValue
})},
this
),
this
.
isRejected
&&
r
.
async
(
function
(){
d
(
"
reject
"
,
n
,
t
,{
detail
:
this
.
rejectedValue
})},
this
),
this
.
on
(
"
promise:resolved
"
,
function
(
t
){
d
(
"
resolve
"
,
n
,
e
,
t
)}),
this
.
on
(
"
promise:failed
"
,
function
(
e
){
d
(
"
reject
"
,
n
,
t
,
e
)}),
n
},
resolve
:
function
(
e
){
v
(
this
,
e
),
this
.
resolve
=
p
,
this
.
reject
=
p
},
reject
:
function
(
e
){
m
(
this
,
e
),
this
.
resolve
=
p
,
this
.
reject
=
p
}},
c
.
mixin
(
h
.
prototype
),
r
=
{
async
:
i
,
Promise
:
h
,
Event
:
a
,
EventTarget
:
c
},
e
.
RSVP
=
r
})(
window
);
(
function
(
e
){
"
use strict
"
;
function
v
(
e
,
t
){
r
.
async
(
function
(){
e
.
trigger
(
"
promise:resolved
"
,{
detail
:
t
}),
e
.
isResolved
=!
0
,
e
.
resolvedValue
=
t
})}
function
m
(
e
,
t
){
r
.
async
(
function
(){
e
.
trigger
(
"
promise:failed
"
,{
detail
:
t
}),
e
.
isRejected
=!
0
,
e
.
rejectedValue
=
t
})}
var
t
=
typeof
window
!=
"
undefined
"
?
window
:{},
n
=
t
.
MutationObserver
||
t
.
WebKitMutationObserver
,
r
,
i
;
if
(
typeof
process
!=
"
undefined
"
&&
{}.
toString
.
call
(
process
)
===
"
[object process]
"
)
i
=
function
(
e
,
t
){
process
.
nextTick
(
function
(){
e
.
call
(
t
)})};
else
if
(
n
){
var
s
=
[],
o
=
new
n
(
function
(){
var
e
=
s
.
slice
();
s
=
[],
e
.
forEach
(
function
(
e
){
var
t
=
e
[
0
],
n
=
e
[
1
];
t
.
call
(
n
)})}),
u
=
document
.
createElement
(
"
div
"
);
o
.
observe
(
u
,{
attributes
:
!
0
}),
i
=
function
(
e
,
t
){
s
.
push
([
e
,
t
]),
u
.
setAttribute
(
"
drainQueue
"
,
"
drainQueue
"
)}}
else
i
=
function
(
e
,
t
){
setTimeout
(
function
(){
e
.
call
(
t
)},
1
)};
var
a
=
function
(
e
,
t
){
this
.
type
=
e
;
for
(
var
n
in
t
){
if
(
!
t
.
hasOwnProperty
(
n
))
continue
;
this
[
n
]
=
t
[
n
]}},
f
=
function
(
e
,
t
){
for
(
var
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
if
(
e
[
n
][
0
]
===
t
)
return
n
;
return
-
1
},
l
=
function
(
e
){
var
t
=
e
.
_promiseCallbacks
;
return
t
||
(
t
=
e
.
_promiseCallbacks
=
{}),
t
},
c
=
{
mixin
:
function
(
e
){
return
e
.
on
=
this
.
on
,
e
.
off
=
this
.
off
,
e
.
trigger
=
this
.
trigger
,
e
},
on
:
function
(
e
,
t
,
n
){
var
r
=
l
(
this
),
i
,
s
;
e
=
e
.
split
(
/
\s
+/
),
n
=
n
||
this
;
while
(
s
=
e
.
shift
())
i
=
r
[
s
],
i
||
(
i
=
r
[
s
]
=
[]),
f
(
i
,
t
)
===-
1
&&
i
.
push
([
t
,
n
])},
off
:
function
(
e
,
t
){
var
n
=
l
(
this
),
r
,
i
,
s
;
e
=
e
.
split
(
/
\s
+/
);
while
(
i
=
e
.
shift
()){
if
(
!
t
){
n
[
i
]
=
[];
continue
}
r
=
n
[
i
],
s
=
f
(
r
,
t
),
s
!==-
1
&&
r
.
splice
(
s
,
1
)}},
trigger
:
function
(
e
,
t
){
var
n
=
l
(
this
),
r
,
i
,
s
,
o
,
u
;
if
(
r
=
n
[
e
])
for
(
var
f
=
0
,
c
=
r
.
length
;
f
<
c
;
f
++
)
i
=
r
[
f
],
s
=
i
[
0
],
o
=
i
[
1
],
typeof
t
!=
"
object
"
&&
(
t
=
{
detail
:
t
}),
u
=
new
a
(
e
,
t
),
s
.
call
(
o
,
u
)}},
h
=
function
(){
this
.
on
(
"
promise:resolved
"
,
function
(
e
){
this
.
trigger
(
"
success
"
,{
detail
:
e
.
detail
})},
this
),
this
.
on
(
"
promise:failed
"
,
function
(
e
){
this
.
trigger
(
"
error
"
,{
detail
:
e
.
detail
})},
this
)},
p
=
function
(){},
d
=
function
(
e
,
t
,
n
,
r
){
var
i
,
s
,
o
,
u
;
if
(
n
)
try
{
i
=
n
(
r
.
detail
),
o
=!
0
}
catch
(
a
){
u
=!
0
,
s
=
a
}
else
i
=
r
.
detail
,
o
=!
0
;
i
instanceof
h
?
i
.
then
(
function
(
e
){
t
.
resolve
(
e
)},
function
(
e
){
t
.
reject
(
e
)}):
n
&&
o
?
t
.
resolve
(
i
):
u
?
t
.
reject
(
s
):
t
[
e
](
i
)};
h
.
prototype
=
{
then
:
function
(
e
,
t
){
var
n
=
new
h
;
return
this
.
isResolved
&&
r
.
async
(
function
(){
d
(
"
resolve
"
,
n
,
e
,{
detail
:
this
.
resolvedValue
})},
this
),
this
.
isRejected
&&
r
.
async
(
function
(){
d
(
"
reject
"
,
n
,
t
,{
detail
:
this
.
rejectedValue
})},
this
),
this
.
on
(
"
promise:resolved
"
,
function
(
t
){
d
(
"
resolve
"
,
n
,
e
,
t
)}),
this
.
on
(
"
promise:failed
"
,
function
(
e
){
d
(
"
reject
"
,
n
,
t
,
e
)}),
n
},
resolve
:
function
(
e
){
v
(
this
,
e
),
this
.
resolve
=
p
,
this
.
reject
=
p
},
reject
:
function
(
e
){
m
(
this
,
e
),
this
.
resolve
=
p
,
this
.
reject
=
p
}},
c
.
mixin
(
h
.
prototype
),
r
=
{
async
:
i
,
Promise
:
h
,
Event
:
a
,
EventTarget
:
c
},
e
.
RSVP
=
r
})(
window
);
lib/rsvp.js
View file @
1d3b8e6c
...
...
@@ -144,27 +144,31 @@ var Promise = function() {
var
noop
=
function
()
{};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
value
,
error
;
var
hasCallback
=
typeof
callback
===
'
function
'
,
value
,
error
,
succeeded
,
failed
;
if
(
c
allback
)
{
if
(
hasC
allback
)
{
try
{
value
=
callback
(
event
.
detail
);
succeeded
=
true
;
}
catch
(
e
)
{
failed
=
true
;
error
=
e
;
}
}
else
{
value
=
event
.
detail
;
succeeded
=
true
;
}
if
(
value
instanceof
Promise
)
{
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
value
.
then
(
function
(
value
)
{
promise
.
resolve
(
value
);
},
function
(
error
)
{
promise
.
reject
(
error
);
});
}
else
if
(
callback
&&
value
)
{
}
else
if
(
hasCallback
&&
succeeded
)
{
promise
.
resolve
(
value
);
}
else
if
(
error
)
{
}
else
if
(
failed
)
{
promise
.
reject
(
error
);
}
else
{
promise
[
type
](
value
);
...
...
tests/index.html
View file @
1d3b8e6c
...
...
@@ -11,6 +11,7 @@
switch
(
name
)
{
case
"
assert
"
:
return
window
.
assert
;
case
"
sinon
"
:
return
window
.
sinon
;
case
"
./helpers/testThreeCases
"
:
return
window
.
testThreeCases
;
case
"
./rsvp
"
:
return
RSVP
;
}
};
...
...
@@ -20,11 +21,19 @@
<script
src=
"mocha.js"
></script>
<script
src=
"../browser/rsvp.js"
></script>
<script
src=
"test-adapter.js"
></script>
<script>
mocha
.
setup
(
'
bdd
'
)
</script>
<script
src=
"../promise-tests/lib/tests/promises-a.js"
></script>
<script
src=
"../promise-tests/lib/tests/always-async.js"
></script>
<script
src=
"../promise-tests/lib/tests/resolution-races.js"
></script>
<script
src=
"../promise-tests/lib/tests/returning-a-promise.js"
></script>
<script>
var
global
=
window
;
var
exports
=
testThreeCases
=
{};
</script>
<script
src=
"../promises-tests/lib/tests/helpers/testThreeCases.js"
></script>
<script>
window
.
exports
=
undefined
;
</script>
<script>
mocha
.
setup
({
ui
:
'
bdd
'
,
timeout
:
200
})
</script>
<script
src=
"../promises-tests/lib/tests/3.2.1.js"
></script>
<script
src=
"../promises-tests/lib/tests/3.2.2.js"
></script>
<script
src=
"../promises-tests/lib/tests/3.2.3.js"
></script>
<script
src=
"../promises-tests/lib/tests/3.2.4.js"
></script>
<script
src=
"../promises-tests/lib/tests/3.2.5.js"
></script>
<script
src=
"../promises-tests/lib/tests/3.2.6.js"
></script>
<script>
mocha
.
run
();
</script>
...
...
tests/rsvp.js
View file @
1d3b8e6c
...
...
@@ -145,27 +145,31 @@ var Promise = function() {
var
noop
=
function
()
{};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
value
,
error
;
var
hasCallback
=
typeof
callback
===
'
function
'
,
value
,
error
,
succeeded
,
failed
;
if
(
c
allback
)
{
if
(
hasC
allback
)
{
try
{
value
=
callback
(
event
.
detail
);
succeeded
=
true
;
}
catch
(
e
)
{
failed
=
true
;
error
=
e
;
}
}
else
{
value
=
event
.
detail
;
succeeded
=
true
;
}
if
(
value
instanceof
Promise
)
{
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
value
.
then
(
function
(
value
)
{
promise
.
resolve
(
value
);
},
function
(
error
)
{
promise
.
reject
(
error
);
});
}
else
if
(
callback
&&
value
)
{
}
else
if
(
hasCallback
&&
succeeded
)
{
promise
.
resolve
(
value
);
}
else
if
(
error
)
{
}
else
if
(
failed
)
{
promise
.
reject
(
error
);
}
else
{
promise
[
type
](
value
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment