Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

typo fix #3

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ If you are not famillier with TypeScript you can go a head and jump to the examp
}
interface TimeWindowCoreOptions<T>{
timeWindow : number,
bucketsFrequancy : number,
bucketsFrequency : number,
defaultValueFactory : defaultValueFactory<T>,
onRemoved : onRemoved<BucketValue<T>>;
}
Expand Down Expand Up @@ -222,7 +222,7 @@ const {TimeBasedWindowMultipleCounters} = require('rolling-windows');

const rollingTimeCounters = new TimeBasedWindowMultipleCounters({
timeWindow : 1000*60, //I want to have information up to 1 minute
bucketsFrequancy : 1000*10,//I want to have bucket every 10 seconds
bucketsFrequency : 1000*10,//I want to have bucket every 10 seconds
});
//Start the internal
rollingTimeCounters.start();
Expand All @@ -243,7 +243,7 @@ const {WindowSingleCounter} = require('rolling-windows');

const counter = new WindowSingleCounter({
timeWindow : 1000*60*60, //I want to have information up tp an hour
bucketsFrequancy : 1000*20,//I want to have bucket per 20 seconds
bucketsFrequency : 1000*20,//I want to have bucket per 20 seconds
});
//increase
counter.increase();
Expand All @@ -267,7 +267,7 @@ const {TimeBasedWindowMultipleCounters} = require('rolling-windows');

const rollingTimeCounters = new TimeBasedWindowMultipleCounters({
timeWindow : 1000*20, //I want to have information up to 20 seconds
bucketsFrequancy : 1000*2,//I want to have bucket per 2 seconds
bucketsFrequency : 1000*2,//I want to have bucket per 2 seconds
});
rollingTimeCounters.start();

Expand Down Expand Up @@ -328,7 +328,7 @@ const querystring = require('querystring');

const rollingTimeCounters = new TimeBasedWindowMultipleCounters({
timeWindow : 1000*60*60, //I want to have information up to 1 hour
bucketsFrequancy : 1000*2,//I want to have bucket every 1 minute
bucketsFrequency : 1000*2,//I want to have bucket every 1 minute
});
//Start the internal interval
rollingTimeCounters.start();
Expand Down
2 changes: 1 addition & 1 deletion examples/single-counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {WindowSingleCounter} = require('../src/single-counter');

const counter = new WindowSingleCounter({
timeWindow : 1000*60*60, //I want to have information up tp an hour
bucketsFrequancy : 1000*20,//I want to have bucket per 20 seconds
bucketsFrequency : 1000*20,//I want to have bucket per 20 seconds
});
//increase
counter.increase();
Expand Down
2 changes: 1 addition & 1 deletion examples/time-counters-rate-limit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const querystring = require('querystring');

const rollingTimeCounters = new TimeBasedWindowMultipleCounters({
timeWindow : 1000*60*60, //I want to have information up to 1 hour
bucketsFrequancy : 1000*2,//I want to have bucket every 1 minute
bucketsFrequency : 1000*2,//I want to have bucket every 1 minute
});
//Start the internal interval
rollingTimeCounters.start();
Expand Down
2 changes: 1 addition & 1 deletion examples/time-counters-server-status-codes.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {TimeBasedWindowMultipleCounters} = require('../src/time-based-counters');

const rollingTimeCounters = new TimeBasedWindowMultipleCounters({
timeWindow : 1000*20, //I want to have information up to 20 seconds
bucketsFrequancy : 1000*2,//I want to have bucket per 2 seconds
bucketsFrequency : 1000*2,//I want to have bucket per 2 seconds
});
rollingTimeCounters.start();

Expand Down
2 changes: 1 addition & 1 deletion examples/time-counters.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const {TimeBasedWindowMultipleCounters} = require('../src/counters');

