standard libray for Calcit in Rust runtime.
Install to ~/.config/calcit/modules/
, compile and provide dylib file:
cargo build --release
mkdir dylibs/ && cp -v target/release/libcalcit_std.dylib dylibs/ # supported macos only
Providing:
calcit.std.fs/read-file! a
calcit.std.fs/write-file! a b
calcit.std.fs/append-file! a b
calcit.std.fs/check-write-file! a b
calcit.std.fs/path-exists? a
calcit.std.fs/read-dir! a
calcit.std.fs/walk-dir! a
calcit.std.fs/glob! |src/*.rs
calcit.std.fs/create-dir! path
calcit.std.fs/create-dir-all! path
calcit.std.fs/rename! from to
calcit.std.fs/read-file-by-line! a $ fn (line) (println line)
calcit.std.process/execute! a
calcit.std.json/stringify-json data true
calcit.std.json/parse-json "|{\"a\": [1, 2], \":b\": 3}"
Date object is wrapped as (:: Date <timestamp>)
:
calcit.std.date/Date
; virtual data for Date
calcit.std.date/get-time!
; (:: Date ...)
calcit.std.date/parse-time "|2014-11-28 21:00:09 +09:00" "|%Y-%m-%d %H:%M:%S %z"
calcit.std.date/format-time (:: Date 1417176009000) "|%Y-%m-%d %H:%M:%S %z"
calcit.std.date/extract-time (get-time!)
; {} (:minute 6) (:hour 16) (:month 11) (:second 48) (:day 10)
calcit.std.date/from-ymd 2021 11 11
; (:: Date ([] :single 1636560000000))
calcit.std.date/from-ywd 2021 45 6)
; (:: Date ([] :single 1636732800000))
calcit.std.date/add-duration time 4 :days
calcit.std.rand/rand
calcit.std.rand/rand 10
calcit.std.rand/rand 10 100 (; "from 10 to 100")
calcit.std.rand/rand-int
calcit.std.rand/rand-int 10
calcit.std.rand/rand-int 10 100 (; "from 10 to 100")
calcit.std.rand/rand-nth ([] 1 2 3)
calcit.std.rand/rand-shift 10 4 (; "10+-4")
calcit.std.rand/rand-between 10 20
calcit.std.rand/nanoid!
calcit.std.rand/nanoid! 9
calcit.std.rand/nanoid! 9 |abcd (; "charset")
calcit.std.rand/rand-hex-color!
calcit.std.time/set-timeout 1000 $ fn ()
println |timeout
calcit.std.time/set-interval 1000 $ fn ()
println |repeated
calcit.std.hash/md5 |content
calcit.std.path/join-path & xs
calcit.std.path/path-dirname |a/b/c
; |a/b
calcit.std.path/path-basename |a/b/c
; |c
MIT