Skip to content

Commit eadf3ce

Browse files
Setup Continuous Integration
Changes: * Add travis.yml * Add CI badges to README * Add licence TAG to README * Improved formating of README and add ring mention * Add keywords to package.json for better searchability on npm PR-URL: #27
1 parent 3c4aa55 commit eadf3ce

File tree

3 files changed

+56
-26
lines changed

3 files changed

+56
-26
lines changed

.travis.yml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
language: node_js
2+
3+
node_js:
4+
- 4
5+
- 5
6+
- 6
7+
- 7
8+
- 8
9+
- 9
10+
- 10
11+
12+
script:
13+
- npm test
14+
15+
cache:
16+
directories:
17+
- node_modules

README.md

+30-25
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,12 @@
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+
[![npm](https://img.shields.io/npm/v/CBuffer.svg)](https://www.npmjs.com/package/CBuffer)
4+
[![Build Status](https://travis-ci.org/trevnorris/cbuffer.svg?branch=master)](https://travis-ci.org/trevnorris/cbuffer)
5+
[![npm license](https://img.shields.io/npm/l/CBuffer.svg)](./LICENSE)
6+
27

38
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.
510

611
Note: This is called a circular buffer because of what this library accomplishes, but is implemented
712
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
3944

4045
#### Mutator Methods
4146

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.
5055

5156
#### Accessor Methods
5257

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.
5661

5762
#### Iteration Methods
5863

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.
6267

6368
#### Utility Methods
6469

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.

package.json

+9-1
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,23 @@
99
"email" : "[email protected]",
1010
"url" : "http://trevorjnorris.com"
1111
},
12+
"license": "MIT",
1213
"licenses" : [{
1314
"type" : "MIT",
1415
"url" : "http://www.opensource.org/licenses/mit-license.php"
1516
}],
17+
"keywords": [
18+
"circular buffer",
19+
"ring",
20+
"circular",
21+
"buffer",
22+
"data structure"
23+
],
1624
"devDependencies" : {
1725
"vows" : "latest"
1826
},
1927
"scripts" : {
20-
"test" : "node ./node_modules/.bin/vows"
28+
"test" : "vows"
2129
},
2230
"repository" : {
2331
"type" : "git",

0 commit comments

Comments
 (0)