-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add README.md, npmignore, and travis.yml
- Loading branch information
Showing
4 changed files
with
73 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
test | ||
coverage | ||
.travis.yml | ||
.mocharc.yml |
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,15 @@ | ||
language: node_js | ||
sudo: false | ||
node_js: | ||
- "10" | ||
- "12" | ||
- "node" | ||
|
||
before_script: | ||
- "npm -g install npm@latest" | ||
|
||
script: | ||
- "npm run cover" | ||
|
||
after_script: | ||
- "cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# EventCounter | ||
|
||
This is a JavaScript library that helps record (any kind of) incremental events, and query the number of events during the specific spantime. | ||
|
||
## Install | ||
|
||
```bash | ||
npm install event-counter | ||
``` | ||
|
||
## Example | ||
|
||
```js | ||
const EventCounter = require('event-counter'); | ||
|
||
const eventCounter = EventCounter(); | ||
eventCounter.increment(); | ||
eventCounter.increment(); | ||
eventCounter.increment(); | ||
|
||
// query the number of the events ocurred in last 1 sec | ||
eventCounter.query(1000); // return 3 | ||
|
||
// after 10 seconds ... | ||
eventCounter.increment(); | ||
eventCounter.increment(); | ||
|
||
// query the number of the events ocurred in last 1 sec | ||
eventCounter.query(1000); // retrun 2 | ||
``` | ||
|
||
## Test | ||
|
||
```bash | ||
git clone https://github.com/zlargon/EventCounter.git | ||
|
||
# npm | ||
npm install | ||
npm test # unit test | ||
npm run cover # generate code coverage report to ./coverage/lcov-report/index.html | ||
``` | ||
|
||
## Licence | ||
|
||
MIT |
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