13 759
правок
Изменения
Нет описания правки
* «вроде что-то древнее»
* ПОЛИЗ?!!!!
== Lua @@ ==
<source lang="lua">
function Encoder.put(self, chunk)
if self.buffersize < 2 then
coroutine.yield(chunk)
else
if #self.buffer + #chunk > self.buffersize then
local written = 0
local fbuffer = self.buffersize - #self.buffer
coroutine.yield(self.buffer .. chunk:sub(written + 1, fbuffer))
written = fbuffer
while #chunk - written > self.buffersize do
fbuffer = written + self.buffersize
coroutine.yield(chunk:sub(written + 1, fbuffer))
written = fbuffer
end
self.buffer = chunk:sub(written + 1)
else
self.buffer = self.buffer .. chunk
end
end
end
</source>
* Для полноты картины
== JS @@ ==