Skip to content

Commit

Permalink
Fix warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
notomo committed Sep 21, 2024
1 parent bfee746 commit 98ec429
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
6 changes: 3 additions & 3 deletions doc/promise.nvim.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ next({on_fullfilled}, {on_rejected}) *promise:next()*
Equivalents to JavaScript's Promise.then.

Parameters: ~
{on_fullfilled} ((fun(...:any):any)?) A callback on fullfilled.
{on_rejected} ((fun(...:any):any)?) A callback on rejected.
{on_fullfilled} ((fun(...:any):(...:any))?) A callback on fullfilled.
{on_rejected} ((fun(...:any):(...:any))?) A callback on rejected.

Return: ~
(Promise)
Expand All @@ -46,7 +46,7 @@ catch({on_rejected}) *promise:catch()*
Equivalents to JavaScript's Promise.catch.

Parameters: ~
{on_rejected} ((fun(...:any):any)?) A callback on rejected.
{on_rejected} ((fun(...:any):(...:any))?) A callback on rejected.

Return: ~
(Promise)
Expand Down
14 changes: 11 additions & 3 deletions lua/promise/init.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---@diagnostic disable: invisible
local vim = vim

local PackedValue = {}
Expand Down Expand Up @@ -26,6 +27,13 @@ function PackedValue.first(self)
end

--- @class Promise
--- @field private _status "pending"|"fulfilled"|"rejected"
--- @field private _value any
--- @field private _queued Promise[]
--- @field private _unhandled_detector table
--- @field private _on_fullfilled (fun(...:any):(...:any))?
--- @field private _on_rejected (fun(...:any):(...:any))?
--- @field private _handled boolean
local Promise = {
_is_promise = true,
}
Expand Down Expand Up @@ -213,8 +221,8 @@ function Promise._start_reject(self, value)
end

--- Equivalents to JavaScript's Promise.then.
--- @param on_fullfilled (fun(...:any):any)?: A callback on fullfilled.
--- @param on_rejected (fun(...:any):any)?: A callback on rejected.
--- @param on_fullfilled (fun(...:any):(...:any))?: A callback on fullfilled.
--- @param on_rejected (fun(...:any):(...:any))?: A callback on rejected.
--- @return Promise
function Promise.next(self, on_fullfilled, on_rejected)
vim.validate({
Expand All @@ -235,7 +243,7 @@ function Promise.next(self, on_fullfilled, on_rejected)
end

--- Equivalents to JavaScript's Promise.catch.
--- @param on_rejected (fun(...:any):any)?: A callback on rejected.
--- @param on_rejected (fun(...:any):(...:any))?: A callback on rejected.
--- @return Promise
function Promise.catch(self, on_rejected)
return self:next(nil, on_rejected)
Expand Down

0 comments on commit 98ec429

Please sign in to comment.