Software / code / prosody
Comparison
util/iterators.lua @ 12802:4a8740e01813
Merge 0.12->trunk
| author | Kim Alvefur <zash@zash.se> |
|---|---|
| date | Mon, 12 Dec 2022 07:10:54 +0100 |
| parent | 12744:e894677359e5 |
comparison
equal
deleted
inserted
replaced
| 12801:ebd6b4d8bf04 | 12802:4a8740e01813 |
|---|---|
| 10 | 10 |
| 11 local it = {}; | 11 local it = {}; |
| 12 | 12 |
| 13 local t_insert = table.insert; | 13 local t_insert = table.insert; |
| 14 local next = next; | 14 local next = next; |
| 15 local unpack = table.unpack or unpack; --luacheck: ignore 113 | 15 local unpack = table.unpack; |
| 16 local pack = table.pack or require "util.table".pack; | 16 local pack = table.pack; |
| 17 local type = type; | 17 local type = type; |
| 18 local table, setmetatable = table, setmetatable; | 18 local table, setmetatable = table, setmetatable; |
| 19 | 19 |
| 20 local _ENV = nil; | 20 local _ENV = nil; |
| 21 --luacheck: std none | 21 --luacheck: std none |
| 238 table.insert(self, { f, s, var }, 1); | 238 table.insert(self, { f, s, var }, 1); |
| 239 return self, { self, 1 }; | 239 return self, { self, 1 }; |
| 240 end | 240 end |
| 241 | 241 |
| 242 function it.join(f, s, var) | 242 function it.join(f, s, var) |
| 243 return setmetatable({ {f, s, var} }, join_mt); | 243 local t = setmetatable({ {f, s, var} }, join_mt); |
| 244 return t, { t, 1 }; | |
| 244 end | 245 end |
| 245 | 246 |
| 246 return it; | 247 return it; |