* Adds content to the tracker and returns whether the limit has been reached. * @param {string} content - Content to add * @returns {boolean} True if the content was added, false if the limit was reached
(content)
| 96 | * @returns {boolean} True if the content was added, false if the limit was reached |
| 97 | */ |
| 98 | add(content) { |
| 99 | if (this.limitReached) { |
| 100 | return false; |
| 101 | } |
| 102 | |
| 103 | const contentSize = Buffer.byteLength(content, "utf8"); |
| 104 | if (this.currentSize + contentSize > this.maxSize) { |
| 105 | this.limitReached = true; |
| 106 | return false; |
| 107 | } |
| 108 | |
| 109 | this.currentSize += contentSize; |
| 110 | return true; |
| 111 | } |
| 112 | |
| 113 | /** |
| 114 | * Checks if the limit has been reached. |
no outgoing calls