Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
C
c3-closed
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
charts
c3-closed
Commits
eab844af
Commit
eab844af
authored
Nov 05, 2015
by
Evgeny
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Buffer add finishAll method
parent
efde3872
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
64 additions
and
0 deletions
+64
-0
c3.js
c3.js
+32
-0
buffer.js
src/buffer.js
+32
-0
No files found.
c3.js
View file @
eab844af
...
@@ -117,6 +117,23 @@
...
@@ -117,6 +117,23 @@
};
};
/**
/**
* Resolves while buffer is not empty, but not more than 10 times.
* @function finishAll
* @returns {int} How many times 'finish' was called
*/
Buffer
.
prototype
.
finishAll
=
function
(){
var
self
=
this
;
var
counter
=
0
;
while
(
!
self
.
isEmpty
()
&&
counter
<
10
){
self
.
finish
();
counter
++
;
}
return
counter
;
};
/**
* Adds callback to main queue and starts timer
* Adds callback to main queue and starts timer
* @function onfinish
* @function onfinish
* @param {Function} callback
* @param {Function} callback
...
@@ -161,6 +178,21 @@
...
@@ -161,6 +178,21 @@
return
isUndefined
(
self
.
namedCallbacks
[
id
]);
return
isUndefined
(
self
.
namedCallbacks
[
id
]);
};
};
Buffer
.
prototype
.
isEmpty
=
function
(){
var
self
=
this
;
for
(
var
id
in
self
.
namedCallbacks
){
if
(
self
.
has
(
id
)){
return
false
;
}
}
var
callbacks
=
self
.
callbacks
.
length
==
0
;
var
lastCallbacks
=
self
.
lastCallbacks
.
length
==
0
;
return
callbacks
&&
lastCallbacks
;
};
/**
/**
* Sets timeout after which buffer should fire
* Sets timeout after which buffer should fire
* @function setTimeout
* @function setTimeout
...
...
src/buffer.js
View file @
eab844af
...
@@ -112,6 +112,23 @@ Buffer.prototype.finish = function(){
...
@@ -112,6 +112,23 @@ Buffer.prototype.finish = function(){
};
};
/**
/**
* Resolves while buffer is not empty, but not more than 10 times.
* @function finishAll
* @returns {int} How many times 'finish' was called
*/
Buffer
.
prototype
.
finishAll
=
function
(){
var
self
=
this
;
var
counter
=
0
;
while
(
!
self
.
isEmpty
()
&&
counter
<
10
){
self
.
finish
();
counter
++
;
}
return
counter
;
};
/**
* Adds callback to main queue and starts timer
* Adds callback to main queue and starts timer
* @function onfinish
* @function onfinish
* @param {Function} callback
* @param {Function} callback
...
@@ -156,6 +173,21 @@ Buffer.prototype.has = function(id){
...
@@ -156,6 +173,21 @@ Buffer.prototype.has = function(id){
return
isUndefined
(
self
.
namedCallbacks
[
id
]);
return
isUndefined
(
self
.
namedCallbacks
[
id
]);
};
};
Buffer
.
prototype
.
isEmpty
=
function
(){
var
self
=
this
;
for
(
var
id
in
self
.
namedCallbacks
){
if
(
self
.
has
(
id
)){
return
false
;
}
}
var
callbacks
=
self
.
callbacks
.
length
==
0
;
var
lastCallbacks
=
self
.
lastCallbacks
.
length
==
0
;
return
callbacks
&&
lastCallbacks
;
};
/**
/**
* Sets timeout after which buffer should fire
* Sets timeout after which buffer should fire
* @function setTimeout
* @function setTimeout
...
...
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