npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

react-native-lua

v0.1.4

Published

Native Lua in React Native

Downloads

5

Readme

react-native-lua

Native Lua in React Native Heavily based on React Native JSI 😅. Working in both iOS and Android.

Lots of inspiration from ObjC-Lua and ilua.

The Lua source version (as of February 2022) is 5.4.4.

  • Minimally modified, simply prevented MakeFile from being detected and commented out os_execute from loslib.c to prevent calls to system(cmd) from occuring (unavailable on iOS).

Installation

npm install react-native-lua

iOS

cd ios && pod install

Android

You need NDK installed. That's it.

Usage

Methods can be seen in the types.

Almost all methods are simply the same as known C api methods of the pattern lua_${methodName}, sans the lua_ prefix.

import { luaInterpreter } from "react-native-lua";
// Create a new interpreter
const interp = luaInterpreter();
// this is equivalent to lua_dostring
interp.dostring(`a = 2
b = a ^ 2
a = b * 20
    `);
// Or asynchronously! Each Lua Interpreter spawns its own thread when executing async code, so this doesn't block any other processes.
interp.dostringasync(`i = 0
while(i < 8)
do
  print(i)
  sleep(100)
  i = i + 1
end`)

// The rest is up to you!

The interpreter in action

the-interpreter-in-action

Execution limits

Since Lua is a scripting language, it wouldn't be nice if our code suddenly got stuck in a forever loop and blocks the whole program.

This library handles this condition by leveraging Lua runtime's lua_sethook function (which allows us to monitor the code execution every N commands).

The property executionLimit defines the number of milliseconds the script should run until it is terminated. Default value is 10000 (10 seconds). You can set this value by calling setExecutionLimit(ms)

Future plans

  • Make async dostringasync and dofileasync work on Android
    • iOS dostringasync is working perfectly well, however, in Android it is only possible to use dostring since CallInvoker crashes immediately when InvokeAsync() is called. Any help in getting this working would be very much appreciated.

Contributing

See the contributing guide to learn how to contribute to the repository and the development workflow.

License

MIT


Tip Jar

If you appreciate my work, help buy me some soda 🥤 via the following routes.

Stellar Lumens (XLM) : 
GCVKPZQUDXWVNPIIMF3FXR6KWAOHTEWPZZM2AQE4J3TXR6ZDHXQHP5BQ
Cardano (ADA) : 
addr1q9datt8urnyuc2059tquh59sva0pja7jqg4nfhnje7xcy6zpndeesglqkxhjvcgdu820flcecjzunwp6qen4yr92gm6smssug8