Документация по либе AdvancedLua

This commit is contained in:
igor
2018-01-09 21:12:03 +03:00
parent 62695c1f93
commit d7cfa257e9
7 changed files with 413 additions and 36 deletions

View File

@@ -126,7 +126,7 @@ function math.doubleToString(num, digitCount)
return string.format("%." .. (digitCount or 1) .. "f", num)
end
function math.shortenNumber(number, digitCount)
function math.shorten(number, digitCount)
local shortcuts = {
"K",
"M",
@@ -146,13 +146,13 @@ end
---------------------------------------------- Filesystem extensions ------------------------------------------------------------------------
-- function filesystem.path(path)
-- return path:match("^(.+%/).") or ""
-- end
function filesystem.path(path)
return path:match("^(.+%/).") or ""
end
-- function filesystem.name(path)
-- return path:match("%/?([^%/]+)%/?$")
-- end
function filesystem.name(path)
return path:match("%/?([^%/]+)%/?$")
end
function filesystem.extension(path, lower)
local extension = path:match("[^%/]+(%.[^%/]+)%/?$")
@@ -258,6 +258,24 @@ function filesystem.directorySize(path)
return size
end
function filesystem.readUnicodeChar(file)
local byteArray = {string.byte(file:read(1))}
local nullBitPosition = 0
for i = 1, 7 do
if bit32.band(bit32.rshift(byteArray[1], 8 - i), 0x1) == 0x0 then
nullBitPosition = i
break
end
end
for i = 1, nullBitPosition - 2 do
table.insert(byteArray, string.byte(file:read(1)))
end
return string.char(table.unpack(byteArray))
end
-------------------------------------------------- Table extensions --------------------------------------------------
local function doSerialize(array, prettyLook, indentationSymbol, indentationSymbolAdder, equalsSymbol, currentRecusrionStack, recursionStackLimit)
@@ -476,24 +494,6 @@ function string.brailleChar(a, b, c, d, e, f, g, h)
return unicode.char(10240 + 128*h + 64*g + 32*f + 16*d + 8*b + 4*e + 2*c + a)
end
function string.readUnicodeChar(file)
local byteArray = {string.byte(file:read(1))}
local nullBitPosition = 0
for i = 1, 7 do
if bit32.band(bit32.rshift(byteArray[1], 8 - i), 0x1) == 0x0 then
nullBitPosition = i
break
end
end
for i = 1, nullBitPosition - 2 do
table.insert(byteArray, string.byte(file:read(1)))
end
return string.char(table.unpack(byteArray))
end
function string.canonicalPath(str)
return string.gsub("/" .. str, "%/+", "/")
end