fix: "filter is not a function" for uniq

This commit is contained in:
Yang Jun
2024-08-23 21:27:53 +08:00
committed by Jun Yang
parent 2d59cff0a6
commit 68387c31ea
5 changed files with 22 additions and 14 deletions
+3
View File
@@ -1,4 +1,5 @@
import { assert } from './assert'
import { toNumber } from './underscore'
export class Limiter {
private message: string
@@ -9,10 +10,12 @@ export class Limiter {
this.limit = limit
}
use (count: number) {
count = toNumber(count)
assert(this.base + count <= this.limit, this.message)
this.base += count
}
check (count: number) {
count = toNumber(count)
assert(count <= this.limit, this.message)
}
}