const rollingTimeCounters = new TimeBasedWindowMultipleCounters({
timeWindow : 1000*60, //I want to have information up to 1 minute
bucketsFrequancy : 1000*10,//I want to have bucket every 10 seconds
bucketsFrequency : 1000*10,//I want to have bucket every 10 seconds
});
//Start the internal
rollingTimeCounters.start();
Expand Down
10 changes: 5 additions & 5 deletions src/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,28 +155,28 @@ class TimeWindowCore{
}
constructor({
timeWindow,
bucketsFrequancy,
bucketsFrequency,
defaultValueFactory,
onRemoved
}){

this._createContainer(
parseInt(timeWindow/bucketsFrequancy),
parseInt(timeWindow/bucketsFrequency),
onRemoved,
defaultValueFactory
);
this.bucketsFrequancy = bucketsFrequancy;
this.bucketsFrequency = bucketsFrequency;
}
_getTimeToNextTick(){
return (this.lastTick + this.bucketsFrequancy) - Date.now();
return (this.lastTick + this.bucketsFrequency) - Date.now();
}
_onIntervalTick(){
this.lastTick = Date.now();
this.tick();
}
_startInterval(){
this._stopInterval();
this._interval = this._setInterval(this._onIntervalTick.bind(this), this.bucketsFrequancy);
this._interval = this._setInterval(this._onIntervalTick.bind(this), this.bucketsFrequency);
}
get _setInterval(){
return setInterval;
Expand Down
2 changes: 1 addition & 1 deletion src/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ declare module RollingTimeWindow{
}
export interface TimeWindowCoreOptions<T>{
timeWindow : number,
bucketsFrequancy : number,
bucketsFrequency : number,
defaultValueFactory : defaultValueFactory<T>,
onRemoved : onRemoved<WindowBucket<T>>;
}
Expand Down
28 changes: 14 additions & 14 deletions test/unit-tests/core.js
Original file line number Diff line number Diff line change
Expand Up @@ -826,20 +826,20 @@ describe('TimeWindowCore' , ()=>{
beforeEach(()=>{
timeWindowOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
});
it('Should call _createContainer with correct timeWindow/bucketsFrequancy',()=>{
it('Should call _createContainer with correct timeWindow/bucketsFrequency',()=>{
const spy = chai.spy(()=>5);
class DummyTimeWindowCore extends TimeWindowCore{
get _createContainer(){
return spy;
}
};
timeWindowOptions.timeWindow = 11;
timeWindowOptions.bucketsFrequancy = 2;
timeWindowOptions.bucketsFrequency = 2;
timeWindowOptions.onRemoved = "something";
timeWindowOptions.defaultValueFactory = "something1";

Expand All @@ -851,7 +851,7 @@ describe('TimeWindowCore' , ()=>{
timeWindowOptions.defaultValueFactory
);
});
it('Should set bucketsFrequancy' , ()=>{
it('Should set bucketsFrequency' , ()=>{
const spy = chai.spy(()=>5);
class DummyTimeWindowCore extends TimeWindowCore{
get _createContainer(){
Expand All @@ -860,7 +860,7 @@ describe('TimeWindowCore' , ()=>{
};
timeWindowCore = new DummyTimeWindowCore(timeWindowOptions);

expect(timeWindowCore.bucketsFrequancy).to.equal(timeWindowOptions.bucketsFrequancy)
expect(timeWindowCore.bucketsFrequency).to.equal(timeWindowOptions.bucketsFrequency)
})
});
describe('#_getTimeToNextTick' , ()=>{
Expand All @@ -874,7 +874,7 @@ describe('TimeWindowCore' , ()=>{
it('Should calculate time to next tick' , ()=>{
const result = TimeWindowCore.prototype._getTimeToNextTick.call({
lastTick : 10,
bucketsFrequancy : 10
bucketsFrequency : 10
});
expect(result).to.be.equal(11);
});
Expand All @@ -885,7 +885,7 @@ describe('TimeWindowCore' , ()=>{
beforeEach(()=>{
timeWindowOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down Expand Up @@ -928,7 +928,7 @@ describe('TimeWindowCore' , ()=>{
beforeEach(()=>{
timeWindowOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down Expand Up @@ -971,7 +971,7 @@ describe('TimeWindowCore' , ()=>{
timeWindowCore = new DummyTimeWindowCore(timeWindowOptions);
timeWindowCore._startInterval();

expect(spyInterval).to.have.been.called.with(spyOnIntervalTick , timeWindowOptions.bucketsFrequancy);
expect(spyInterval).to.have.been.called.with(spyOnIntervalTick , timeWindowOptions.bucketsFrequency);

});
});
Expand All @@ -981,7 +981,7 @@ describe('TimeWindowCore' , ()=>{
beforeEach(()=>{
timeWindowOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down Expand Up @@ -1035,7 +1035,7 @@ describe('TimeWindowCore' , ()=>{
beforeEach(()=>{
timeWindowCore = new TimeWindowCore({
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
});
Expand All @@ -1053,7 +1053,7 @@ describe('TimeWindowCore' , ()=>{
beforeEach(()=>{
timeWindowCore = new TimeWindowCore({
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
});
Expand All @@ -1078,7 +1078,7 @@ describe('TimeWindowCore' , ()=>{
_createContainerSpy = chai.spy(()=>3);
timeWindowOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down Expand Up @@ -1150,7 +1150,7 @@ describe('TimeWindowCore' , ()=>{
pauseBindSpy = chai.spy(()=>4);
timeWindowOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/counters.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ describe('WindowMultipleCounters' , ()=>{
));
windowMultipleCountersOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down
4 changes: 2 additions & 2 deletions test/unit-tests/single-counter.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ describe('WindowSingleCounter' , ()=>{
lastWidnowValueSetterSpy = chai.spy(()=>9);
windowSingleConterOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down Expand Up @@ -146,7 +146,7 @@ describe('WindowSingleCounter' , ()=>{
lastWidnowValueSetterSpy = chai.spy(()=>9);
windowSingleConterOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>1,
onRemoved : ()=>4
}
Expand Down
2 changes: 1 addition & 1 deletion test/unit-tests/time-based-counters.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ describe('TimeBasedWindowMultipleCounters' , ()=>{
createContainerSpy = chai.spy(()=>9);
timeWindowMultipleCountersOptions = {
timeWindow : 5000,
bucketsFrequancy : 3,
bucketsFrequency : 3,
defaultValueFactory : ()=>{},
onRemoved : ()=>4
}
Expand Down