Skip to content
This repository has been archived by the owner on Jul 12, 2024. It is now read-only.

Commit

Permalink
add sleep function
Browse files Browse the repository at this point in the history
  • Loading branch information
soerenmeier committed Sep 18, 2023
1 parent 36363a8 commit 6e67153
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "riji"
description = "Scripting environment using rhai"
version = "0.1.12"
authors = ["Sören Meier <info@s-me.ch>"]
version = "0.1.13"
authors = ["Sören Meier <info@soerenmeier.ch>"]
repository = "https://github.com/fire-lib/riji"
edition = "2021"
license = "MIT OR Apache-2.0"
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ You should probably not use this crate.
- `ends_with(str, str)`
- `sort_strs(array)`
- `env_os()` returns windows | linux | unknown
- `sleep(ms)`

### Command api
- `cmd(str|array)`
Expand Down
7 changes: 6 additions & 1 deletion src/api/other.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ fn sort_strs(a: Array) -> RhaiResult<Array> {
Ok(ar)
}

fn sleep(ms: i64) {
std::thread::sleep(std::time::Duration::from_millis(ms as u64));
}

pub fn add(engine: &mut Engine) {
engine
.register_fn("uuid_v4", uuid_v4)
Expand All @@ -70,5 +74,6 @@ pub fn add(engine: &mut Engine) {
.register_fn("starts_with", starts_with)
.register_fn("ends_with", ends_with)
.register_fn("sort_strs", sort_strs)
.register_fn("env_os", env_os);
.register_fn("env_os", env_os)
.register_fn("sleep", sleep);
}

0 comments on commit 6e67153

Please sign in to comment.