From 86690e35df6020c6b2eaaa5adf1194a075e07160 Mon Sep 17 00:00:00 2001 From: Aura <kyradiscord@gmail.com> Date: Wed, 18 Dec 2024 20:36:58 +0100 Subject: [PATCH] docs: add `nullable` to the README (#847) --- packages/string-store/README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/packages/string-store/README.md b/packages/string-store/README.md index 527a4c926c..25d9503ee4 100644 --- a/packages/string-store/README.md +++ b/packages/string-store/README.md @@ -111,6 +111,20 @@ const schema = new Schema(Id.Planets).fixedLengthArray('names', t.string, 3); // → Schema<Id.Planets, { names: [string, string, string] }> ``` +### `nullable` + +Adds a nullable property of the specified type to the schema. + +```ts +// A schema with a single field `capitalId` that is a nullable string: + +const schema = new Schema(Id.Planets).nullable('capitalId', t.uint32); +// → Schema<Id.Planets, { capitalId: number | null }> +``` + +To track whether or not a property is optional, it will serialize a [bit](#bit), which signals whether or not the value +is defined, due to this, its bit size is `null`. + ### `string` Adds a string to the schema.