From 764074d764d901065e353d68f1c5d0a78ec3a6c6 Mon Sep 17 00:00:00 2001 From: Michael Martin Date: Tue, 21 Dec 2021 17:58:03 -0800 Subject: chore: update/cleanup resty.string annotations --- meta/3rd/OpenResty/library/resty.string.lua | 79 +++++++++++++++++++++++++++-- 1 file changed, 74 insertions(+), 5 deletions(-) (limited to 'meta/3rd/OpenResty/library/resty.string.lua') diff --git a/meta/3rd/OpenResty/library/resty.string.lua b/meta/3rd/OpenResty/library/resty.string.lua index 9931b0ec..e9852da8 100644 --- a/meta/3rd/OpenResty/library/resty.string.lua +++ b/meta/3rd/OpenResty/library/resty.string.lua @@ -1,6 +1,75 @@ ---@meta -resty_string={} -function resty_string.to_hex(s) end -resty_string._VERSION="0.11" -function resty_string.atoi(s) end -return resty_string \ No newline at end of file + +--- OpenResty string functions. +--- https://github.com/openresty/lua-resty-string +local str = { + _VERSION = "0.14", +} + + +--- Encode byte string in hexidecimal. +--- +--- This is most useful for retrieving a printable string from a checksum +--- result. +--- +--- Usage: +--- +---```lua +--- local str = require "resty.string" +--- local md5 = require "resty.md5" +--- +--- local sum = md5:new() +--- sum:update("hello") +--- sum:update("goodbye") +--- local digest = sum:final() +--- print(str.to_hex(digest)) --> 441add4718519b71e42d329a834d6d5e +---``` +---@param s string +---@return string hex +function str.to_hex(s) end + +--- Convert an ASCII string to an integer. +--- +--- If the string is not numeric, `-1` is returned. +--- +--- Usage: +--- +---```lua +--- local str = require "resty.string" +--- print(str.atoi("250")) --> 250 +--- print(str.atoi("abc")) --> -1 +---``` +--- +---@param s string +---@return number +function str.atoi(s) end + + +--- A lua-resty-string checksum object. +---@class resty.string.checksum : table +local checksum = { + _VERSION = str._VERSION, +} + +--- Create a new checksum object. +---@return resty.string.checksum? +function checksum:new() end + +--- Add a string to the checksum data. +--- +--- This can be called multiple times. +--- +---@param s string +---@return boolean ok +function checksum:update(s) end + +--- Calculate the final checksum. +---@return string? digest +function checksum:final() end + +--- Reset the checksum object. +---@return boolean ok +function checksum:reset() end + + +return str \ No newline at end of file -- cgit v1.2.3