Software /
code /
prosody
Changeset
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 |
parents | 11142:552cafd30eb2 |
children | 11157:413bd21ba449 |
files | spec/util_dbuffer_spec.lua util/dbuffer.lua |
diffstat | 2 files changed, 2 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/spec/util_dbuffer_spec.lua Wed Oct 07 13:33:02 2020 +0200 +++ b/spec/util_dbuffer_spec.lua Mon Oct 12 20:20:02 2020 +0200 @@ -42,6 +42,7 @@ assert.truthy(b:write("hello world")); assert.truthy(b:discard(6)); assert.equal(5, b:length()); + assert.equal(5, b:len()); assert.equal("world", b:read(5)); end); end);
--- a/util/dbuffer.lua Wed Oct 07 13:33:02 2020 +0200 +++ b/util/dbuffer.lua Mon Oct 12 20:20:02 2020 +0200 @@ -135,6 +135,7 @@ function dbuffer_methods:length() return self._length; end +dbuffer_methods.len = dbuffer_methods.length; -- strings have :len() dynamic_buffer_mt.__len = dbuffer_methods.length; -- support # operator function dbuffer_methods:collapse(bytes)