We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3aa57d9 commit e7d1506Copy full SHA for e7d1506
src/filters/filters.ts
@@ -100,6 +100,7 @@ const filters = {
100
x: +xs[0],
101
y: NaN,
102
};
103
+ checkTimeUnits(unit);
104
return {
105
meta: {
106
...meta,
@@ -119,6 +120,7 @@ const filters = {
119
120
integrate:
121
(unit: keyof typeof timeUnits = "h") =>
122
({ xs, ys, meta }) => {
123
124
let yAcc = 0;
125
let last = {
126
x: NaN,
@@ -284,3 +286,10 @@ const filters = {
284
286
},
285
287
} satisfies Record<string, (...args: any[]) => FilterFn>;
288
export default filters;
289
+function checkTimeUnits(unit: string) {
290
+ if (!timeUnits[unit]) {
291
+ throw new Error(
292
+ `Unit '${unit}' is not valid, use ${Object.keys(timeUnits)}`
293
+ );
294
+ }
295
+}
0 commit comments