From 224f303ee54c54d2147f03010385e8cc48e42869 Mon Sep 17 00:00:00 2001 From: Gregory Anders <8965202+gpanders@users.noreply.github.com> Date: Tue, 31 Oct 2023 09:15:32 -0500 Subject: feat(stdlib): add vim.base64 module (#25843) Add base64 encode() and decode() functions to a vim.base64 module. --- runtime/doc/lua.txt | 22 ++++++++++++++++++++++ runtime/doc/news.txt | 3 +++ runtime/lua/vim/_meta/base64.lua | 13 +++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 runtime/lua/vim/_meta/base64.lua (limited to 'runtime') diff --git a/runtime/doc/lua.txt b/runtime/doc/lua.txt index 1d69b1cc91..aea19d7bf0 100644 --- a/runtime/doc/lua.txt +++ b/runtime/doc/lua.txt @@ -809,6 +809,28 @@ vim.json.encode({obj}) *vim.json.encode()* (string) +============================================================================== +VIM.BASE64 *vim.base64* + +vim.base64.decode({str}) *vim.base64.decode()* + Decode a Base64 encoded string. + + Parameters: ~ + • {str} (string) Base64 encoded string + + Return: ~ + (string) Decoded string + +vim.base64.encode({str}) *vim.base64.encode()* + Encode {str} using Base64. + + Parameters: ~ + • {str} (string) String to encode + + Return: ~ + (string) Encoded string + + ============================================================================== VIM.SPELL *vim.spell* diff --git a/runtime/doc/news.txt b/runtime/doc/news.txt index d1191bef9a..b88b7d164f 100644 --- a/runtime/doc/news.txt +++ b/runtime/doc/news.txt @@ -202,6 +202,9 @@ The following new APIs and features were added. • 'complete' option supports "f" flag for completing buffer names. +• Added |vim.base64.encode()| and |vim.base64.decode()| for encoding and decoding + strings using Base64 encoding. + ============================================================================== CHANGED FEATURES *news-changed* diff --git a/runtime/lua/vim/_meta/base64.lua b/runtime/lua/vim/_meta/base64.lua new file mode 100644 index 0000000000..f25b4af234 --- /dev/null +++ b/runtime/lua/vim/_meta/base64.lua @@ -0,0 +1,13 @@ +--- @meta + +--- Encode {str} using Base64. +--- +--- @param str string String to encode +--- @return string Encoded string +function vim.base64.encode(str) end + +--- Decode a Base64 encoded string. +--- +--- @param str string Base64 encoded string +--- @return string Decoded string +function vim.base64.decode(str) end -- cgit