Skip to content

Commit

Permalink
feat: 🎸 increase default limit and add new size property
Browse files Browse the repository at this point in the history
  • Loading branch information
mjancarik committed Jan 19, 2023
1 parent 91ddf9b commit 2527f25
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ Configure options for the new instance of MetricsHistory.
##### options.limit?

Type: `integer`
Default: `10`
Default: `60`

FIFO size of array for calculating percentile.

Expand Down
6 changes: 5 additions & 1 deletion src/MetricsHistory.mjs
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
import { Observer } from '@esmj/observable';

export class MetricsHistory extends Observer {
#options = { limit: 10 };
#options = { limit: 60 };
#history = [];

constructor(options) {
super();
this.#options = { ...this.#options, ...options };
}

get size() {
return this.#history.length;
}

complete() {
this.#history = [];
}
Expand Down
1 change: 1 addition & 0 deletions src/__tests__/MetricsHistorySpec.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -70,5 +70,6 @@ describe('MetricsHistory', () => {
expect(percentile25).toMatchInlineSnapshot(`4`);
expect(percentile20).toMatchInlineSnapshot(`2.6000000000000005`);
expect(percentile0).toMatchInlineSnapshot(`1`);
expect(metricsHistory.size).toEqual(6);
});
});

0 comments on commit 2527f25

Please sign in to comment.