Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add copper tier #3460

Merged
merged 2 commits into from
May 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
52 changes: 25 additions & 27 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@ Sponsorship at any level is appreciated and encouraged. For individual developer

#### Bronze

<!--
two column table layout
each td should contain a ul
-->

<table>
<tr>
<td><a href="https://www.numeric.io">Numeric</a></td>
Expand All @@ -298,34 +293,37 @@ each td should contain a ul
</tr>
<tr>
<td><a href="https://www.bamboocreative.nz/">Bamboo Creative</a></td>
<td><a href="https://twitter.com/flybayer">Brandon Bayer</a></td>
<td><a href="https://github.com/brabeji">Jiří Brabec</a></td>
<td><a href="https://twitter.com/alexdotjs">Alex Johansson</a></td>
</tr>
</table>

#### Copper

<table>
<tr>
<td>Brandon Bayer</td>
<td>Jiří Brabec</td>
<td>Alex Johansson</td>
<td>Fungible Systems</td>
</tr>
<tr>
<td>Adaptable</td>
<td>Avana Wallet</td>
<td>Jason Lengstorf</td>
<td>Global Illumination, Inc.</td>
</tr>
<tr>
<td><a href="https://learnwithjason.dev">Learn with Jason</a></td>
<td><a href="https://github.com/kronodeus">Ryan Palmer</a></td>
<td><a href="https://github.com/overthemike">Michael Sweeney</a></td>
<td><a href="https://github.com/ConnorSinnott">Connor Sinnott</a></td>
<td>MasterBorn</td>
<td>Ryan Palmer</td>
<td>Michael Sweeney</td>
<td>Nextbase</td>
</tr>
<tr>
<td><a href="https://aerabi.com/">Mohammad-Ali A'râbi</a></td>
<td>Remotion</td>
<td>Connor Sinnott</td>
<td>Mohammad-Ali A'râbi</td>
<td>Supatool</td>
</tr>
</table>
<!--
- [Numeric](https://www.numeric.io)
- [Marcato Partners](https://marcatopartners.com/)
- [Interval](https://interval.com)
- [Seasoned Software](https://seasoned.cc)
- [Bamboo Creative](https://www.bamboocreative.nz/)
- [Brandon Bayer](https://twitter.com/flybayer)
- [Jiří Brabec](https://github.com/brabeji)
- [Alex Johansson](https://twitter.com/alexdotjs)
- [Learn with Jason](https://learnwithjason.dev)
- [Ryan Palmer](https://github.com/kronodeus)
- [Michael Sweeney](https://github.com/overthemike)
- [Connor Sinnott](https://github.com/ConnorSinnott)
- [Mohammad-Ali A'râbi](https://aerabi.com/) -->

### Ecosystem

Expand Down
55 changes: 27 additions & 28 deletions deno/lib/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,11 +284,6 @@ Sponsorship at any level is appreciated and encouraged. For individual developer

#### Bronze

<!--
two column table layout
each td should contain a ul
-->

<table>
<tr>
<td><a href="https://www.numeric.io">Numeric</a></td>
Expand All @@ -298,34 +293,37 @@ each td should contain a ul
</tr>
<tr>
<td><a href="https://www.bamboocreative.nz/">Bamboo Creative</a></td>
<td><a href="https://twitter.com/flybayer">Brandon Bayer</a></td>
<td><a href="https://github.com/brabeji">Jiří Brabec</a></td>
<td><a href="https://twitter.com/alexdotjs">Alex Johansson</a></td>
</tr>
</table>

#### Copper

<table>
<tr>
<td>Brandon Bayer</td>
<td>Jiří Brabec</td>
<td>Alex Johansson</td>
<td>Fungible Systems</td>
</tr>
<tr>
<td>Adaptable</td>
<td>Avana Wallet</td>
<td>Jason Lengstorf</td>
<td>Global Illumination, Inc.</td>
</tr>
<tr>
<td><a href="https://learnwithjason.dev">Learn with Jason</a></td>
<td><a href="https://github.com/kronodeus">Ryan Palmer</a></td>
<td><a href="https://github.com/overthemike">Michael Sweeney</a></td>
<td><a href="https://github.com/ConnorSinnott">Connor Sinnott</a></td>
<td>MasterBorn</td>
<td>Ryan Palmer</td>
<td>Michael Sweeney</td>
<td>Nextbase</td>
</tr>
<tr>
<td><a href="https://aerabi.com/">Mohammad-Ali A'râbi</a></td>
<td>Remotion</td>
<td>Connor Sinnott</td>
<td>Mohammad-Ali A'râbi</td>
<td>Supatool</td>
</tr>
</table>
<!--
- [Numeric](https://www.numeric.io)
- [Marcato Partners](https://marcatopartners.com/)
- [Interval](https://interval.com)
- [Seasoned Software](https://seasoned.cc)
- [Bamboo Creative](https://www.bamboocreative.nz/)
- [Brandon Bayer](https://twitter.com/flybayer)
- [Jiří Brabec](https://github.com/brabeji)
- [Alex Johansson](https://twitter.com/alexdotjs)
- [Learn with Jason](https://learnwithjason.dev)
- [Ryan Palmer](https://github.com/kronodeus)
- [Michael Sweeney](https://github.com/overthemike)
- [Connor Sinnott](https://github.com/ConnorSinnott)
- [Mohammad-Ali A'râbi](https://aerabi.com/) -->

### Ecosystem

Expand Down Expand Up @@ -417,6 +415,7 @@ There are a growing number of tools that are built atop or support Zod natively!
#### Utilities for Zod

- [`zod_utilz`](https://github.com/JacobWeisenburger/zod_utilz): Framework agnostic utilities for Zod.
- [`zod-playground`](https://github.com/marilari88/zod-playground): A tool for learning and testing Zod schema validation functionalities. [Link](https://zod-playground.vercel.app/).
- [`zod-sandbox`](https://github.com/nereumelo/zod-sandbox): Controlled environment for testing zod schemas. [Live demo](https://zod-sandbox.vercel.app/).
- [`zod-dev`](https://github.com/schalkventer/zod-dev): Conditionally disables Zod runtime parsing in production.
- [`zod-accelerator`](https://github.com/duplojs/duplojs-zod-accelerator): Accelerates Zod's throughput up to ~100x.
Expand Down Expand Up @@ -2445,7 +2444,7 @@ Note that branded types do not affect the runtime result of `.parse`. It is a st
This method returns a `ZodReadonly` schema instance that parses the input using the base schema, then calls `Object.freeze()` on the result. The inferred type is also marked as `readonly`.

```ts
const schema = z.object({ name: string }).readonly();
const schema = z.object({ name: z.string() }).readonly();
type schema = z.infer<typeof schema>;
// Readonly<{name: string}>

Expand Down
50 changes: 50 additions & 0 deletions deno/lib/__tests__/readonly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,53 @@ test("object freezing", () => {
)
).toBe(true);
});

test("async object freezing", async () => {
expect(
Object.isFrozen(await z.array(z.string()).readonly().parseAsync(["a"]))
).toBe(true);
expect(
Object.isFrozen(
await z.tuple([z.string(), z.number()]).readonly().parseAsync(["a", 1])
)
).toBe(true);
expect(
Object.isFrozen(
await z
.map(z.string(), z.date())
.readonly()
.parseAsync(new Map([["a", new Date()]]))
)
).toBe(true);
expect(
Object.isFrozen(
await z
.set(z.promise(z.string()))
.readonly()
.parseAsync(new Set([Promise.resolve("a")]))
)
).toBe(true);
expect(
Object.isFrozen(
await z.record(z.string()).readonly().parseAsync({ a: "b" })
)
).toBe(true);
expect(
Object.isFrozen(
await z.record(z.string(), z.number()).readonly().parseAsync({ a: 1 })
)
).toBe(true);
expect(
Object.isFrozen(
await z
.object({ a: z.string(), 1: z.number() })
.readonly()
.parseAsync({ a: "b", 1: 2 })
)
).toBe(true);
expect(
Object.isFrozen(
await z.promise(z.string()).readonly().parseAsync(Promise.resolve("a"))
)
).toBe(true);
});
13 changes: 9 additions & 4 deletions deno/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5041,10 +5041,15 @@ export class ZodReadonly<T extends ZodTypeAny> extends ZodType<
> {
_parse(input: ParseInput): ParseReturnType<this["_output"]> {
const result = this._def.innerType._parse(input);
if (isValid(result)) {
result.value = Object.freeze(result.value);
}
return result;
const freeze = (data: ParseReturnType<this["_output"]>) => {
if (isValid(data)) {
data.value = Object.freeze(data.value);
}
return data;
};
return isAsync(result)
? result.then((data) => freeze(data))
: freeze(result);
}

static create = <T extends ZodTypeAny>(
Expand Down