Skip to content

Commit

Permalink
fixing merge conflight
Browse files Browse the repository at this point in the history
  • Loading branch information
boyney123 committed Sep 30, 2024
2 parents da5bda7 + 6de886c commit 4e03314
Show file tree
Hide file tree
Showing 70 changed files with 6,024 additions and 384 deletions.
1 change: 1 addition & 0 deletions api_versioned_docs/version-latest/05-language-reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,6 +593,7 @@ the following properties (given an example intrinsic `@x`):
| `@assert()` | checks a condition and _throws_ if evaluated to false |
| `@filename` | absolute path of the source file |
| `@dirname` | absolute path of the source file's directory |
| `@target` | a string identifying the current target platform |
| `@app` | the root of the construct tree |
| `@unsafeCast()` | cast a value into a different type |
| `@nodeof()` | obtain the [tree node](/docs/concepts/application-tree) of a preflight object |
Expand Down
305 changes: 305 additions & 0 deletions blog/2024-09-24-magazine-011.md

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ new cloud.Function(inflight ()=> {
// push a message to queue
queue.push("m");
// sleep according to target
if util.env("WING_TARGET") == "sim" {
if @target == "sim" {
log("Running on Simulator, sleeping for 1s");
util.sleep(1s);
} else {
Expand All @@ -85,7 +85,7 @@ new cloud.Function(inflight ()=> {
});
```

In this example, we want to sleep briefly for the Simulator target and for 30 seconds for cloud targets, this is achieved using the `WING_TARGET` environment variable.
In this example, we want to sleep briefly for the simulator target and for 30 seconds for cloud targets, this is achieved using the `@target` intrinsic function.

## Compiler plugins

Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/02-hello-world.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Wing by example
id: hello-world
slug: /hello-world
sidebar_label: 1. Hello world
sidebar_label: Hello world
description: Hello world wing example
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/03-values.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Primitive values
id: primitives
slug: /primitive-values
sidebar_label: 2. Primitive values
sidebar_label: Primitive values
description: Hello world wing example
keywords: [Wing language, example, primitives, values]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/04-variables.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Variables
id: Variables
slug: /Variables
sidebar_label: 4. Variables
sidebar_label: Variables
description: Using variables with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/05-for.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: For
id: for
slug: /for
sidebar_label: 5. For
sidebar_label: For
description: Using for loops with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/06-ifelse.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: If/Else
id: if-else
slug: /if-else
sidebar_label: 6. If/Else
sidebar_label: If/Else
description: Using if else with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/07-while.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: While
id: while
slug: /while
sidebar_label: 7. While
sidebar_label: While
description: Using while statements with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/08-optionality.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Optionality
id: optionality
slug: /optionality
sidebar_label: 8. Optionality
sidebar_label: Optionality
description: Using while statements with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/09-arrays.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Arrays
id: arrays
slug: /arrays
sidebar_label: 9. Arrays
sidebar_label: Arrays
description: Using arrays with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/10-maps.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Maps
id: maps
slug: /maps
sidebar_label: 10. Maps
sidebar_label: Maps
description: Using maps with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/11-sets.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Sets
id: sets
slug: /sets
sidebar_label: 11. Sets
sidebar_label: Sets
description: Using sets with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/12-structs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Structs
id: structs
slug: /structs
sidebar_label: 12. Structs
sidebar_label: Structs
description: Using arrays with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
29 changes: 29 additions & 0 deletions example_versioned_docs/version-latest/13-bytes.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
---
title: Bytes
id: bytes
slug: /bytes
sidebar_label: Bytes
description: Hash values in Wing with SHA256
keywords: [Wing language, Hash, SHA256]
image: /img/wing-by-example.png
---

When working with binary files like images, audio, or other binary formats, you often need to manipulate data at the byte level.

```js playground example title="main.w"
// get bytes from raw value
let rawData: bytes = bytes.fromRaw([104, 101, 108, 108, 111]);

// get the bytes from a string
let rawString: bytes = bytes.fromString("hello");

// get bytes from base64 encoded value
let base64: bytes = bytes.fromBase64("aGVsbG8=");

// get bytes from hex value
let hex: bytes = bytes.fromHex("68656c6c6f");
```




Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Trailing struct parameters
id: trailing-structs-parameters
slug: /trailing-structs-parameters
sidebar_label: 13. Trailing struct parameters
sidebar_label: Trailing struct parameters
description: Passing fields directly to a function
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Inflight functions
id: inflight-functions
slug: /inflight-functions
sidebar_label: 14. Async inflight functions
sidebar_label: Async inflight functions
description: Using functions with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/14-functions.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Functions
id: functions
slug: /functions
sidebar_label: 14. Functions
sidebar_label: Functions
description: Using functions with Wing
keywords: [Wing language, example]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Variadic Functions
id: variadic-functions
slug: /variadic-functions
sidebar_label: 15. Variadic Functions
sidebar_label: Variadic Functions
description: Using variadic functions with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/16-closures.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Closures
id: closures
slug: /closures
sidebar_label: 16. Closures
sidebar_label: Closures
description: Closures with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/17-recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Recursion
id: recursion
slug: /recursion
sidebar_label: 17. Recursion
sidebar_label: Recursion
description: Recursion with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/18-methods.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Methods
id: methods
slug: /methods
sidebar_label: 18. Methods
sidebar_label: Methods
description: Methods with Wing
keywords: [Wing language, variadic]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/19-interfaces.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Interfaces
id: interfaces
slug: /interfaces
sidebar_label: 19. Interfaces
sidebar_label: Interfaces
description: Interfaces with Wing
keywords: [Wing language, interfaces]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/20-sleep.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Sleep
id: sleep
slug: /sleep
sidebar_label: 20. Sleep
sidebar_label: Sleep
description: Suspends execution for a given duration.
keywords: [Wing language, sleep]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: String functions
id: string-functions
slug: /string-functions
sidebar_label: 21. String functions
sidebar_label: String functions
description: Functions for string values in Wing
keywords: [Wing language, string, functions]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/22-regex.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Regular expressions
id: regex
slug: /regex
sidebar_label: 22. Regular expressions
sidebar_label: Regular expressions
description: Functions for string values in Wing
keywords: [Wing language, string, functions]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/23-Json.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Json
id: json
slug: /json
sidebar_label: 23. Json
sidebar_label: Json
description: Create Json values in Wing
keywords: [Wing language, json]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/24-time.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Time
id: time
slug: /time
sidebar_label: 24. Time
sidebar_label: Time
description: Create time/date values in Wing
keywords: [Wing language, time, date]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/25-random.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Random
id: random
slug: /random
sidebar_label: 25. Random
sidebar_label: Random
description: Create random values in Wing
keywords: [Wing language, random]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/26-number-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Number parsing
id: number-parsing
slug: /number-parsing
sidebar_label: 26. Number Parsing
sidebar_label: Number Parsing
description: Parse values into numbers
keywords: [Wing language, random]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/27-url-parsing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: URL parsing
id: url-parsing
slug: /url-parsing
sidebar_label: 27. URL parsing
sidebar_label: URL parsing
description: Parse urls in Wing
keywords: [Wing language, URL]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/28-sha256.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: SHA256 Hashes
id: sha256
slug: /sha256
sidebar_label: 28. SHA256 Hashes
sidebar_label: SHA256 Hashes
description: Hash values in Wing with SHA256
keywords: [Wing language, Hash, SHA256]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Base64 Encoding
id: base64-encoding
slug: /base64-encoding
sidebar_label: 29. Base64 Encoding
sidebar_label: Base64 Encoding
description: Encode and decode Base64 values
keywords: [Wing language, Base64]
image: /img/wing-by-example.png
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Reading and writing files
id: reading-and-writing-files
slug: /reading-and-writing-files
sidebar_label: 30. Reading and writing files
sidebar_label: Reading and writing files
description: Reading and writing files with Wing
keywords: [Wing language, Reading files, Writing files]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/31-directories.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Directories
id: directories
slug: /directories
sidebar_label: 31. Directories
sidebar_label: Directories
description: Directories
keywords: [Wing language, Directories]
image: /img/wing-by-example.png
Expand Down
2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/32-testing.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: Testing
id: testing
slug: /testing
sidebar_label: 32. Testing
sidebar_label: Testing
description: Directories
keywords: [Wing language, Directories]
image: /img/wing-by-example.png
Expand Down
19 changes: 9 additions & 10 deletions example_versioned_docs/version-latest/33-http-client.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: HTTP Client
id: http-client
slug: /http-client
sidebar_label: 33. HTTP Client
sidebar_label: HTTP Client
description: Directories
keywords: [Wing language, HTTP]
image: /img/wing-by-example.png
Expand All @@ -17,7 +17,7 @@ bring http;
bring cloud;

struct Pokemon {
id: str;
id: num;
name: str;
order: num;
weight: num;
Expand All @@ -29,18 +29,17 @@ new cloud.Function(inflight () => {
// response status
log(x.status);

// Cast response back into struct
let ditto = Pokemon.fromJson(x.body);
log(ditto.name);
// parse string response as a JSON object
let data = Json.parse(x.body);

// cast JSON response into struct
let ditto = Pokemon.fromJson(data);
log(ditto.name);
});
```

```bash title="Wing console output"
# Run locally with wing console
No directory found
200
ditto
```




2 changes: 1 addition & 1 deletion example_versioned_docs/version-latest/34-http-server.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
title: HTTP Server
id: http-server
slug: /http-server
sidebar_label: 33. HTTP Server
sidebar_label: HTTP Server
description: Directories
keywords: [Wing language, HTTP]
image: /img/wing-by-example.png
Expand Down
Loading

0 comments on commit 4e03314

Please sign in to comment.