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
7a5493c2
Commit
7a5493c2
authored
Mar 06, 2013
by
Tomhuda Katzdale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add RSVP.defer
parent
6dd93886
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
66 additions
and
2 deletions
+66
-2
browser/rsvp.amd.js
browser/rsvp.amd.js
+13
-0
browser/rsvp.js
browser/rsvp.js
+13
-0
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
lib/rsvp.js
lib/rsvp.js
+13
-1
tests/extension-tests.js
tests/extension-tests.js
+26
-0
No files found.
browser/rsvp.amd.js
View file @
7a5493c2
...
...
@@ -154,7 +154,20 @@ define(
config
[
name
]
=
value
;
}
function
defer
()
{
var
deferred
=
{};
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
deferred
.
resolve
=
resolve
;
deferred
.
reject
=
reject
;
});
deferred
.
promise
=
promise
;
return
deferred
;
}
__exports__
.
Promise
=
Promise
;
__exports__
.
all
=
all
;
__exports__
.
defer
=
defer
;
__exports__
.
configure
=
configure
;
});
browser/rsvp.js
View file @
7a5493c2
...
...
@@ -341,8 +341,21 @@ define("rsvp",
config
[
name
]
=
value
;
}
function
defer
()
{
var
deferred
=
{};
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
deferred
.
resolve
=
resolve
;
deferred
.
reject
=
reject
;
});
deferred
.
promise
=
promise
;
return
deferred
;
}
__exports__
.
Promise
=
Promise
;
__exports__
.
all
=
all
;
__exports__
.
defer
=
defer
;
__exports__
.
configure
=
configure
;
});
...
...
browser/rsvp.min.js
View file @
7a5493c2
(
function
(){
var
a
,
b
;(
function
(){
var
c
=
{},
d
=
{};
a
=
function
(
a
,
b
,
d
){
c
[
a
]
=
{
deps
:
b
,
callback
:
d
}},
b
=
function
(
a
){
if
(
d
[
a
])
return
d
[
a
];
d
[
a
]
=
{};
var
e
=
c
[
a
],
f
=
e
.
deps
,
g
=
e
.
callback
,
h
=
[],
i
;
for
(
var
j
=
0
,
k
=
f
.
length
;
j
<
k
;
j
++
)
f
[
j
]
===
"
exports
"
?
h
.
push
(
i
=
{}):
h
.
push
(
b
(
f
[
j
]));
var
l
=
g
.
apply
(
this
,
h
);
return
d
[
a
]
=
i
||
l
}})(),
a
(
"
rsvp/async
"
,[
"
exports
"
],
function
(
a
){
"
use strict
"
;
var
b
=
typeof
window
!=
"
undefined
"
?
window
:{},
c
=
b
.
MutationObserver
||
b
.
WebKitMutationObserver
,
d
;
if
(
typeof
process
!=
"
undefined
"
&&
{}.
toString
.
call
(
process
)
===
"
[object process]
"
)
d
=
function
(
a
,
b
){
process
.
nextTick
(
function
(){
a
.
call
(
b
)})};
else
if
(
c
){
var
e
=
[],
f
=
new
c
(
function
(){
var
a
=
e
.
slice
();
e
=
[],
a
.
forEach
(
function
(
a
){
var
b
=
a
[
0
],
c
=
a
[
1
];
b
.
call
(
c
)})}),
g
=
document
.
createElement
(
"
div
"
);
f
.
observe
(
g
,{
attributes
:
!
0
}),
window
.
addEventListener
(
"
unload
"
,
function
(){
f
.
disconnect
(),
f
=
null
}),
d
=
function
(
a
,
b
){
e
.
push
([
a
,
b
]),
g
.
setAttribute
(
"
drainQueue
"
,
"
drainQueue
"
)}}
else
d
=
function
(
a
,
b
){
setTimeout
(
function
(){
a
.
call
(
b
)},
1
)};
a
.
async
=
d
}),
a
(
"
rsvp/events
"
,[
"
exports
"
],
function
(
a
){
"
use strict
"
;
var
b
=
function
(
a
,
b
){
this
.
type
=
a
;
for
(
var
c
in
b
){
if
(
!
b
.
hasOwnProperty
(
c
))
continue
;
this
[
c
]
=
b
[
c
]}},
c
=
function
(
a
,
b
){
for
(
var
c
=
0
,
d
=
a
.
length
;
c
<
d
;
c
++
)
if
(
a
[
c
][
0
]
===
b
)
return
c
;
return
-
1
},
d
=
function
(
a
){
var
b
=
a
.
_promiseCallbacks
;
b
||
(
b
=
a
.
_promiseCallbacks
=
{});
return
b
},
e
=
{
mixin
:
function
(
a
){
a
.
on
=
this
.
on
,
a
.
off
=
this
.
off
,
a
.
trigger
=
this
.
trigger
;
return
a
},
on
:
function
(
a
,
b
,
e
){
var
f
=
d
(
this
),
g
,
h
;
a
=
a
.
split
(
/
\s
+/
),
e
=
e
||
this
;
while
(
h
=
a
.
shift
())
g
=
f
[
h
],
g
||
(
g
=
f
[
h
]
=
[]),
c
(
g
,
b
)
===-
1
&&
g
.
push
([
b
,
e
])},
off
:
function
(
a
,
b
){
var
e
=
d
(
this
),
f
,
g
,
h
;
a
=
a
.
split
(
/
\s
+/
);
while
(
g
=
a
.
shift
()){
if
(
!
b
){
e
[
g
]
=
[];
continue
}
f
=
e
[
g
],
h
=
c
(
f
,
b
),
h
!==-
1
&&
f
.
splice
(
h
,
1
)}},
trigger
:
function
(
a
,
c
){
var
e
=
d
(
this
),
f
,
g
,
h
,
i
,
j
;
if
(
f
=
e
[
a
])
for
(
var
k
=
0
;
k
<
f
.
length
;
k
++
)
g
=
f
[
k
],
h
=
g
[
0
],
i
=
g
[
1
],
typeof
c
!=
"
object
"
&&
(
c
=
{
detail
:
c
}),
j
=
new
b
(
a
,
c
),
h
.
call
(
i
,
j
)}};
a
.
EventTarget
=
e
}),
a
(
"
rsvp
"
,[
"
rsvp/async
"
,
"
rsvp/events
"
,
"
exports
"
],
function
(
a
,
b
,
c
){
function
m
(
a
,
b
){
f
[
a
]
=
b
}
function
l
(
a
){
var
b
,
c
=
[],
d
=
new
h
,
e
=
a
.
length
;
e
===
0
&&
j
(
d
,[]);
var
f
=
function
(
a
){
return
function
(
b
){
g
(
a
,
b
)}},
g
=
function
(
a
,
b
){
c
[
a
]
=
b
,
--
e
===
0
&&
j
(
d
,
c
)},
i
=
function
(
a
){
k
(
d
,
a
)};
for
(
b
=
0
;
b
<
e
;
b
++
)
a
[
b
].
then
(
f
(
b
),
i
);
return
d
}
function
k
(
a
,
b
){
f
.
async
(
function
(){
a
.
trigger
(
"
promise:failed
"
,{
detail
:
b
}),
a
.
isRejected
=!
0
,
a
.
rejectedReason
=
b
})}
function
j
(
a
,
b
){
f
.
async
(
function
(){
a
.
trigger
(
"
promise:resolved
"
,{
detail
:
b
}),
a
.
isFulfilled
=!
0
,
a
.
fulfillmentValue
=
b
})}
"
use strict
"
;
var
d
=
a
.
async
,
e
=
b
.
EventTarget
,
f
=
{};
f
.
async
=
d
;
var
g
=
function
(){},
h
=
function
(
a
){
var
b
=
this
,
c
=
function
(
a
){
j
(
b
,
a
),
c
=
g
,
d
=
g
},
d
=
function
(
a
){
k
(
b
,
a
),
c
=
g
,
d
=
g
};
this
.
on
(
"
promise:resolved
"
,
function
(
a
){
this
.
trigger
(
"
success
"
,{
detail
:
a
.
detail
})},
this
),
this
.
on
(
"
promise:failed
"
,
function
(
a
){
this
.
trigger
(
"
error
"
,{
detail
:
a
.
detail
})},
this
),
a
&&
a
(
c
,
d
)},
i
=
function
(
a
,
b
,
c
,
d
){
var
e
=
typeof
c
==
"
function
"
,
f
,
g
,
h
,
i
;
if
(
e
)
try
{
f
=
c
(
d
.
detail
),
h
=!
0
}
catch
(
l
){
i
=!
0
,
g
=
l
}
else
f
=
d
.
detail
,
h
=!
0
;
f
&&
typeof
f
.
then
==
"
function
"
?
f
.
then
(
function
(
a
){
j
(
b
,
a
)},
function
(
a
){
k
(
b
,
a
)}):
e
&&
h
?
j
(
b
,
f
):
i
?
k
(
b
,
g
):
a
===
"
resolve
"
?
j
(
b
,
f
):
a
===
"
reject
"
&&
k
(
b
,
f
)};
h
.
prototype
=
{
then
:
function
(
a
,
b
){
var
c
=
new
h
;
this
.
isFulfilled
&&
f
.
async
(
function
(){
i
(
"
resolve
"
,
c
,
a
,{
detail
:
this
.
fulfillmentValue
})},
this
),
this
.
isRejected
&&
f
.
async
(
function
(){
i
(
"
reject
"
,
c
,
b
,{
detail
:
this
.
rejectedReason
})},
this
),
this
.
on
(
"
promise:resolved
"
,
function
(
b
){
i
(
"
resolve
"
,
c
,
a
,
b
)}),
this
.
on
(
"
promise:failed
"
,
function
(
a
){
i
(
"
reject
"
,
c
,
b
,
a
)});
return
c
}},
e
.
mixin
(
h
.
prototype
),
c
.
Promise
=
h
,
c
.
all
=
l
,
c
.
configure
=
m
}),
window
.
RSVP
=
b
(
"
rsvp
"
)})()
(
function
(){
var
e
,
t
;(
function
(){
var
n
=
{},
r
=
{};
e
=
function
(
e
,
t
,
r
){
n
[
e
]
=
{
deps
:
t
,
callback
:
r
}},
t
=
function
(
e
){
if
(
r
[
e
])
return
r
[
e
];
r
[
e
]
=
{};
var
i
=
n
[
e
],
s
=
i
.
deps
,
o
=
i
.
callback
,
u
=
[],
a
;
for
(
var
f
=
0
,
l
=
s
.
length
;
f
<
l
;
f
++
)
s
[
f
]
===
"
exports
"
?
u
.
push
(
a
=
{}):
u
.
push
(
t
(
s
[
f
]));
var
c
=
o
.
apply
(
this
,
u
);
return
r
[
e
]
=
a
||
c
}})(),
e
(
"
rsvp/async
"
,[
"
exports
"
],
function
(
e
){
"
use strict
"
;
var
t
=
typeof
window
!=
"
undefined
"
?
window
:{},
n
=
t
.
MutationObserver
||
t
.
WebKitMutationObserver
,
r
;
if
(
typeof
process
!=
"
undefined
"
&&
{}.
toString
.
call
(
process
)
===
"
[object process]
"
)
r
=
function
(
e
,
t
){
process
.
nextTick
(
function
(){
e
.
call
(
t
)})};
else
if
(
n
){
var
i
=
[],
s
=
new
n
(
function
(){
var
e
=
i
.
slice
();
i
=
[],
e
.
forEach
(
function
(
e
){
var
t
=
e
[
0
],
n
=
e
[
1
];
t
.
call
(
n
)})}),
o
=
document
.
createElement
(
"
div
"
);
s
.
observe
(
o
,{
attributes
:
!
0
}),
window
.
addEventListener
(
"
unload
"
,
function
(){
s
.
disconnect
(),
s
=
null
}),
r
=
function
(
e
,
t
){
i
.
push
([
e
,
t
]),
o
.
setAttribute
(
"
drainQueue
"
,
"
drainQueue
"
)}}
else
r
=
function
(
e
,
t
){
setTimeout
(
function
(){
e
.
call
(
t
)},
1
)};
e
.
async
=
r
}),
e
(
"
rsvp/events
"
,[
"
exports
"
],
function
(
e
){
"
use strict
"
;
var
t
=
function
(
e
,
t
){
this
.
type
=
e
;
for
(
var
n
in
t
){
if
(
!
t
.
hasOwnProperty
(
n
))
continue
;
this
[
n
]
=
t
[
n
]}},
n
=
function
(
e
,
t
){
for
(
var
n
=
0
,
r
=
e
.
length
;
n
<
r
;
n
++
)
if
(
e
[
n
][
0
]
===
t
)
return
n
;
return
-
1
},
r
=
function
(
e
){
var
t
=
e
.
_promiseCallbacks
;
return
t
||
(
t
=
e
.
_promiseCallbacks
=
{}),
t
},
i
=
{
mixin
:
function
(
e
){
return
e
.
on
=
this
.
on
,
e
.
off
=
this
.
off
,
e
.
trigger
=
this
.
trigger
,
e
},
on
:
function
(
e
,
t
,
i
){
var
s
=
r
(
this
),
o
,
u
;
e
=
e
.
split
(
/
\s
+/
),
i
=
i
||
this
;
while
(
u
=
e
.
shift
())
o
=
s
[
u
],
o
||
(
o
=
s
[
u
]
=
[]),
n
(
o
,
t
)
===-
1
&&
o
.
push
([
t
,
i
])},
off
:
function
(
e
,
t
){
var
i
=
r
(
this
),
s
,
o
,
u
;
e
=
e
.
split
(
/
\s
+/
);
while
(
o
=
e
.
shift
()){
if
(
!
t
){
i
[
o
]
=
[];
continue
}
s
=
i
[
o
],
u
=
n
(
s
,
t
),
u
!==-
1
&&
s
.
splice
(
u
,
1
)}},
trigger
:
function
(
e
,
n
){
var
i
=
r
(
this
),
s
,
o
,
u
,
a
,
f
;
if
(
s
=
i
[
e
])
for
(
var
l
=
0
;
l
<
s
.
length
;
l
++
)
o
=
s
[
l
],
u
=
o
[
0
],
a
=
o
[
1
],
typeof
n
!=
"
object
"
&&
(
n
=
{
detail
:
n
}),
f
=
new
t
(
e
,
n
),
u
.
call
(
a
,
f
)}};
e
.
EventTarget
=
i
}),
e
(
"
rsvp
"
,[
"
rsvp/async
"
,
"
rsvp/events
"
,
"
exports
"
],
function
(
e
,
t
,
n
){
"
use strict
"
;
function
f
(
e
,
t
){
s
.
async
(
function
(){
e
.
trigger
(
"
promise:resolved
"
,{
detail
:
t
}),
e
.
isFulfilled
=!
0
,
e
.
fulfillmentValue
=
t
})}
function
l
(
e
,
t
){
s
.
async
(
function
(){
e
.
trigger
(
"
promise:failed
"
,{
detail
:
t
}),
e
.
isRejected
=!
0
,
e
.
rejectedReason
=
t
})}
function
c
(
e
){
var
t
,
n
=
[],
r
=
new
u
,
i
=
e
.
length
;
i
===
0
&&
f
(
r
,[]);
var
s
=
function
(
e
){
return
function
(
t
){
o
(
e
,
t
)}},
o
=
function
(
e
,
t
){
n
[
e
]
=
t
,
--
i
===
0
&&
f
(
r
,
n
)},
a
=
function
(
e
){
l
(
r
,
e
)};
for
(
t
=
0
;
t
<
i
;
t
++
)
e
[
t
].
then
(
s
(
t
),
a
);
return
r
}
function
h
(
e
,
t
){
s
[
e
]
=
t
}
function
p
(){
var
e
=
{},
t
=
new
u
(
function
(
t
,
n
){
e
.
resolve
=
t
,
e
.
reject
=
n
});
return
e
.
promise
=
t
,
e
}
var
r
=
e
.
async
,
i
=
t
.
EventTarget
,
s
=
{};
s
.
async
=
r
;
var
o
=
function
(){},
u
=
function
(
e
){
var
t
=
this
,
n
=
function
(
e
){
f
(
t
,
e
),
n
=
o
,
r
=
o
},
r
=
function
(
e
){
l
(
t
,
e
),
n
=
o
,
r
=
o
};
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
),
e
&&
e
(
n
,
r
)},
a
=
function
(
e
,
t
,
n
,
r
){
var
i
=
typeof
n
==
"
function
"
,
s
,
o
,
u
,
a
;
if
(
i
)
try
{
s
=
n
(
r
.
detail
),
u
=!
0
}
catch
(
c
){
a
=!
0
,
o
=
c
}
else
s
=
r
.
detail
,
u
=!
0
;
s
&&
typeof
s
.
then
==
"
function
"
?
s
.
then
(
function
(
e
){
f
(
t
,
e
)},
function
(
e
){
l
(
t
,
e
)}):
i
&&
u
?
f
(
t
,
s
):
a
?
l
(
t
,
o
):
e
===
"
resolve
"
?
f
(
t
,
s
):
e
===
"
reject
"
&&
l
(
t
,
s
)};
u
.
prototype
=
{
then
:
function
(
e
,
t
){
var
n
=
new
u
;
return
this
.
isFulfilled
&&
s
.
async
(
function
(){
a
(
"
resolve
"
,
n
,
e
,{
detail
:
this
.
fulfillmentValue
})},
this
),
this
.
isRejected
&&
s
.
async
(
function
(){
a
(
"
reject
"
,
n
,
t
,{
detail
:
this
.
rejectedReason
})},
this
),
this
.
on
(
"
promise:resolved
"
,
function
(
t
){
a
(
"
resolve
"
,
n
,
e
,
t
)}),
this
.
on
(
"
promise:failed
"
,
function
(
e
){
a
(
"
reject
"
,
n
,
t
,
e
)}),
n
}},
i
.
mixin
(
u
.
prototype
),
n
.
Promise
=
u
,
n
.
all
=
c
,
n
.
defer
=
p
,
n
.
configure
=
h
}),
window
.
RSVP
=
t
(
"
rsvp
"
)})();
lib/rsvp.js
View file @
7a5493c2
...
...
@@ -150,4 +150,16 @@ function configure(name, value) {
config
[
name
]
=
value
;
}
export
{
Promise
,
all
,
configure
};
function
defer
()
{
var
deferred
=
{};
var
promise
=
new
Promise
(
function
(
resolve
,
reject
)
{
deferred
.
resolve
=
resolve
;
deferred
.
reject
=
reject
;
});
deferred
.
promise
=
promise
;
return
deferred
;
}
export
{
Promise
,
all
,
defer
,
configure
};
tests/extension-tests.js
View file @
7a5493c2
/*global RSVP, describe, specify, assert */
describe
(
"
RSVP extensions
"
,
function
()
{
describe
(
"
RSVP.defer
"
,
function
()
{
specify
(
"
It should return a resolver and promise together
"
,
function
(
done
)
{
var
deferred
=
RSVP
.
defer
(),
value
=
{};
// resolve first to confirm that the semantics are async
deferred
.
resolve
(
value
);
deferred
.
promise
.
then
(
function
(
passedValue
)
{
assert
(
passedValue
===
value
);
done
();
});
});
specify
(
"
The provided resolver should support rejection
"
,
function
(
done
)
{
var
deferred
=
RSVP
.
defer
(),
reason
=
{};
// resolve first to confirm that the semantics are async
deferred
.
reject
(
reason
);
deferred
.
promise
.
then
(
null
,
function
(
passedReason
)
{
assert
(
passedReason
===
reason
);
done
();
});
});
});
describe
(
"
RSVP.all
"
,
function
()
{
specify
(
'
it should exist
'
,
function
()
{
assert
(
RSVP
.
all
);
...
...
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