@icgio/icg-utils 1.8.0 → 1.8.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.js CHANGED
@@ -9,6 +9,7 @@ module.exports = {
9
9
  mail: require('./lib/mail.js'),
10
10
  observable: require('./lib/observable.js'),
11
11
  ohlcv: require('./lib/ohlcv'),
12
+ rate_limiter_logger: require('./lib/rate-limit-logger.js'),
12
13
  rate_limiter: require('./lib/rate-limiter.js'),
13
14
  utils: require('./lib/utils.js'),
14
15
  constants: {
@@ -0,0 +1,15 @@
1
+ class RateLimitedLogger {
2
+ constructor(defaultLimit = 1000) {
3
+ this.defaultLimit = defaultLimit // Default time in milliseconds
4
+ this.lastLogTime = 0
5
+ }
6
+ log(message, limit = this.defaultLimit) {
7
+ const now = Date.now()
8
+ if (now - this.lastLogTime >= limit) {
9
+ console.log(message)
10
+ this.lastLogTime = now
11
+ }
12
+ }
13
+ }
14
+
15
+ module.exports = RateLimitedLogger
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@icgio/icg-utils",
3
- "version": "1.8.0",
3
+ "version": "1.8.1",
4
4
  "description": "Utils package.",
5
5
  "main": "index.js",
6
6
  "directories": {