Skip to content

Commit

Permalink
docs: add example to README
Browse files Browse the repository at this point in the history
  • Loading branch information
R-unic committed Sep 10, 2023
1 parent b6e035e commit 09a6da8
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 2 deletions.
39 changes: 38 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,40 @@
![build](https://github.com/R-unic/crystallizer/actions/workflows/test.yml/badge.svg)
# Crystallizer
A TypeScript to Crystal compiler. All the beauty and power of TypeScript, with all the speed and compatibility of Crystal.
A TypeScript to Crystal compiler. All the beauty and power of TypeScript, with the speed and portability of Crystal.

# Example
```ts
// examples/async-await/src/test.ts

async function myAsyncFunction(): Promise<string> {
return "Hello!";
}

async function main(): Promise<void> {
myAsyncFunction() // you can also use await here of course
.then(res => console.log(res));
}

main();
```
```cr
# examples/async-await/dist/test.cr
private def myAsyncFunction : MiniFuture(String)
async! do
return "Hello!"
end
end
private def main : MiniFuture(Nil)
async! do
myAsyncFunction.then do |res|
puts(res)
end
return
end
end
await main
```

# Usage
* All of the below instructions are temporary.
Expand All @@ -19,6 +53,9 @@ A TypeScript to Crystal compiler. All the beauty and power of TypeScript, with a
- destructuring (this is so much harder than it needs to be)
- for..in
- macro the rest of the `console` library
- macro the `??` operator
- tab size option
- emit comments
- disallow:
- call expressions on arrow functions directly
- type parameters in function types
Expand Down
2 changes: 1 addition & 1 deletion examples/async-await/src/test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ async function myAsyncFunction(): Promise<string> {
}

async function main(): Promise<void> {
myAsyncFunction()
myAsyncFunction() // you can also use await here of course
.then(res => console.log(res));
}

Expand Down

0 comments on commit 09a6da8

Please sign in to comment.