-
Notifications
You must be signed in to change notification settings - Fork 35
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of github.com:meemoo/dataflow
- Loading branch information
Showing
8 changed files
with
142 additions
and
102 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,6 +12,8 @@ | |
}, | ||
dist: { | ||
src: [ | ||
// Libs | ||
'libs/CircularBuffer.js', | ||
// Main | ||
'src/dataflow.js', | ||
'src/state.js', | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
// Thanks bobnice http://stackoverflow.com/a/1583281/592125 | ||
|
||
// Circular buffer storage. Externally-apparent 'length' increases indefinitely | ||
// while any items with indexes below length-n will be forgotten (undefined | ||
// will be returned if you try to get them, trying to set is an exception). | ||
// n represents the initial length of the array, not a maximum | ||
|
||
function CircularBuffer(n) { | ||
this._array= new Array(n); | ||
this.length= 0; | ||
} | ||
CircularBuffer.prototype.toString= function() { | ||
return '[object CircularBuffer('+this._array.length+') length '+this.length+']'; | ||
}; | ||
CircularBuffer.prototype.get= function(i) { | ||
if (i<0 || i<this.length-this._array.length) | ||
return undefined; | ||
return this._array[i%this._array.length]; | ||
}; | ||
CircularBuffer.prototype.set = function(i, v) { | ||
if (i<0 || i<this.length-this._array.length) | ||
throw CircularBuffer.IndexError; | ||
while (i>this.length) { | ||
this._array[this.length%this._array.length] = undefined; | ||
this.length++; | ||
} | ||
this._array[i%this._array.length] = v; | ||
if (i==this.length) | ||
this.length++; | ||
}; | ||
CircularBuffer.prototype.push = function(v) { | ||
this._array[this.length%this._array.length] = v; | ||
this.length++; | ||
}; | ||
CircularBuffer.IndexError= {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters