标准库

515 个函数 · 115 个常量 · 默认注入环境,无需 import

math

数学常量与函数
pi (常量)
tau (常量)
e (常量)
nan (常量)
inf (常量)
abs
acos
asin
atan
atan2
cbrt
ceil
clamp
cos
deg
exp
exp2
expm1
floor
fract
hypot
isFinite
isInf
isNaN
log
log10
log1p
log2
max
min
mod
pow
rad
round
sign
sin
sqrt
tan
trunc

string

UTF-8 字符串操作(44 函数)
approx
byteAt
byteLen
charAt
chars
compare
contains
count
endsWith
equals
filter
formatFloat
formatInt
hasAny
indexOf
insert
isBlank
isEmpty
isUtf8
join
lastIndexOf
left
len
like
lower
ltrim
mid
padCenter
padLeft
padRight
remove
removeAt
repeat
replace
reverse
right
rtrim
sim
slice
split
splitLines
startsWith
trim
upper
bytes

time

日期时间处理(67 函数)
addDays
addHours
addMinutes
addMonths
addQuarters
addSeconds
addWeeks
addYears
approx
clock
datePart
dateString
day
dayOfYear
daysInMonth
daysInYear
diffDays
diffHours
diffMinutes
diffMonths
diffQuarters
diffSeconds
diffWeeks
diffYears
firstDayOfMonth
firstDayOfWeek
firstDayOfYear
format
formatPattern
fromDate
fromDateTime
fromTime
fromUnix
hour
inRange
isLeapYear
isSameDay
isSameMonth
isSameYear
lastDayOfMonth
lastDayOfWeek
lastDayOfYear
localToUTC
minute
month
now
nowUTC
parse
parsePattern
quarter
rangeOverlap
relative
second
sleep
timePart
timer
timeString
timezoneOffset
today
toUnix
tryParse
tryParsePattern
utcToLocal
weekday
weekOfMonth
weekOfYear
year

file

文件操作,UTF-8 路径(31 函数)
accessTime
appendText
appendTextAsync
attr
changeTime
copy
copyAsync
delete
deleteAsync
exists
info
move
moveAsync
readText
readTextAsync
rename
replace
setAttr
setSize
size
touch
writeText
writeTextAsync
writeTextAtomic

dir

目录操作(23 函数)
copy
create
createAll
delete
dirs
exists
files
list
move

path

路径处理(19 函数)
abs
appDir
cwd
dir
exists
ext
home
isAbs
join
name
nameExt
normalize
random
rel
sep
setCwd
temp
withExt
withName

json

JSON 序列化/反序列化
parse
valid
read
stringify
write

xson

XSON 序列化(扩展 JSON)
parse
valid
read
stringify
write

crypto

加密套件:SHA/HMAC/HKDF/AES-GCM/ChaCha20/Ed25519/X25519/RSA(54 函数)
sha1
sha256
sha384
sha512
sha256Stream
sha384Stream
sha512Stream
hmacSha256
hmacSha384
hmacSha512
hkdfSha256
hkdfSha384
randomHex
chacha20Encrypt
chacha20Decrypt
chacha20Poly1305Encrypt
chacha20Poly1305Decrypt
aes128GcmEncrypt
aes128GcmDecrypt
aes256GcmEncrypt
aes256GcmDecrypt
ed25519Keypair
ed25519PublicKey
ed25519Sign
ed25519Verify
x25519Keypair
x25519SharedSecret
rsaPssVerify
rsaPkcs1Verify

http

HTTP 客户端 + 完整服务器(TLS/SNI/路由/静态/流式)
get
post
request
server.create
server.createTls
server.get
server.post
server.any
server.route
server.static
server.staticEx
server.start
server.drain
server.stop
server.tlsHost
server.mimeByPath

net / tcp / udp

网络编程
net.localIP
net.localMAC
net.localName
tcp.connect
tcp.connectAsync
tcp.listen
udp.bind

codec / encoding

编解码与字符集
codec.base64Encode
codec.base64Decode
codec.hexEncode
codec.hexDecode
codec.percentEncode
codec.percentDecode
codec.formUrlEncode
codec.formUrlDecode
encoding.detect
encoding.toBytes
encoding.fromBytes
encoding.convertBytes
encoding.isUtf8

hash

哈希算法
u32
u32WithSeed
u64
u64WithSeed
u64Micro
u64Nano

random

随机数
range
seed
string
u32
u64

regex

正则表达式
find
isMatch

log

日志系统(16 函数 + 8 常量)
create
default
setLevel
getLevel
levelName
addConsole
addFile
addRollingFile
write
trace
debug
info
warn
error
fatal
flush

template

模板引擎
compile
render
renderFile

process

进程管理
exec
exitCode
success
run
runFile
cmd
shell
pipeline
start
startFile

url / query

URL 解析与查询字符串
url.authority
url.fragment
url.host
url.isAbsolute
url.isSecure
url.path
url.port
url.query
url.resolve
url.scheme
url.valid
query.append
query.decode
query.encode
query.pair
query.valid

id

唯一标识生成
xid

全局

默认可用
print
println
write
writeln
range