diff --git a/README.md b/README.md index f65ca2a..85ac98b 100644 --- a/README.md +++ b/README.md @@ -133,7 +133,7 @@ If you are not famillier with TypeScript you can go a head and jump to the examp } interface TimeWindowCoreOptions{ timeWindow : number, - bucketsFrequancy : number, + bucketsFrequency : number, defaultValueFactory : defaultValueFactory, onRemoved : onRemoved>; } @@ -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(); @@ -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(); @@ -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(); @@ -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(); diff --git a/examples/single-counter.js b/examples/single-counter.js index 052fe43..fa8754d 100644 --- a/examples/single-counter.js +++ b/examples/single-counter.js @@ -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(); diff --git a/examples/time-counters-rate-limit.js b/examples/time-counters-rate-limit.js index bfb40b0..bf61ec6 100644 --- a/examples/time-counters-rate-limit.js +++ b/examples/time-counters-rate-limit.js @@ -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(); diff --git a/examples/time-counters-server-status-codes.js b/examples/time-counters-server-status-codes.js index cea7ae8..b4d7cc7 100644 --- a/examples/time-counters-server-status-codes.js +++ b/examples/time-counters-server-status-codes.js @@ -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(); diff --git a/examples/time-counters.js b/examples/time-counters.js index bbd6169..3a474c7 100644 --- a/examples/time-counters.js +++ b/examples/time-counters.js @@ -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(); diff --git a/src/core.js b/src/core.js index cf5aa19..add276e 100644 --- a/src/core.js +++ b/src/core.js @@ -155,20 +155,20 @@ 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(); @@ -176,7 +176,7 @@ class TimeWindowCore{ } _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; diff --git a/src/index.d.ts b/src/index.d.ts index 18244b1..e2fe1a4 100644 --- a/src/index.d.ts +++ b/src/index.d.ts @@ -9,7 +9,7 @@ declare module RollingTimeWindow{ } export interface TimeWindowCoreOptions{ timeWindow : number, - bucketsFrequancy : number, + bucketsFrequency : number, defaultValueFactory : defaultValueFactory, onRemoved : onRemoved>; } diff --git a/test/unit-tests/core.js b/test/unit-tests/core.js index 7c7c394..3f170ee 100644 --- a/test/unit-tests/core.js +++ b/test/unit-tests/core.js @@ -826,12 +826,12 @@ 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(){ @@ -839,7 +839,7 @@ describe('TimeWindowCore' , ()=>{ } }; timeWindowOptions.timeWindow = 11; - timeWindowOptions.bucketsFrequancy = 2; + timeWindowOptions.bucketsFrequency = 2; timeWindowOptions.onRemoved = "something"; timeWindowOptions.defaultValueFactory = "something1"; @@ -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(){ @@ -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' , ()=>{ @@ -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); }); @@ -885,7 +885,7 @@ describe('TimeWindowCore' , ()=>{ beforeEach(()=>{ timeWindowOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } @@ -928,7 +928,7 @@ describe('TimeWindowCore' , ()=>{ beforeEach(()=>{ timeWindowOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } @@ -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); }); }); @@ -981,7 +981,7 @@ describe('TimeWindowCore' , ()=>{ beforeEach(()=>{ timeWindowOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } @@ -1035,7 +1035,7 @@ describe('TimeWindowCore' , ()=>{ beforeEach(()=>{ timeWindowCore = new TimeWindowCore({ timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 }); @@ -1053,7 +1053,7 @@ describe('TimeWindowCore' , ()=>{ beforeEach(()=>{ timeWindowCore = new TimeWindowCore({ timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 }); @@ -1078,7 +1078,7 @@ describe('TimeWindowCore' , ()=>{ _createContainerSpy = chai.spy(()=>3); timeWindowOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } @@ -1150,7 +1150,7 @@ describe('TimeWindowCore' , ()=>{ pauseBindSpy = chai.spy(()=>4); timeWindowOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } diff --git a/test/unit-tests/counters.js b/test/unit-tests/counters.js index 5930dd5..c61e942 100644 --- a/test/unit-tests/counters.js +++ b/test/unit-tests/counters.js @@ -20,7 +20,7 @@ describe('WindowMultipleCounters' , ()=>{ )); windowMultipleCountersOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } diff --git a/test/unit-tests/single-counter.js b/test/unit-tests/single-counter.js index a9dbd42..0c32c91 100644 --- a/test/unit-tests/single-counter.js +++ b/test/unit-tests/single-counter.js @@ -37,7 +37,7 @@ describe('WindowSingleCounter' , ()=>{ lastWidnowValueSetterSpy = chai.spy(()=>9); windowSingleConterOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } @@ -146,7 +146,7 @@ describe('WindowSingleCounter' , ()=>{ lastWidnowValueSetterSpy = chai.spy(()=>9); windowSingleConterOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>1, onRemoved : ()=>4 } diff --git a/test/unit-tests/time-based-counters.js b/test/unit-tests/time-based-counters.js index 376f048..931f223 100644 --- a/test/unit-tests/time-based-counters.js +++ b/test/unit-tests/time-based-counters.js @@ -16,7 +16,7 @@ describe('TimeBasedWindowMultipleCounters' , ()=>{ createContainerSpy = chai.spy(()=>9); timeWindowMultipleCountersOptions = { timeWindow : 5000, - bucketsFrequancy : 3, + bucketsFrequency : 3, defaultValueFactory : ()=>{}, onRemoved : ()=>4 }