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
8c11dcc8
Commit
8c11dcc8
authored
May 10, 2013
by
Stefan Penner
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
refactor RSVP.all to just use a promise directly
parent
55398c39
Changes
4
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
75 additions
and
82 deletions
+75
-82
browser/rsvp.js
browser/rsvp.js
+25
-27
browser/rsvp.min.js
browser/rsvp.min.js
+1
-1
browser/rsvp/all.amd.js
browser/rsvp/all.amd.js
+25
-27
lib/rsvp/all.js
lib/rsvp/all.js
+24
-27
No files found.
browser/rsvp.js
View file @
8c11dcc8
...
...
@@ -32,45 +32,43 @@ var define, requireModule;
})();
define
(
"
rsvp/all
"
,
[
"
rsvp/
defer
"
,
"
exports
"
],
[
"
rsvp/
promise
"
,
"
exports
"
],
function
(
__dependency1__
,
__exports__
)
{
"
use strict
"
;
var
defer
=
__dependency1__
.
defer
;
var
Promise
=
__dependency1__
.
Promise
;
function
all
(
promises
)
{
var
results
=
[],
deferred
=
defer
(),
remaining
=
promises
.
length
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
results
=
[],
remaining
=
promises
.
length
;
if
(
remaining
===
0
)
{
deferred
.
resolve
([]);
resolve
([]);
}
var
resolver
=
function
(
index
)
{
function
resolver
(
index
)
{
return
function
(
value
)
{
resolveAll
(
index
,
value
);
};
};
}
var
resolveAll
=
function
(
index
,
value
)
{
function
resolveAll
(
index
,
value
)
{
results
[
index
]
=
value
;
if
(
--
remaining
===
0
)
{
deferred
.
resolve
(
results
);
resolve
(
results
);
}
}
};
var
rejectAll
=
function
(
error
)
{
deferred
.
reject
(
error
);
};
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
if
(
promises
[
i
]
&&
typeof
promises
[
i
].
then
===
'
function
'
)
{
promises
[
i
].
then
(
resolver
(
i
),
rejectAll
);
promises
[
i
].
then
(
resolver
(
i
),
reject
);
}
else
{
resolveAll
(
i
,
promises
[
i
]);
}
}
return
deferred
.
promise
;
})
;
}
__exports__
.
all
=
all
;
});
...
...
browser/rsvp.min.js
View file @
8c11dcc8
This diff is collapsed.
Click to expand it.
browser/rsvp/all.amd.js
View file @
8c11dcc8
define
(
[
"
rsvp/
defer
"
,
"
exports
"
],
[
"
rsvp/
promise
"
,
"
exports
"
],
function
(
__dependency1__
,
__exports__
)
{
"
use strict
"
;
var
defer
=
__dependency1__
.
defer
;
var
Promise
=
__dependency1__
.
Promise
;
function
all
(
promises
)
{
var
results
=
[],
deferred
=
defer
(),
remaining
=
promises
.
length
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
results
=
[],
remaining
=
promises
.
length
;
if
(
remaining
===
0
)
{
deferred
.
resolve
([]);
resolve
([]);
}
var
resolver
=
function
(
index
)
{
function
resolver
(
index
)
{
return
function
(
value
)
{
resolveAll
(
index
,
value
);
};
};
}
var
resolveAll
=
function
(
index
,
value
)
{
function
resolveAll
(
index
,
value
)
{
results
[
index
]
=
value
;
if
(
--
remaining
===
0
)
{
deferred
.
resolve
(
results
);
resolve
(
results
);
}
}
};
var
rejectAll
=
function
(
error
)
{
deferred
.
reject
(
error
);
};
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
if
(
promises
[
i
]
&&
typeof
promises
[
i
].
then
===
'
function
'
)
{
promises
[
i
].
then
(
resolver
(
i
),
rejectAll
);
promises
[
i
].
then
(
resolver
(
i
),
reject
);
}
else
{
resolveAll
(
i
,
promises
[
i
]);
}
}
return
deferred
.
promise
;
})
;
}
__exports__
.
all
=
all
;
});
lib/rsvp/all.js
View file @
8c11dcc8
import
{
defer
}
from
"
rsvp/defer
"
;
import
{
Promise
}
from
"
rsvp/promise
"
;
function
all
(
promises
)
{
var
results
=
[],
deferred
=
defer
(),
remaining
=
promises
.
length
;
return
new
Promise
(
function
(
resolve
,
reject
)
{
var
results
=
[],
remaining
=
promises
.
length
;
if
(
remaining
===
0
)
{
deferred
.
resolve
([]);
resolve
([]);
}
var
resolver
=
function
(
index
)
{
function
resolver
(
index
)
{
return
function
(
value
)
{
resolveAll
(
index
,
value
);
};
};
}
var
resolveAll
=
function
(
index
,
value
)
{
function
resolveAll
(
index
,
value
)
{
results
[
index
]
=
value
;
if
(
--
remaining
===
0
)
{
deferred
.
resolve
(
results
);
resolve
(
results
);
}
}
};
var
rejectAll
=
function
(
error
)
{
deferred
.
reject
(
error
);
};
for
(
var
i
=
0
;
i
<
promises
.
length
;
i
++
)
{
if
(
promises
[
i
]
&&
typeof
promises
[
i
].
then
===
'
function
'
)
{
promises
[
i
].
then
(
resolver
(
i
),
rejectAll
);
promises
[
i
].
then
(
resolver
(
i
),
reject
);
}
else
{
resolveAll
(
i
,
promises
[
i
]);
}
}
return
deferred
.
promise
;
})
;
}
export
{
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