feat: add example scripts for argparse, bytes, dataset, html, markdown, uuid, wdantic, and web chat modules
Add comprehensive demo scripts showcasing the usage of multiple Wren modules including argument parsing, byte manipulation, in-memory dataset operations, HTML encoding/slugification, markdown-to-HTML conversion, UUID generation/validation, schema validation with wdantic, and a full web chat application with REST endpoints.
This commit is contained in:
Vendored
+39
@@ -0,0 +1,39 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "bytes" for Bytes
|
||||
|
||||
System.print("=== Bytes Module Demo ===\n")
|
||||
|
||||
System.print("--- fromList / toList ---")
|
||||
var list = [72, 101, 108, 108, 111]
|
||||
var str = Bytes.fromList(list)
|
||||
System.print("fromList([72, 101, 108, 108, 111]) = %(str)")
|
||||
System.print("toList(%(str)) = %(Bytes.toList(str))")
|
||||
|
||||
System.print("\n--- length ---")
|
||||
System.print("length('Hello World') = %(Bytes.length("Hello World"))")
|
||||
|
||||
System.print("\n--- concat ---")
|
||||
var a = "Hello"
|
||||
var b = " World"
|
||||
System.print("concat('%(a)', '%(b)') = %(Bytes.concat(a, b))")
|
||||
|
||||
System.print("\n--- slice ---")
|
||||
var data = "Hello World"
|
||||
System.print("slice('%(data)', 0, 5) = %(Bytes.slice(data, 0, 5))")
|
||||
System.print("slice('%(data)', 6, 11) = %(Bytes.slice(data, 6, 11))")
|
||||
|
||||
System.print("\n--- xorMask ---")
|
||||
var payload = Bytes.fromList([1, 2, 3, 4, 5, 6, 7, 8])
|
||||
var mask = Bytes.fromList([0x12, 0x34, 0x56, 0x78])
|
||||
var masked = Bytes.xorMask(payload, mask)
|
||||
System.print("Original: %(Bytes.toList(payload))")
|
||||
System.print("Mask: %(Bytes.toList(mask))")
|
||||
System.print("XOR'd: %(Bytes.toList(masked))")
|
||||
var unmasked = Bytes.xorMask(masked, mask)
|
||||
System.print("Unmasked: %(Bytes.toList(unmasked))")
|
||||
|
||||
System.print("\n--- Binary data handling ---")
|
||||
var binary = Bytes.fromList([0, 127, 128, 255])
|
||||
System.print("Binary data length: %(Bytes.length(binary))")
|
||||
System.print("Binary data bytes: %(Bytes.toList(binary))")
|
||||
Reference in New Issue
Block a user