Skip to content

Commit

Permalink
Async.Promise: Prefer v:t_*
Browse files Browse the repository at this point in the history
  • Loading branch information
rhysd committed Dec 27, 2017
1 parent 522f48e commit 8f6b866
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions autoload/vital/__vital__/Async/Promise.vim
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ let s:PENDING = 0
let s:FULFILLED = 1
let s:REJECTED = 2

let s:DICT_T = type({})
let s:NULL_T = type(v:null)

" @vimlint(EVL103, 1, a:resolve)
" @vimlint(EVL103, 1, a:reject)
function! s:noop(resolve, reject) abort
Expand All @@ -37,7 +34,7 @@ endfunction

" ... is added to use this function as a callback of timer_start()
function! s:_invoke_callback(settled, promise, callback, result, ...) abort
let has_callback = type(a:callback) != s:NULL_T
let has_callback = type(a:callback) != v:t_none
let success = 1
let Err = v:null
if has_callback
Expand Down Expand Up @@ -79,7 +76,7 @@ function! s:_publish(promise, ...) abort
throw 'vital: Async.Promise: Cannot publish a pending promise'
endif
let child = a:promise._children[i]
if type(child) != s:NULL_T
if type(child) != v:t_none
call s:_invoke_callback(settled, child, l:CB, a:promise._result)
else
call l:CB(a:promise._result)
Expand Down Expand Up @@ -223,7 +220,7 @@ function! s:is_available() abort
endfunction

function! s:is_promise(maybe_promise) abort
return type(a:maybe_promise) == s:DICT_T && has_key(a:maybe_promise, '_vital_promise')
return type(a:maybe_promise) == v:t_dict && has_key(a:maybe_promise, '_vital_promise')
endfunction

function! s:_promise_then(...) dict abort
Expand Down

0 comments on commit 8f6b866

Please sign in to comment.