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
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
(
define
(
[
"
rsvp/events
"
,
"
rsvp/promise
"
,
"
rsvp/node
"
,
"
rsvp/all
"
,
"
rsvp/hash
"
,
"
rsvp/defer
"
,
"
rsvp/config
"
,
"
rsvp/resolve
"
,
"
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__
,
__exports__
)
{
function
(
__dependency1__
,
__dependency2__
,
__dependency3__
,
__dependency4__
,
__dependency5__
,
__dependency6__
,
__dependency7__
,
__dependency8__
,
__
dependency9__
,
__
exports__
)
{
"
use strict
"
;
"
use strict
"
;
var
EventTarget
=
__dependency1__
.
EventTarget
;
var
EventTarget
=
__dependency1__
.
EventTarget
;
var
Promise
=
__dependency2__
.
Promise
;
var
Promise
=
__dependency2__
.
Promise
;
...
@@ -10,6 +10,7 @@ define(
...
@@ -10,6 +10,7 @@ define(
var
defer
=
__dependency6__
.
defer
;
var
defer
=
__dependency6__
.
defer
;
var
config
=
__dependency7__
.
config
;
var
config
=
__dependency7__
.
config
;
var
resolve
=
__dependency8__
.
resolve
;
var
resolve
=
__dependency8__
.
resolve
;
var
reject
=
__dependency9__
.
reject
;
function
configure
(
name
,
value
)
{
function
configure
(
name
,
value
)
{
config
[
name
]
=
value
;
config
[
name
]
=
value
;
...
@@ -24,4 +25,5 @@ define(
...
@@ -24,4 +25,5 @@ define(
__exports__
.
denodeify
=
denodeify
;
__exports__
.
denodeify
=
denodeify
;
__exports__
.
configure
=
configure
;
__exports__
.
configure
=
configure
;
__exports__
.
resolve
=
resolve
;
__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(
...
@@ -45,7 +45,11 @@ define(
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
this
.
trigger
(
'
error
'
,
{
detail
:
event
.
detail
});
},
this
);
},
this
);
resolver
(
resolvePromise
,
rejectPromise
);
try
{
resolver
(
resolvePromise
,
rejectPromise
);
}
catch
(
e
)
{
rejectPromise
(
e
);
}
};
};
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
var
invokeCallback
=
function
(
type
,
promise
,
callback
,
event
)
{
...
@@ -65,12 +69,8 @@ define(
...
@@ -65,12 +69,8 @@ define(
succeeded
=
true
;
succeeded
=
true
;
}
}
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
if
(
handleThenable
(
promise
,
value
))
{
value
.
then
(
function
(
value
)
{
return
;
resolve
(
promise
,
value
);
},
function
(
error
)
{
reject
(
promise
,
error
);
});
}
else
if
(
hasCallback
&&
succeeded
)
{
}
else
if
(
hasCallback
&&
succeeded
)
{
resolve
(
promise
,
value
);
resolve
(
promise
,
value
);
}
else
if
(
failed
)
{
}
else
if
(
failed
)
{
...
@@ -115,24 +115,45 @@ define(
...
@@ -115,24 +115,45 @@ define(
EventTarget
.
mixin
(
Promise
.
prototype
);
EventTarget
.
mixin
(
Promise
.
prototype
);
function
resolve
(
promise
,
value
)
{
function
resolve
(
promise
,
value
)
{
if
(
promise
===
value
)
{
if
(
promise
===
value
)
{
fulfill
(
promise
,
value
);
fulfill
(
promise
,
value
);
}
else
if
(
objectOrFunction
(
value
)
&&
isFunction
(
value
.
then
))
{
}
else
if
(
!
handleThenable
(
promise
,
value
))
{
value
.
then
(
function
(
val
)
{
if
(
value
!==
val
)
{
resolve
(
promise
,
val
);
}
else
{
fulfill
(
promise
,
val
);
}
},
function
(
val
)
{
reject
(
promise
,
val
);
});
}
else
{
fulfill
(
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
)
{
function
fulfill
(
promise
,
value
)
{
config
.
async
(
function
()
{
config
.
async
(
function
()
{
promise
.
trigger
(
'
promise:resolved
'
,
{
detail
:
value
});
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";
...
@@ -6,9 +6,10 @@ import { hash } from "rsvp/hash";
import
{
defer
}
from
"
rsvp/defer
"
;
import
{
defer
}
from
"
rsvp/defer
"
;
import
{
config
}
from
"
rsvp/config
"
;
import
{
config
}
from
"
rsvp/config
"
;
import
{
resolve
}
from
"
rsvp/resolve
"
;
import
{
resolve
}
from
"
rsvp/resolve
"
;
import
{
reject
}
from
"
rsvp/reject
"
;
function
configure
(
name
,
value
)
{
function
configure
(
name
,
value
)
{
config
[
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() {
...
@@ -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
(){
describe
(
"
RSVP.resolve
"
,
function
(){
specify
(
"
it should exist
"
,
function
(){
specify
(
"
it should exist
"
,
function
(){
assert
(
RSVP
.
resolve
);
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