Software /
code /
prosody
Comparison
util/dbuffer.lua @ 11156:a8ef69f7fc35 0.11
util.dbuffer: Expose length as :len() method, like strings
Ref #1598
author | Kim Alvefur <zash@zash.se> |
---|---|
date | Mon, 12 Oct 2020 20:20:02 +0200 |
parent | 11104:6632acc96cf6 |
child | 11158:3a72cb126d6c |
child | 11189:0ff148362a3d |
comparison
equal
deleted
inserted
replaced
11142:552cafd30eb2 | 11156:a8ef69f7fc35 |
---|---|
133 end | 133 end |
134 | 134 |
135 function dbuffer_methods:length() | 135 function dbuffer_methods:length() |
136 return self._length; | 136 return self._length; |
137 end | 137 end |
138 dbuffer_methods.len = dbuffer_methods.length; -- strings have :len() | |
138 dynamic_buffer_mt.__len = dbuffer_methods.length; -- support # operator | 139 dynamic_buffer_mt.__len = dbuffer_methods.length; -- support # operator |
139 | 140 |
140 function dbuffer_methods:collapse(bytes) | 141 function dbuffer_methods:collapse(bytes) |
141 bytes = bytes or self._length; | 142 bytes = bytes or self._length; |
142 | 143 |