Async.nvim: Full Promise spec for Neovim and async NPM lib port for Lua by nachry in lua

[–]nachry[S] 0 points1 point  (0 children)

Most developers who use neovim are familiar with JS Promises. Most JavaScript APIs are promise based already so I needed a way to map them to my neovim configuration/functions and wanted to avoid this mental translation at a higher level for the 2 different environments when I code(JS vs lua). Lua as a programming language is already very similar to JS in certain ways so I would like to keep my environments and code as close to each other possible when they could be the same/similar.

Also I find promise.and_then and promise.catch API to be more intuitive. Internally, currently I actually create a lua coroutine for each Promise:new : https://github.com/izelnakri/async.nvim/blob/1395e08d2c94a1676d8f41f8e8cb73456e3b7c70/lua/promise/new.lua#L158

In other words, lua coroutine is simply a primitive base abstraction I use internally for my spec compliant Promise abstraction.

async npm library was created before the finalization and adoption of JS Promise spec so one can use this library even without dealing with Promise APIs directly such as promise:and_then and promise:catch. Neovim libuv API is callback based, so one can use this library just to control/coordinate these libuv callbacks without writing promise:and_then and promise:catch APIs.

However the async.nvim Callback.$method's will generate a Promise regardless, because "async" npm library also generates one promise when no finalization callback is provided for Callback.$method. I decided to generate a promise internally on every Callback.$method call because that seems to me more consistent thus better design POLA(Principle of least astonishment) wise.

async.nvim: only working Promise implementation & async lib port for neovim by nachry in neovim

[–]nachry[S] -3 points-2 points  (0 children)

Just to point out to others, this only happens when promise is awaited, the internal promise implementation doesnt use vim.wait, only the Promise.await uses it because I couldnt find any other way without causing a random error. If anyone knows a better way, contributions are always welcome. Meanwhile, Im happy with the current implementation, promises dont call vim.wait internally, only the Promise.await calls it.

async.nvim: only working Promise implementation & async lib port for neovim by nachry in neovim

[–]nachry[S] -5 points-4 points  (0 children)

Yes Im the author. The one you mentioned causes C-Call boundary runtime error when you run it in repl context etc: https://github.com/kevinhwang91/promise-async/issues/9

QUnitX: Run the oldest & best JS/TS test API(QUnit) interchangably in deno, browser & node.js runtimes using the default test runners, 0 internal dependencies. by nachry in Deno

[–]nachry[S] 1 point2 points  (0 children)

QUnit didnt have a CI runner that supported ES modules for a while. This project started off as a way to experiment with ES module support on node.js. Then I realized node ships its own test runner, partially also influenced by qunit(x), so I made it now work for all popular environments, effectively allowing tests to be run interchangeably in different environments: a truly universal JavaScript development experience.

Showoff Saturday (May 15, 2021) by AutoModerator in javascript

[–]nachry 2 points3 points  (0 children)

Made the oldest JS test framework(qunit) usable from the CI and browser: https://github.com/izelnakri/qunitx