Skip to content

Commit 1a00968

Browse files
committed
docs: add shorn to the ecosystem page
1 parent 03b1f01 commit 1a00968

2 files changed

Lines changed: 26 additions & 1 deletion

File tree

ark/docs/content/docs/ecosystem/index.mdx

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,28 @@ export default defineConfig({
6969
```
7070

7171
> For more details, see the [Getting Started guide](https://use-drzl.github.io/drzl/guide/getting-started.html).
72+
73+
### shorn
74+
75+
[shorn](https://shorn.dev) turns an ArkType type into compact binary serialization. Field names and type tags stay out of the payload because the type already provides them, so there is no schema language to learn and nothing to generate.
76+
77+
ArkType 2.1.28 and newer implements both [Standard Schema](https://standardschema.dev/schema) and [Standard JSON Schema](https://standardschema.dev/json-schema), so a type can be passed straight to `encode`. Validation runs on encode and again on decode.
78+
79+
```ts
80+
// @noErrors
81+
import { type } from "arktype"
82+
import { decode, encode } from "@chichurita/shorn"
83+
84+
const Person = type({
85+
name: "string",
86+
age: "number.integer >= 0",
87+
sex: "'M' | 'F' | 'X'"
88+
})
89+
90+
const bytes = encode(Person, { name: "Grace", age: 45, sex: "F" })
91+
bytes.length // 8, where the same record is 35 bytes of minified JSON
92+
93+
decode(Person, bytes) // typed and validated
94+
```
95+
96+
> ArkType objects are open by default, so shorn rejects undeclared properties during encoding rather than dropping data. Use `"+": "delete"` to strip expected extras. See the [ArkType guide](https://shorn.dev/validators/arktype/) for the details.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
22
"title": "Ecosystem",
33
"icon": "New",
4-
"pages": ["[ArkEnv](/docs/ecosystem#arkenv)", "[DRZL](/docs/ecosystem#drzl)"]
4+
"pages": ["[ArkEnv](/docs/ecosystem#arkenv)", "[DRZL](/docs/ecosystem#drzl)", "[shorn](/docs/ecosystem#shorn)"]
55
}

0 commit comments

Comments
 (0)