iyi

Playground

samples/iyi/std_text.iyi

Standard text processing library demonstration.

samples/iyi/std_text.iyi · iyi-std_text.wasm · 188 KB
# Standard text processing library demonstration.
#
#   ./bin/iyi run samples/iyi/std_text.iyi

import std/text

# 1. Whitespace stripping and line cleaning
raw_line = "  \tGET /api/v1/users HTTP/1.1\r\n"
cleaned = raw_line.strip.chomp
puts "cleaned line: '#{cleaned}'"

# 2. Splitting and partitioning
parts = cleaned.split
method = parts[0]
path = parts[1]
version = parts[2]
puts "HTTP method: #{method}, path: #{path}, version: #{version}"

key_val = "Authorization: Bearer token123".partition(": ")
header_name = key_val[0]
header_val = key_val[2]
puts "Header '#{header_name}' = '#{header_val}'"

# 3. Substitutions and transformations
slug = "Hello World! This is iyi std/text.".downcase.tr(" /.", "---").delete("!")
puts "slug: #{slug}"

# 4. UTF-8 multi-byte handling
greeting = "héllo world"
puts "greeting size: #{greeting.size} characters, #{greeting.bytesize} bytes"
puts "reversed greeting: #{greeting.reverse}"

# 5. Base conversion
hex_color = "ff"
puts "hex '#{hex_color}' to decimal: #{hex_color.to_i(16)}"
output
Press Run.

recorded with iyi 0.18.0 (built on Crystal 1.22.0-dev [2a9653052] (2026-10-18)) · Linux 7.0.0-38-generic x86_64, QEMU Virtual CPU version 2.5+ · 2026-10-19

You can type in the pane: nothing here compiles, so what you type cannot run, and the page says which bytes it is running the moment the text stops being the recorded file. There is no standard input, no filesystem and no threads on this target, and one sample fails on purpose for exactly that reason.

Run executes iyi-std_text.wasm, the module the compiler built from this file, in your browser. How this works

Try it on your machine

Copy the program into std_text.iyi, change something, and run it. Only a compiler on your own machine can run what you wrote.

sh, after installing
$ iyi run std_text.iyi