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
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
rsvp.js
Commits
ab31b960
Commit
ab31b960
authored
Jan 11, 2013
by
tomhuda
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improve exports and configuration
Fixes #31
parent
94aeaf66
Changes
7
Show whitespace changes
Inline
Side-by-side
Showing
7 changed files
with
221 additions
and
175 deletions
+221
-175
Rakefile
Rakefile
+1
-1
browser/rsvp.amd.js
browser/rsvp.amd.js
+46
-37
browser/rsvp.js
browser/rsvp.js
+44
-35
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
lib/rsvp.js
lib/rsvp.js
+39
-34
node/rsvp.js
node/rsvp.js
+43
-34
tests/rsvp.js
tests/rsvp.js
+47
-33
No files found.
Rakefile
View file @
ab31b960
...
...
@@ -17,7 +17,7 @@ file "browser/rsvp.amd.js" => ["browser", "lib/rsvp.js"] do
open
"browser/rsvp.amd.js"
,
"w"
do
|
file
|
require
"js_module_transpiler"
converter
=
JsModuleTranspiler
::
Compiler
.
new
(
File
.
read
(
"./lib/rsvp.js"
)
,
"rsvp"
)
converter
=
JsModuleTranspiler
::
Compiler
.
new
(
File
.
read
(
"./lib/rsvp.js"
))
file
.
puts
converter
.
to_amd
end
end
...
...
browser/rsvp.amd.js
View file @
ab31b960
define
(
"
rsvp
"
,
[],
function
()
{
define
(
[
"
exports
"
],
function
(
__exports__
)
{
"
use strict
"
;
var
config
=
{};
var
browserGlobal
=
(
typeof
window
!==
'
undefined
'
)
?
window
:
{};
var
MutationObserver
=
browserGlobal
.
MutationObserver
||
browserGlobal
.
WebKitMutationObserver
;
var
RSVP
,
async
;
var
RSVP
;
if
(
typeof
process
!==
'
undefined
'
&&
{}.
toString
.
call
(
process
)
===
'
[object process]
'
)
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
process
.
nextTick
(
function
()
{
callback
.
call
(
binding
);
});
...
...
@@ -36,12 +38,12 @@ define("rsvp",
observer
=
null
;
});
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
queue
.
push
([
callback
,
binding
]);
element
.
setAttribute
(
'
drainQueue
'
,
'
drainQueue
'
);
};
}
else
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
setTimeout
(
function
()
{
callback
.
call
(
binding
);
},
1
);
...
...
@@ -190,13 +192,13 @@ define("rsvp",
var
thenPromise
=
new
Promise
();
if
(
this
.
isResolved
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
resolve
'
,
thenPromise
,
done
,
{
detail
:
this
.
resolvedValue
});
},
this
);
}
if
(
this
.
isRejected
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
reject
'
,
thenPromise
,
fail
,
{
detail
:
this
.
rejectedValue
});
},
this
);
}
...
...
@@ -228,7 +230,7 @@ define("rsvp",
};
function
resolve
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isResolved
=
true
;
promise
.
resolvedValue
=
value
;
...
...
@@ -236,7 +238,7 @@ define("rsvp",
}
function
reject
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedValue
=
value
;
...
...
@@ -277,6 +279,13 @@ define("rsvp",
EventTarget
.
mixin
(
Promise
.
prototype
);
RSVP
=
{
async
:
async
,
Promise
:
Promise
,
Event
:
Event
,
EventTarget
:
EventTarget
,
all
:
all
,
raiseOnUncaughtExceptions
:
true
};
return
RSVP
;
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
}
__exports__
.
Promise
=
Promise
;
__exports__
.
Event
=
Event
;
__exports__
.
EventTarget
=
EventTarget
;
__exports__
.
all
=
all
;
__exports__
.
configure
=
configure
;
});
browser/rsvp.js
View file @
ab31b960
(
function
(
exports
)
{
"
use strict
"
;
var
config
=
{};
var
browserGlobal
=
(
typeof
window
!==
'
undefined
'
)
?
window
:
{};
var
MutationObserver
=
browserGlobal
.
MutationObserver
||
browserGlobal
.
WebKitMutationObserver
;
var
RSVP
,
async
;
var
RSVP
;
if
(
typeof
process
!==
'
undefined
'
&&
{}.
toString
.
call
(
process
)
===
'
[object process]
'
)
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
process
.
nextTick
(
function
()
{
callback
.
call
(
binding
);
});
...
...
@@ -34,12 +36,12 @@
observer
=
null
;
});
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
queue
.
push
([
callback
,
binding
]);
element
.
setAttribute
(
'
drainQueue
'
,
'
drainQueue
'
);
};
}
else
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
setTimeout
(
function
()
{
callback
.
call
(
binding
);
},
1
);
...
...
@@ -188,13 +190,13 @@
var
thenPromise
=
new
Promise
();
if
(
this
.
isResolved
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
resolve
'
,
thenPromise
,
done
,
{
detail
:
this
.
resolvedValue
});
},
this
);
}
if
(
this
.
isRejected
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
reject
'
,
thenPromise
,
fail
,
{
detail
:
this
.
rejectedValue
});
},
this
);
}
...
...
@@ -226,7 +228,7 @@
};
function
resolve
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isResolved
=
true
;
promise
.
resolvedValue
=
value
;
...
...
@@ -234,7 +236,7 @@
}
function
reject
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedValue
=
value
;
...
...
@@ -275,6 +277,13 @@
EventTarget
.
mixin
(
Promise
.
prototype
);
RSVP
=
{
async
:
async
,
Promise
:
Promise
,
Event
:
Event
,
EventTarget
:
EventTarget
,
all
:
all
,
raiseOnUncaughtExceptions
:
true
};
exports
.
RSVP
=
RSVP
;
})(
window
);
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
}
exports
.
Promise
=
Promise
;
exports
.
Event
=
Event
;
exports
.
EventTarget
=
EventTarget
;
exports
.
all
=
all
;
exports
.
configure
=
configure
;
})(
window
.
RSVP
=
{});
browser/rsvp.min.js
View file @
ab31b960
(
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
})}
function
g
(
e
){
var
t
,
n
=
[],
r
=
new
h
,
i
=
e
.
length
;
i
===
0
&&
r
.
resolve
([]);
var
s
=
function
(
e
){
return
function
(
t
){
o
(
e
,
t
)}},
o
=
function
(
e
,
t
){
n
[
e
]
=
t
,
--
i
===
0
&&
r
.
resolve
(
n
)},
u
=
function
(
e
){
r
.
reject
(
e
)};
for
(
t
=
0
;
t
<
i
;
t
++
)
e
[
t
].
then
(
s
(
t
),
u
);
return
r
}
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
}),
window
.
addEventListener
(
"
unload
"
,
function
(){
o
.
disconnect
(),
o
=
null
}),
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
=
typeof
n
==
"
function
"
,
s
,
o
,
u
,
a
;
if
(
i
)
try
{
s
=
n
(
r
.
detail
),
u
=!
0
}
catch
(
f
){
a
=!
0
,
o
=
f
}
else
s
=
r
.
detail
,
u
=!
0
;
s
&&
typeof
s
.
then
==
"
function
"
?
s
.
then
(
function
(
e
){
t
.
resolve
(
e
)},
function
(
e
){
t
.
reject
(
e
)}):
i
&&
u
?
t
.
resolve
(
s
):
a
?
t
.
reject
(
o
):
t
[
e
](
s
)};
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
,
all
:
g
,
raiseOnUncaughtExceptions
:
!
0
},
e
.
RSVP
=
r
})(
window
);
(
function
(
e
){
"
use strict
"
;
function
v
(
e
,
n
){
t
.
async
(
function
(){
e
.
trigger
(
"
promise:resolved
"
,{
detail
:
n
}),
e
.
isResolved
=!
0
,
e
.
resolvedValue
=
n
})}
function
m
(
e
,
n
){
t
.
async
(
function
(){
e
.
trigger
(
"
promise:failed
"
,{
detail
:
n
}),
e
.
isRejected
=!
0
,
e
.
rejectedValue
=
n
})}
function
g
(
e
){
var
t
,
n
=
[],
r
=
new
h
,
i
=
e
.
length
;
i
===
0
&&
r
.
resolve
([]);
var
s
=
function
(
e
){
return
function
(
t
){
o
(
e
,
t
)}},
o
=
function
(
e
,
t
){
n
[
e
]
=
t
,
--
i
===
0
&&
r
.
resolve
(
n
)},
u
=
function
(
e
){
r
.
reject
(
e
)};
for
(
t
=
0
;
t
<
i
;
t
++
)
e
[
t
].
then
(
s
(
t
),
u
);
return
r
}
function
y
(
e
,
n
){
t
[
e
]
=
n
}
var
t
=
{},
n
=
typeof
window
!=
"
undefined
"
?
window
:{},
r
=
n
.
MutationObserver
||
n
.
WebKitMutationObserver
,
i
;
if
(
typeof
process
!=
"
undefined
"
&&
{}.
toString
.
call
(
process
)
===
"
[object process]
"
)
t
.
async
=
function
(
e
,
t
){
process
.
nextTick
(
function
(){
e
.
call
(
t
)})};
else
if
(
r
){
var
s
=
[],
o
=
new
r
(
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
}),
window
.
addEventListener
(
"
unload
"
,
function
(){
o
.
disconnect
(),
o
=
null
}),
t
.
async
=
function
(
e
,
t
){
s
.
push
([
e
,
t
]),
u
.
setAttribute
(
"
drainQueue
"
,
"
drainQueue
"
)}}
else
t
.
async
=
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
=
typeof
n
==
"
function
"
,
s
,
o
,
u
,
a
;
if
(
i
)
try
{
s
=
n
(
r
.
detail
),
u
=!
0
}
catch
(
f
){
a
=!
0
,
o
=
f
}
else
s
=
r
.
detail
,
u
=!
0
;
s
&&
typeof
s
.
then
==
"
function
"
?
s
.
then
(
function
(
e
){
t
.
resolve
(
e
)},
function
(
e
){
t
.
reject
(
e
)}):
i
&&
u
?
t
.
resolve
(
s
):
a
?
t
.
reject
(
o
):
t
[
e
](
s
)};
h
.
prototype
=
{
then
:
function
(
e
,
n
){
var
r
=
new
h
;
return
this
.
isResolved
&&
t
.
async
(
function
(){
d
(
"
resolve
"
,
r
,
e
,{
detail
:
this
.
resolvedValue
})},
this
),
this
.
isRejected
&&
t
.
async
(
function
(){
d
(
"
reject
"
,
r
,
n
,{
detail
:
this
.
rejectedValue
})},
this
),
this
.
on
(
"
promise:resolved
"
,
function
(
t
){
d
(
"
resolve
"
,
r
,
e
,
t
)}),
this
.
on
(
"
promise:failed
"
,
function
(
e
){
d
(
"
reject
"
,
r
,
n
,
e
)}),
r
},
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
),
e
.
Promise
=
h
,
e
.
Event
=
a
,
e
.
EventTarget
=
c
,
e
.
all
=
g
,
e
.
configure
=
y
})(
window
.
RSVP
=
{}
);
lib/rsvp.js
View file @
ab31b960
var
config
=
{};
var
browserGlobal
=
(
typeof
window
!==
'
undefined
'
)
?
window
:
{};
var
MutationObserver
=
browserGlobal
.
MutationObserver
||
browserGlobal
.
WebKitMutationObserver
;
var
RSVP
,
async
;
var
RSVP
;
if
(
typeof
process
!==
'
undefined
'
&&
{}.
toString
.
call
(
process
)
===
'
[object process]
'
)
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
process
.
nextTick
(
function
()
{
callback
.
call
(
binding
);
});
...
...
@@ -32,12 +34,12 @@ if (typeof process !== 'undefined' &&
observer
=
null
;
});
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
queue
.
push
([
callback
,
binding
]);
element
.
setAttribute
(
'
drainQueue
'
,
'
drainQueue
'
);
};
}
else
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
setTimeout
(
function
()
{
callback
.
call
(
binding
);
},
1
);
...
...
@@ -186,13 +188,13 @@ Promise.prototype = {
var
thenPromise
=
new
Promise
();
if
(
this
.
isResolved
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
resolve
'
,
thenPromise
,
done
,
{
detail
:
this
.
resolvedValue
});
},
this
);
}
if
(
this
.
isRejected
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
reject
'
,
thenPromise
,
fail
,
{
detail
:
this
.
rejectedValue
});
},
this
);
}
...
...
@@ -224,7 +226,7 @@ Promise.prototype = {
};
function
resolve
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isResolved
=
true
;
promise
.
resolvedValue
=
value
;
...
...
@@ -232,7 +234,7 @@ function resolve(promise, value) {
}
function
reject
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedValue
=
value
;
...
...
@@ -273,5 +275,8 @@ function all(promises) {
EventTarget
.
mixin
(
Promise
.
prototype
);
RSVP
=
{
async
:
async
,
Promise
:
Promise
,
Event
:
Event
,
EventTarget
:
EventTarget
,
all
:
all
,
raiseOnUncaughtExceptions
:
true
};
export
=
RSVP
;
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
}
export
{
Promise
,
Event
,
EventTarget
,
all
,
configure
};
node/rsvp.js
View file @
ab31b960
"
use strict
"
;
var
config
=
{};
var
browserGlobal
=
(
typeof
window
!==
'
undefined
'
)
?
window
:
{};
var
MutationObserver
=
browserGlobal
.
MutationObserver
||
browserGlobal
.
WebKitMutationObserver
;
var
RSVP
,
async
;
var
RSVP
;
if
(
typeof
process
!==
'
undefined
'
&&
{}.
toString
.
call
(
process
)
===
'
[object process]
'
)
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
process
.
nextTick
(
function
()
{
callback
.
call
(
binding
);
});
...
...
@@ -33,12 +35,12 @@ if (typeof process !== 'undefined' &&
observer
=
null
;
});
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
queue
.
push
([
callback
,
binding
]);
element
.
setAttribute
(
'
drainQueue
'
,
'
drainQueue
'
);
};
}
else
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
setTimeout
(
function
()
{
callback
.
call
(
binding
);
},
1
);
...
...
@@ -187,13 +189,13 @@ Promise.prototype = {
var
thenPromise
=
new
Promise
();
if
(
this
.
isResolved
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
resolve
'
,
thenPromise
,
done
,
{
detail
:
this
.
resolvedValue
});
},
this
);
}
if
(
this
.
isRejected
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
reject
'
,
thenPromise
,
fail
,
{
detail
:
this
.
rejectedValue
});
},
this
);
}
...
...
@@ -225,7 +227,7 @@ Promise.prototype = {
};
function
resolve
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isResolved
=
true
;
promise
.
resolvedValue
=
value
;
...
...
@@ -233,7 +235,7 @@ function resolve(promise, value) {
}
function
reject
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedValue
=
value
;
...
...
@@ -274,5 +276,12 @@ function all(promises) {
EventTarget
.
mixin
(
Promise
.
prototype
);
RSVP
=
{
async
:
async
,
Promise
:
Promise
,
Event
:
Event
,
EventTarget
:
EventTarget
,
all
:
all
,
raiseOnUncaughtExceptions
:
true
};
module
.
exports
=
RSVP
;
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
}
exports
.
Promise
=
Promise
;
exports
.
Event
=
Event
;
exports
.
EventTarget
=
EventTarget
;
exports
.
all
=
all
;
exports
.
configure
=
configure
;
tests/rsvp.js
View file @
ab31b960
"
use strict
"
;
var
config
=
{};
var
browserGlobal
=
(
typeof
window
!==
'
undefined
'
)
?
window
:
{};
var
MutationObserver
=
browserGlobal
.
MutationObserver
||
browserGlobal
.
WebKitMutationObserver
;
var
RSVP
,
async
;
var
RSVP
;
if
(
typeof
process
!==
'
undefined
'
&&
{}.
toString
.
call
(
process
)
===
'
[object process]
'
)
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
process
.
nextTick
(
function
()
{
callback
.
call
(
binding
);
});
...
...
@@ -33,12 +35,12 @@ if (typeof process !== 'undefined' &&
observer
=
null
;
});
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
queue
.
push
([
callback
,
binding
]);
element
.
setAttribute
(
'
drainQueue
'
,
'
drainQueue
'
);
};
}
else
{
async
=
function
(
callback
,
binding
)
{
config
.
async
=
function
(
callback
,
binding
)
{
setTimeout
(
function
()
{
callback
.
call
(
binding
);
},
1
);
...
...
@@ -187,13 +189,13 @@ Promise.prototype = {
var
thenPromise
=
new
Promise
();
if
(
this
.
isResolved
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
resolve
'
,
thenPromise
,
done
,
{
detail
:
this
.
resolvedValue
});
},
this
);
}
if
(
this
.
isRejected
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
invokeCallback
(
'
reject
'
,
thenPromise
,
fail
,
{
detail
:
this
.
rejectedValue
});
},
this
);
}
...
...
@@ -225,7 +227,7 @@ Promise.prototype = {
};
function
resolve
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
promise
.
isResolved
=
true
;
promise
.
resolvedValue
=
value
;
...
...
@@ -233,7 +235,7 @@ function resolve(promise, value) {
}
function
reject
(
promise
,
value
)
{
RSVP
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:failed
'
,
{
detail
:
value
});
promise
.
isRejected
=
true
;
promise
.
rejectedValue
=
value
;
...
...
@@ -245,17 +247,23 @@ function all(promises) {
var
allPromise
=
new
Promise
();
var
remaining
=
promises
.
length
;
if
(
remaining
===
0
)
{
allPromise
.
resolve
([]);
}
var
resolver
=
function
(
index
)
{
return
function
(
value
)
{
resolve
(
index
,
value
);
};
};
var
resolve
=
function
(
index
,
value
)
{
results
[
index
]
=
value
;
if
(
--
remaining
===
0
)
{
allPromise
.
resolve
(
results
);
}
};
var
reject
=
function
(
error
)
{
allPromise
.
reject
(
error
);
};
...
...
@@ -268,5 +276,11 @@ function all(promises) {
EventTarget
.
mixin
(
Promise
.
prototype
);
RSVP
=
{
async
:
async
,
Promise
:
Promise
,
Event
:
Event
,
EventTarget
:
EventTarget
,
all
:
all
,
raiseOnUncaughtExceptions
:
true
};
module
.
exports
=
RSVP
;
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
}
exports
.
Promise
=
Promise
;
exports
.
Event
=
Event
;
exports
.
EventTarget
=
EventTarget
;
exports
.
configure
=
configure
;
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