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
Romain Courteaud
rsvp.js
Commits
8c80ba5e
Commit
8c80ba5e
authored
May 02, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add RSVP.reject
parent
84469f63
Changes
8
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
378 additions
and
256 deletions
+378
-256
browser/rsvp.amd.js
browser/rsvp.amd.js
+4
-2
browser/rsvp.js
browser/rsvp.js
+278
-233
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
browser/rsvp/promise.amd.js
browser/rsvp/promise.amd.js
+40
-19
browser/rsvp/reject.amd.js
browser/rsvp/reject.amd.js
+21
-0
lib/rsvp.js
lib/rsvp.js
+2
-1
lib/rsvp/reject.js
lib/rsvp/reject.js
+15
-0
tests/extension-tests.js
tests/extension-tests.js
+17
-0
No files found.
browser/rsvp.amd.js
View file @
8c80ba5e
define
(
[
"
rsvp/events
"
,
"
rsvp/promise
"
,
"
rsvp/node
"
,
"
rsvp/all
"
,
"
rsvp/hash
"
,
"
rsvp/defer
"
,
"
rsvp/config
"
,
"
rsvp/resolve
"
,
"
exports
"
],
function
(
__dependency1__
,
__dependency2__
,
__dependency3__
,
__dependency4__
,
__dependency5__
,
__dependency6__
,
__dependency7__
,
__dependency8__
,
__exports__
)
{
[
"
rsvp/events
"
,
"
rsvp/promise
"
,
"
rsvp/node
"
,
"
rsvp/all
"
,
"
rsvp/hash
"
,
"
rsvp/defer
"
,
"
rsvp/config
"
,
"
rsvp/resolve
"
,
"
rsvp/reject
"
,
"
exports
"
],
function
(
__dependency1__
,
__dependency2__
,
__dependency3__
,
__dependency4__
,
__dependency5__
,
__dependency6__
,
__dependency7__
,
__dependency8__
,
__
dependency9__
,
__
exports__
)
{
"
use strict
"
;
var
EventTarget
=
__dependency1__
.
EventTarget
;
var
Promise
=
__dependency2__
.
Promise
;
...
...
@@ -10,6 +10,7 @@ define(
var
defer
=
__dependency6__
.
defer
;
var
config
=
__dependency7__
.
config
;
var
resolve
=
__dependency8__
.
resolve
;
var
reject
=
__dependency9__
.
reject
;
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
...
...
@@ -24,4 +25,5 @@ define(
__exports__
.
denodeify
=
denodeify
;
__exports__
.
configure
=
configure
;
__exports__
.
resolve
=
resolve
;
__exports__
.
reject
=
reject
;
});
browser/rsvp.js
View file @
8c80ba5e
This diff is collapsed.
Click to expand it.
browser/rsvp.min.js
View file @
8c80ba5e
This diff is collapsed.
Click to expand it.
browser/rsvp/promise.amd.js
View file @
8c80ba5e
...
...
@@ -45,7 +45,11 @@ define(
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
},
this
);
resolver
(
resolvePromise
,
rejectPromise
);
try
{
resolver
(
resolvePromise
,
rejectPromise
);
}
catch
(
e
)
{
rejectPromise
(
e
);
}
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
...
...
@@ -65,12 +69,8 @@ define(
succeeded
=
true
;
}
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
value
.
then
(
function
(
value
)
{
resolve
(
promise
,
value
);
},
function
(
error
)
{
reject
(
promise
,
error
);
});
if
(
handleThenable
(
promise
,
value
))
{
return
;
}
else
if
(
hasCallback
&&
succeeded
)
{
resolve
(
promise
,
value
);
}
else
if
(
failed
)
{
...
...
@@ -115,24 +115,45 @@ define(
EventTarget
.
mixin
(
Promise
.
prototype
);
function
resolve
(
promise
,
value
)
{
if
(
promise
===
value
)
{
fulfill
(
promise
,
value
);
}
else
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
value
.
then
(
function
(
val
)
{
if
(
value
!==
val
)
{
resolve
(
promise
,
val
);
}
else
{
fulfill
(
promise
,
val
);
}
},
function
(
val
)
{
reject
(
promise
,
val
);
});
}
else
{
}
else
if
(
!
handleThenable
(
promise
,
value
))
{
fulfill
(
promise
,
value
);
}
}
function
handleThenable
(
promise
,
value
)
{
var
then
=
null
;
if
(
objectOrFunction
(
value
))
{
try
{
then
=
value
.
then
;
}
catch
(
e
)
{
reject
(
promise
,
e
);
return
true
;
}
if
(
isFunction
(
then
))
{
try
{
then
.
call
(
value
,
function
(
val
)
{
if
(
value
!==
val
)
{
resolve
(
promise
,
val
);
}
else
{
fulfill
(
promise
,
val
);
}
},
function
(
val
)
{
reject
(
promise
,
val
);
});
}
catch
(
e
)
{
reject
(
promise
,
e
);
}
return
true
;
}
}
return
false
;
}
function
fulfill
(
promise
,
value
)
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
...
...
browser/rsvp/reject.amd.js
0 → 100644
View file @
8c80ba5e
define
(
[
"
rsvp/promise
"
,
"
exports
"
],
function
(
__dependency1__
,
__exports__
)
{
"
use strict
"
;
var
Promise
=
__dependency1__
.
Promise
;
function
objectOrFunction
(
x
)
{
return
typeof
x
===
"
function
"
||
(
typeof
x
===
"
object
"
&&
x
!==
null
);
}
function
reject
(
reason
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
reject
(
reason
);
});
}
__exports__
.
reject
=
reject
;
});
lib/rsvp.js
View file @
8c80ba5e
...
...
@@ -6,9 +6,10 @@ import { hash } from "rsvp/hash";
import
{
defer
}
from
"
rsvp/defer
"
;
import
{
config
}
from
"
rsvp/config
"
;
import
{
resolve
}
from
"
rsvp/resolve
"
;
import
{
reject
}
from
"
rsvp/reject
"
;
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
}
export
{
Promise
,
EventTarget
,
all
,
hash
,
defer
,
denodeify
,
configure
,
resolve
};
export
{
Promise
,
EventTarget
,
all
,
hash
,
defer
,
denodeify
,
configure
,
resolve
,
reject
};
lib/rsvp/reject.js
0 → 100644
View file @
8c80ba5e
import
{
Promise
}
from
"
rsvp/promise
"
;
function
objectOrFunction
(
x
)
{
return
typeof
x
===
"
function
"
||
(
typeof
x
===
"
object
"
&&
x
!==
null
);
}
function
reject
(
reason
)
{
return
new
Promise
(
function
(
resolve
,
reject
)
{
reject
(
reason
);
});
}
export
{
reject
};
tests/extension-tests.js
View file @
8c80ba5e
...
...
@@ -574,6 +574,23 @@ describe("RSVP extensions", function() {
});
});
describe
(
"
RSVP.reject
"
,
function
(){
specify
(
"
it should exist
"
,
function
(){
assert
(
RSVP
.
reject
);
});
describe
(
'
it rejects
'
,
function
(){
var
reason
=
'
the reason
'
,
promise
=
RSVP
.
reject
(
reason
);
promise
.
then
(
function
(){
assert
(
false
,
'
should not fulfill
'
);
},
function
(
actualReason
){
assert
.
equal
(
reason
,
actualReason
);
});
});
});
describe
(
"
RSVP.resolve
"
,
function
(){
specify
(
"
it should exist
"
,
function
(){
assert
(
RSVP
.
resolve
);
...
...
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