Skip to content

Latest commit

 

History

History
61 lines (51 loc) · 1.42 KB

README.md

File metadata and controls

61 lines (51 loc) · 1.42 KB

kagura-mea

A lightweight async function binder, named after only the most loved virtual youtuber, Kagura Mea.

Installation

lit needs to be installed in your system, to install kagura-mea please run the following command:

lit install alphafantomu/kagura-mea

Usage

The library returns a function which will be used to wrap synchronous functions, an example using coroutines is shown below:

local async = require('kagura-mea').async;

local waitFive = async(function(n)
	local uv = require('uv');
	local t = uv.thread_self();
	uv.sleep(5000);
	return nil, n * n, n;
end);

coroutine.wrap(function()
	local thread = coroutine.running();
	waitFive(5, function(...)
		print(...);
		coroutine.resume(thread);
	end)
	print'got here';
	coroutine.yield();
	print'woohoo';
end)();

coroutine.wrap(function()
	local thread = coroutine.running();
	waitFive(5, function(...)
		print(...);
		coroutine.resume(thread);
	end)
	print'got here';
	coroutine.yield();
	print'woohoo';
end)();

Kagura Mea

You can find her socials here:

Disclaimer

There is no affiliation with Kagura Mea.

License

MIT License

Contact

  • Discord: Arivistraliavatoriar#2678