|
1 |
| -## JavaScript [Circular Buffer](http://en.wikipedia.org/wiki/Circular_buffer) Utility |
| 1 | +## CBuffer: JavaScript [Circular Buffer](http://en.wikipedia.org/wiki/Circular_buffer) Utility |
| 2 | + |
| 3 | +[](https://www.npmjs.com/package/CBuffer) |
| 4 | +[](https://travis-ci.org/trevnorris/cbuffer) |
| 5 | +[](./LICENSE) |
| 6 | + |
2 | 7 |
|
3 | 8 | The end goal of this project is to implement the entire JavaScript `Array.prototype`, and some
|
4 |
| -additional utility methods, as a circular buffer. |
| 9 | +additional utility methods, as a **circular buffer**, a **ring buffer** structure. |
5 | 10 |
|
6 | 11 | Note: This is called a circular buffer because of what this library accomplishes, but is implemented
|
7 | 12 | as an Array. This may be confusing for Node users, which may want to use a true Buffer.
|
@@ -39,35 +44,35 @@ myBuff.push(5); // log: 1
|
39 | 44 |
|
40 | 45 | #### Mutator Methods
|
41 | 46 |
|
42 |
| -* pop - Removes the last element from a circular buffer and returns that element. |
43 |
| -* push - Adds one or more elements to the end of a circular buffer and returns the new length. |
44 |
| -* reverse - Reverses the order of the elements of a circular buffer. |
45 |
| -* rotateLeft - Rotates all elements left 1, or n, times. |
46 |
| -* rotateRight - Rotates all elements right 1, or n, times. |
47 |
| -* shift - Removes the first element from a circular buffer and returns that element. |
48 |
| -* sort - Sorts the elements of a circular buffer. Unlike native `sort`, the default comparitor sorts by `a > b`. |
49 |
| -* unshift - Adds one or more elements to the front of a circular buffer and returns the new length. |
| 47 | +* `pop` - Removes the last element from a circular buffer and returns that element. |
| 48 | +* `push` - Adds one or more elements to the end of a circular buffer and returns the new length. |
| 49 | +* `reverse` - Reverses the order of the elements of a circular buffer. |
| 50 | +* `rotateLeft` - Rotates all elements left 1, or n, times. |
| 51 | +* `rotateRight` - Rotates all elements right 1, or n, times. |
| 52 | +* `shift` - Removes the first element from a circular buffer and returns that element. |
| 53 | +* `sort` - Sorts the elements of a circular buffer. Unlike native `sort`, the default comparitor sorts by `a > b`. |
| 54 | +* `unshift` - Adds one or more elements to the front of a circular buffer and returns the new length. |
50 | 55 |
|
51 | 56 | #### Accessor Methods
|
52 | 57 |
|
53 |
| -* indexOf - Returns the first (least) index of an element within the circular buffer equal to the specified value, or -1 if none is found. |
54 |
| -* lastIndexOf - Returns the last (greatest) index of an element within the circular buffer equal to the specified value, or -1 if none is found. |
55 |
| -* sortedIndex - Returns the position some `value` would be inserted into a sorted circular buffer ranked by an optional comparitor. |
| 58 | +* `indexOf` - Returns the first (least) index of an element within the circular buffer equal to the specified value, or -1 if none is found. |
| 59 | +* `lastIndexOf` - Returns the last (greatest) index of an element within the circular buffer equal to the specified value, or -1 if none is found. |
| 60 | +* `sortedIndex` - Returns the position some `value` would be inserted into a sorted circular buffer ranked by an optional comparitor. |
56 | 61 |
|
57 | 62 | #### Iteration Methods
|
58 | 63 |
|
59 |
| -* every - Returns true if every element in the circular buffer satisfies the provided testing function. |
60 |
| -* forEach - Calls a function for each element in the circular buffer. |
61 |
| -* some - Returns true if at least one element in the circular buffer satisfies the provided testing function. |
| 64 | +* `every` - Returns true if every element in the circular buffer satisfies the provided testing function. |
| 65 | +* `forEach` - Calls a function for each element in the circular buffer. |
| 66 | +* `some` - Returns true if at least one element in the circular buffer satisfies the provided testing function. |
62 | 67 |
|
63 | 68 | #### Utility Methods
|
64 | 69 |
|
65 |
| -* empty - Equivalent to setting `Array.length = 0`. |
66 |
| -* fill - Fill with passed argument. Also supports functions. |
67 |
| -* first - Returns first value in circular buffer. |
68 |
| -* last - Returns last value in circular buffer. |
69 |
| -* get - Get value at specific index. |
70 |
| -* set - Set value as specific index. |
71 |
| -* toArray - Return clean ordered array of buffer. |
72 |
| -* overflow - Set to function and will be called when data is about to be overwritten. |
73 |
| -* slice - Return a slice of the buffer as an array. |
| 70 | +* `empty` - Equivalent to setting `Array.length = 0`. |
| 71 | +* `fill` - Fill with passed argument. Also supports functions. |
| 72 | +* `first` - Returns first value in circular buffer. |
| 73 | +* `last` - Returns last value in circular buffer. |
| 74 | +* `get` - Get value at specific index. |
| 75 | +* `set` - Set value as specific index. |
| 76 | +* `toArray` - Return clean ordered array of buffer. |
| 77 | +* `overflow` - Set to function and will be called when data is about to be overwritten. |
| 78 | +* `slice` - Return a slice of the buffer as an array. |
0 commit comments