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
00d5aaed
Commit
00d5aaed
authored
Apr 18, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
promise.resolve(promise) === fulfillment
parent
46bce2f6
Changes
5
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
59 additions
and
12 deletions
+59
-12
browser/rsvp.js
browser/rsvp.js
+12
-4
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
browser/rsvp/promise.amd.js
browser/rsvp/promise.amd.js
+12
-4
lib/rsvp/promise.js
lib/rsvp/promise.js
+13
-3
tests/extension-tests.js
tests/extension-tests.js
+21
-0
No files found.
browser/rsvp.js
View file @
00d5aaed
...
@@ -369,7 +369,13 @@ define("rsvp/promise",
...
@@ -369,7 +369,13 @@ define("rsvp/promise",
var
config
=
__dependency1__
.
config
;
var
config
=
__dependency1__
.
config
;
var
EventTarget
=
__dependency2__
.
EventTarget
;
var
EventTarget
=
__dependency2__
.
EventTarget
;
var
noop
=
function
()
{};
function
objectOrFunction
(
x
)
{
return
isFunction
(
x
)
||
(
typeof
x
===
"
object
"
&&
x
!==
null
);
}
function
isFunction
(
x
){
return
typeof
x
===
"
function
"
;
}
var
Promise
=
function
(
resolver
)
{
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
,
var
promise
=
this
,
...
@@ -407,7 +413,7 @@ define("rsvp/promise",
...
@@ -407,7 +413,7 @@ define("rsvp/promise",
};
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
hasCallback
=
typeof
callback
===
'
function
'
,
var
hasCallback
=
isFunction
(
callback
)
,
value
,
error
,
succeeded
,
failed
;
value
,
error
,
succeeded
,
failed
;
if
(
hasCallback
)
{
if
(
hasCallback
)
{
...
@@ -423,7 +429,7 @@ define("rsvp/promise",
...
@@ -423,7 +429,7 @@ define("rsvp/promise",
succeeded
=
true
;
succeeded
=
true
;
}
}
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
)
)
{
value
.
then
(
function
(
value
)
{
value
.
then
(
function
(
value
)
{
resolve
(
promise
,
value
);
resolve
(
promise
,
value
);
},
function
(
error
)
{
},
function
(
error
)
{
...
@@ -473,7 +479,9 @@ define("rsvp/promise",
...
@@ -473,7 +479,9 @@ define("rsvp/promise",
EventTarget
.
mixin
(
Promise
.
prototype
);
EventTarget
.
mixin
(
Promise
.
prototype
);
function
resolve
(
promise
,
value
)
{
function
resolve
(
promise
,
value
)
{
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
if
(
value
&&
(
value
===
promise
)
||
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
promise
)
&&
value
.
promise
()
===
promise
))
{
fulfill
(
promise
,
value
);
}
else
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
value
.
then
(
function
(
val
)
{
value
.
then
(
function
(
val
)
{
resolve
(
promise
,
val
);
resolve
(
promise
,
val
);
},
function
(
val
)
{
},
function
(
val
)
{
...
...
browser/rsvp.min.js
View file @
00d5aaed
This diff is collapsed.
Click to expand it.
browser/rsvp/promise.amd.js
View file @
00d5aaed
...
@@ -5,7 +5,13 @@ define(
...
@@ -5,7 +5,13 @@ define(
var
config
=
__dependency1__
.
config
;
var
config
=
__dependency1__
.
config
;
var
EventTarget
=
__dependency2__
.
EventTarget
;
var
EventTarget
=
__dependency2__
.
EventTarget
;
var
noop
=
function
()
{};
function
objectOrFunction
(
x
)
{
return
isFunction
(
x
)
||
(
typeof
x
===
"
object
"
&&
x
!==
null
);
}
function
isFunction
(
x
){
return
typeof
x
===
"
function
"
;
}
var
Promise
=
function
(
resolver
)
{
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
,
var
promise
=
this
,
...
@@ -43,7 +49,7 @@ define(
...
@@ -43,7 +49,7 @@ define(
};
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
hasCallback
=
typeof
callback
===
'
function
'
,
var
hasCallback
=
isFunction
(
callback
)
,
value
,
error
,
succeeded
,
failed
;
value
,
error
,
succeeded
,
failed
;
if
(
hasCallback
)
{
if
(
hasCallback
)
{
...
@@ -59,7 +65,7 @@ define(
...
@@ -59,7 +65,7 @@ define(
succeeded
=
true
;
succeeded
=
true
;
}
}
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
)
)
{
value
.
then
(
function
(
value
)
{
value
.
then
(
function
(
value
)
{
resolve
(
promise
,
value
);
resolve
(
promise
,
value
);
},
function
(
error
)
{
},
function
(
error
)
{
...
@@ -109,7 +115,9 @@ define(
...
@@ -109,7 +115,9 @@ define(
EventTarget
.
mixin
(
Promise
.
prototype
);
EventTarget
.
mixin
(
Promise
.
prototype
);
function
resolve
(
promise
,
value
)
{
function
resolve
(
promise
,
value
)
{
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
if
(
value
&&
(
value
===
promise
)
||
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
promise
)
&&
value
.
promise
()
===
promise
))
{
fulfill
(
promise
,
value
);
}
else
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
value
.
then
(
function
(
val
)
{
value
.
then
(
function
(
val
)
{
resolve
(
promise
,
val
);
resolve
(
promise
,
val
);
},
function
(
val
)
{
},
function
(
val
)
{
...
...
lib/rsvp/promise.js
View file @
00d5aaed
import
{
config
}
from
"
rsvp/config
"
;
import
{
config
}
from
"
rsvp/config
"
;
import
{
EventTarget
}
from
"
rsvp/events
"
;
import
{
EventTarget
}
from
"
rsvp/events
"
;
function
objectOrFunction
(
x
)
{
return
isFunction
(
x
)
||
(
typeof
x
===
"
object
"
&&
x
!==
null
);
}
function
isFunction
(
x
){
return
typeof
x
===
"
function
"
;
}
var
Promise
=
function
(
resolver
)
{
var
Promise
=
function
(
resolver
)
{
var
promise
=
this
,
var
promise
=
this
,
resolved
=
false
;
resolved
=
false
;
...
@@ -37,7 +45,7 @@ var Promise = function(resolver) {
...
@@ -37,7 +45,7 @@ var Promise = function(resolver) {
};
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
hasCallback
=
typeof
callback
===
'
function
'
,
var
hasCallback
=
isFunction
(
callback
)
,
value
,
error
,
succeeded
,
failed
;
value
,
error
,
succeeded
,
failed
;
if
(
hasCallback
)
{
if
(
hasCallback
)
{
...
@@ -53,7 +61,7 @@ var invokeCallback = function(type, promise, callback, event) {
...
@@ -53,7 +61,7 @@ var invokeCallback = function(type, promise, callback, event) {
succeeded
=
true
;
succeeded
=
true
;
}
}
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
)
)
{
value
.
then
(
function
(
value
)
{
value
.
then
(
function
(
value
)
{
resolve
(
promise
,
value
);
resolve
(
promise
,
value
);
},
function
(
error
)
{
},
function
(
error
)
{
...
@@ -103,7 +111,9 @@ Promise.prototype = {
...
@@ -103,7 +111,9 @@ Promise.prototype = {
EventTarget
.
mixin
(
Promise
.
prototype
);
EventTarget
.
mixin
(
Promise
.
prototype
);
function
resolve
(
promise
,
value
)
{
function
resolve
(
promise
,
value
)
{
if
(
value
&&
typeof
value
.
then
===
'
function
'
)
{
if
(
value
&&
(
value
===
promise
)
||
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
promise
)
&&
value
.
promise
()
===
promise
))
{
fulfill
(
promise
,
value
);
}
else
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
value
.
then
(
function
(
val
)
{
value
.
then
(
function
(
val
)
{
resolve
(
promise
,
val
);
resolve
(
promise
,
val
);
},
function
(
val
)
{
},
function
(
val
)
{
...
...
tests/extension-tests.js
View file @
00d5aaed
/*global RSVP, describe, specify, it, assert */
/*global RSVP, describe, specify, it, assert */
describe
(
"
RSVP extensions
"
,
function
()
{
describe
(
"
RSVP extensions
"
,
function
()
{
describe
(
"
self fulfillment
"
,
function
(){
it
(
"
treats self fulfillment as the recursive base case
"
,
function
(
done
){
var
aDefer
=
new
RSVP
.
defer
(),
bDefer
=
new
RSVP
.
defer
();
aDefer
.
promise
.
then
(
function
(
a
){
setTimeout
(
function
(){
bDefer
.
resolve
(
bDefer
);
},
1
);
return
bDefer
.
promise
;
});
bDefer
.
promise
.
then
(
function
(
c
){
done
();
})
aDefer
.
resolve
(
aDefer
.
promise
);
});
});
describe
(
"
Promise constructor
"
,
function
()
{
describe
(
"
Promise constructor
"
,
function
()
{
it
(
'
should exist and have length 1
'
,
function
()
{
it
(
'
should exist and have length 1
'
,
function
()
{
assert
(
RSVP
.
Promise
);
assert
(
RSVP
.
Promise
);
...
...
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