mirror of
https://github.com/azur1s/bobbylisp.git
synced 2024-10-16 02:37:40 -05:00
io function
This commit is contained in:
parent
71f313dbe1
commit
dff9e03ea9
|
@ -3,7 +3,7 @@ Programming language that compiles to Typescript!
|
||||||
|
|
||||||
```sml
|
```sml
|
||||||
fun main: void = do
|
fun main: void = do
|
||||||
@write("Hello, World!\n");
|
@write("Hello, World!");
|
||||||
end;
|
end;
|
||||||
```
|
```
|
||||||
or with the pipe operator:
|
or with the pipe operator:
|
||||||
|
|
20
std/io.ts
Normal file
20
std/io.ts
Normal file
|
@ -0,0 +1,20 @@
|
||||||
|
import { writeAllSync } from "https://deno.land/std@0.129.0/streams/conversion.ts";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes text to the stdout stream.
|
||||||
|
* @param text The text to write. Can be any type.
|
||||||
|
*/
|
||||||
|
export function write(text: any): void {
|
||||||
|
const bytes: Uint8Array = new TextEncoder().encode(text);
|
||||||
|
writeAllSync(Deno.stdout, bytes);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes text to the file.
|
||||||
|
* @param text The text to write. Can be any type.
|
||||||
|
* @param path The path to the file.
|
||||||
|
*/
|
||||||
|
export function write_file(text: any, path: string): void {
|
||||||
|
const bytes: Uint8Array = new TextEncoder().encode(text);
|
||||||
|
Deno.writeFileSync(path, bytes);
|
||||||
|
}
|
Loading…
Reference in a new issue