tokenbucket
Advanced tools
+10
-11
@@ -8,6 +8,6 @@ # Load all required libraries. | ||
| plumber = require 'gulp-plumber' | ||
| jsdoc2md = require("jsdoc-to-markdown") | ||
| concat = require("gulp-concat") | ||
| fs = require("fs") | ||
| coveralls = require('gulp-coveralls') | ||
| jsdoc2md = require 'jsdoc-to-markdown' | ||
| concat = require 'gulp-concat' | ||
| fs = require 'fs' | ||
| coveralls = require 'gulp-coveralls' | ||
@@ -33,3 +33,2 @@ onError = (err) -> | ||
| compilers: 'coffee:coffee-script' | ||
| timeout: 3000 | ||
| .pipe istanbul.writeReports() # Creating the reports after tests run | ||
@@ -41,11 +40,11 @@ | ||
| gulp.task "doc", -> | ||
| src = "lib/**/*.js" | ||
| dest = "README.md" | ||
| gulp.task 'doc', -> | ||
| src = 'lib/**/*.js' | ||
| dest = 'README.md' | ||
| options = { template: 'README.hbs'} | ||
| gutil.log("writing documentation to " + dest) | ||
| gutil.log('writing documentation to ' + dest) | ||
| return jsdoc2md.render(src, options) | ||
| .on "error", (err) -> | ||
| gutil.log(gutil.colors.red("jsdoc2md failed"), err.message) | ||
| .on 'error', (err) -> | ||
| gutil.log(gutil.colors.red('jsdoc2md failed'), err.message) | ||
| .pipe(fs.createWriteStream(dest)) | ||
@@ -52,0 +51,0 @@ |
+1
-1
| { | ||
| "name": "tokenbucket", | ||
| "version": "0.1.2", | ||
| "version": "0.1.3", | ||
| "description": "A flexible rate limiter using different variations of the Token Bucket algorithm, with hierarchy support, and optional persistence in Redis. Useful for limiting API requests, or other tasks that need to be throttled.", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
+3
-3
@@ -25,7 +25,7 @@ [](https://david-dm.org/jesucarr/tokenbucket) | ||
| Contributions are welcome! | ||
| Contributions are welcome! Pull requests should have 100% code coverage. | ||
| ## Credits | ||
| Originally inspired by [limiter](https://github.com/jhurliman/node-rate-limiter) | ||
| Originally inspired by [limiter](https://github.com/jhurliman/node-rate-limiter). | ||
@@ -36,3 +36,3 @@ ## License | ||
| Copyright 2015 JesĂşs Carrera | ||
| Copyright 2015 JesĂşs Carrera - [frontendmatters.com](http://frontendmatters.com) | ||
@@ -39,0 +39,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
+5
-5
@@ -48,7 +48,7 @@ [](https://david-dm.org/jesucarr/tokenbucket) | ||
| | [options.tokensToAddPerInterval] | <code>Number</code> | <code>1</code> | Number of tokens to add to the bucket in one interval. | | ||
| | [options.interval] | <code>Number</code> \| <code>String</code> | <code>1000</code> | The time passing between adding tokens, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. | | ||
| | [options.interval] | <code>Number</code> | <code>String</code> | <code>1000</code> | The time passing between adding tokens, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. | | ||
| | [options.lastFill] | <code>Number</code> | | The timestamp of the last time when tokens where added to the bucket (last interval). | | ||
| | [options.tokensLeft] | <code>Number</code> | <code>size</code> | By default it will initialize full of tokens, but you can set here the number of tokens you want to initialize it with. | | ||
| | [options.spread] | <code>Boolean</code> | <code>false</code> | By default it will wait the interval, and then add all the tokensToAddPerInterval at once. If you set this to true, it will insert fractions of tokens at any given time, spreading the token addition along the interval. | | ||
| | [options.maxWait] | <code>Number</code> \| <code>String</code> | | The maximum time that we would wait for enough tokens to be added, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. If any of the parents in the hierarchy has `maxWait`, we will use the smallest value. | | ||
| | [options.maxWait] | <code>Number</code> | <code>String</code> | | The maximum time that we would wait for enough tokens to be added, in milliseconds or as one of the following strings: 'second', 'minute', 'hour', day'. If any of the parents in the hierarchy has `maxWait`, we will use the smallest value. | | ||
| | [options.redis] | <code>Object</code> | | Options object for Redis | | ||
@@ -220,7 +220,7 @@ | options.redis.bucketName | <code>String</code> | | The name of the bucket to reference it in Redis. Must be unique. | | ||
| Contributions are welcome! | ||
| Contributions are welcome! Pull requests should have 100% code coverage. | ||
| ## Credits | ||
| Originally inspired by [limiter](https://github.com/jhurliman/node-rate-limiter) | ||
| Originally inspired by [limiter](https://github.com/jhurliman/node-rate-limiter). | ||
@@ -231,3 +231,3 @@ ## License | ||
| Copyright 2015 JesĂşs Carrera | ||
| Copyright 2015 JesĂşs Carrera - [frontendmatters.com](http://frontendmatters.com) | ||
@@ -234,0 +234,0 @@ Permission is hereby granted, free of charge, to any person obtaining a copy |
-22
| The MIT License (MIT) | ||
| Copyright 2015 JesĂşs Carrera | ||
| Permission is hereby granted, free of charge, to any person obtaining | ||
| a copy of this software and associated documentation files (the | ||
| "Software"), to deal in the Software without restriction, including | ||
| without limitation the rights to use, copy, modify, merge, publish, | ||
| distribute, sublicense, and/or sell copies of the Software, and to | ||
| permit persons to whom the Software is furnished to do so, subject to | ||
| the following conditions: | ||
| The above copyright notice and this permission notice shall be | ||
| included in all copies or substantial portions of the Software. | ||
| THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, | ||
| EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF | ||
| MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND | ||
| NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE | ||
| LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION | ||
| OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION | ||
| WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
81900
-1.09%9
-10%