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
89646829
Commit
89646829
authored
Feb 25, 2020
by
Romain Courteaud
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Reduce number of array"
This reverts commit
974b8596
.
parent
9b922f24
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
26 additions
and
18 deletions
+26
-18
lib/rsvp/queue.js
lib/rsvp/queue.js
+26
-18
No files found.
lib/rsvp/queue.js
View file @
89646829
...
@@ -12,30 +12,39 @@ function ResolvedQueueError(message) {
...
@@ -12,30 +12,39 @@ function ResolvedQueueError(message) {
ResolvedQueueError
.
prototype
=
new
Error
();
ResolvedQueueError
.
prototype
=
new
Error
();
ResolvedQueueError
.
prototype
.
constructor
=
ResolvedQueueError
;
ResolvedQueueError
.
prototype
.
constructor
=
ResolvedQueueError
;
var
last_promise
,
i
;
var
Queue
=
function
()
{
var
Queue
=
function
()
{
if
(
!
(
this
instanceof
Queue
))
{
if
(
!
(
this
instanceof
Queue
))
{
return
new
Queue
();
return
new
Queue
();
}
}
var
promise_stack
=
[]
,
var
queue
=
this
,
// handleQueue
promise_stack
=
[],
detect_end_index
=
1
;
then_stack
=
[]
;
Promise
.
call
(
this
,
function
(
resolveQueue
,
rejectQueue
)
{
Promise
.
call
(
queue
,
function
(
resolveQueue
,
rejectQueue
)
{
var
detectQueueSuccess
,
var
detectQueueSuccess
,
detectQueueError
;
detectQueueError
;
function
handleQueue
()
{
function
handleQueue
()
{
if
(
promise_stack
.
length
===
detect_end_index
)
{
if
(
then_stack
.
length
===
0
)
{
return
true
;
return
true
;
}
}
promise_stack
.
splice
(
0
,
detect_end_index
);
last_promise
=
promise_stack
[
promise_stack
.
length
-
1
];
promise_stack
.
splice
(
0
,
promise_stack
.
length
);
for
(
i
=
then_stack
.
length
-
1
;
i
>=
0
;
i
-=
2
)
{
last_promise
=
last_promise
.
then
(
then_stack
[
i
-
1
],
then_stack
[
i
]);
promise_stack
.
push
(
last_promise
);
}
then_stack
.
splice
(
0
,
then_stack
.
length
);
promise_stack
.
push
(
promise_stack
.
push
(
promise_stack
[
promise_stack
.
length
-
1
]
.
then
(
detectQueueSuccess
,
last_promise
.
then
(
detectQueueSuccess
,
detectQueueError
)
detectQueueError
)
);
);
detect_end_index
=
promise_stack
.
length
;
return
false
;
return
false
;
}
}
...
@@ -55,29 +64,28 @@ var Queue = function() {
...
@@ -55,29 +64,28 @@ var Queue = function() {
// Resolve by default
// Resolve by default
promise_stack
.
push
(
promise_stack
.
push
(
resolve
().
then
(
detectQueueSuccess
)
resolve
().
then
(
detectQueueSuccess
,
detectQueueError
)
);
);
},
function
()
{
},
function
()
{
// Cancel all created promises
// Cancel all created promises
var
i
;
var
i
;
then_stack
.
splice
(
0
,
then_stack
.
length
);
for
(
i
=
0
;
i
<
promise_stack
.
length
;
i
+=
1
)
{
for
(
i
=
0
;
i
<
promise_stack
.
length
;
i
+=
1
)
{
promise_stack
[
i
].
cancel
();
promise_stack
[
i
].
cancel
();
}
}
});
});
this
.
push
=
function
(
done
,
fail
)
{
queue
.
push
=
function
(
done
,
fail
)
{
if
(
this
.
isFulfilled
||
this
.
isRejected
)
{
if
(
queue
.
isFulfilled
||
queue
.
isRejected
)
{
throw
new
ResolvedQueueError
();
throw
new
ResolvedQueueError
();
}
}
promise_stack
.
push
(
then_stack
.
unshift
(
done
,
fail
);
promise_stack
[
promise_stack
.
length
-
1
].
then
(
done
,
fail
)
return
queue
;
);
return
this
;
};
};
return
this
;
return
queue
;
};
};
Queue
.
prototype
=
Object
.
create
(
Promise
.
prototype
);
Queue
.
prototype
=
Object
.
create
(
Promise
.
prototype
);
...
...
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