Skip to content

Commit

Permalink
How to select into bytes
Browse files Browse the repository at this point in the history
  • Loading branch information
expede committed Aug 6, 2024
1 parent 0b723ff commit 846779b
Showing 1 changed file with 31 additions and 18 deletions.
49 changes: 31 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ The Delegation payload MUST describe the authorization claims, who is involved,
# Capability
[Capability]: #capability

Capabilities are the semantically-relevant claims of a delegation. They MUST be presented as a map under the `cap` field as a map. This map is REQUIRED but MAY be empty. This MUST take the following form:
A capability is the semantically-relevant claim of a delegation. They MUST be presented as a map under the `cap` field as a map. This map is REQUIRED but MAY be empty. This MUST take the following form:

| Field | Type | Required | Description |
|--------|---------------|----------|----------------------------------------------------------------------------------------------------------|
Expand Down Expand Up @@ -291,7 +291,7 @@ Connectives add context to their enclosed statement(s).

```js
// Data
{ "name": "Katie", "age": 35, nationalities: ["Canadian", "South African"] }
{ name: "Katie", age: 35, nationalities: ["Canadian", "South African"] }

["and", []]
// ⬆️ true
Expand All @@ -317,7 +317,7 @@ Connectives add context to their enclosed statement(s).

```js
// Data
{ "name": "Katie", "age": 35, nationalities: ["Canadian", "South African"] }
{ name: "Katie", age: 35, nationalities: ["Canadian", "South African"] }

["or", []]
// ⬆️ true
Expand All @@ -336,7 +336,7 @@ Connectives add context to their enclosed statement(s).

```js
// Data
{ "name": "Katie", nationalities: ["Canadian", "South African"] }
{ name: "Katie", nationalities: ["Canadian", "South African"] }

["not",
["and", [
Expand Down Expand Up @@ -364,24 +364,21 @@ Quantifying over an array is straightforward: it MUST apply the inner statement
const args = {"a": [{"b": 1}, {"b": 2}, {"z": [7, 8, 9]}]}
const statement = ["every", ".a", [">", ".b", 0]]

// Reduction
// Outer Selector Substitution
["every", [{"b": 1}, {"b": 2}, {"z": [7, 8, 9]}], [">", ".b", 0]]

// Predicate Reduction
["and", [
[
[">", 1, 0],
[">", 2, 0],
[">", null, 0]
]
]
[">", 1, 0],
[">", 2, 0],
[">", null, 0]
]]

["and",
[
true,
true,
false // ⬅️
]
]
["and", [
true,
true,
false // ⬅️
]]

false //
```
Expand Down Expand Up @@ -542,6 +539,22 @@ null
</tbody>
</table>

### Selecting on Bytes

Bytes MAY be selected into. When doing so, they MUST be treated as a byte array (`[u8]`), and MUST NOT be treated as a Base64 string or any other representation.

``` js
// DAG-JSON
{ "/": { "bytes": "1qnBjPjE" } }

// Hexadecimal
0xd6 0xa9 0xc1 0x8c 0xf8 0xc4

// Selector
".[3]"
// ⬆️ 0x8c = 140
```

### Differences from jq
[Differences from jq]: #differences-from-jq

Expand Down

0 comments on commit 846779b

Please sign in to comment.