Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@effect/schema

Package Overview
Dependencies
Maintainers
3
Versions
335
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@effect/schema - npm Package Compare versions

Comparing version 0.30.1 to 0.30.2

6

package.json
{
"name": "@effect/schema",
"version": "0.30.1",
"version": "0.30.2",
"license": "MIT",

@@ -10,4 +10,4 @@ "repository": {

"dependencies": {
"@effect/data": "^0.16.0",
"@effect/io": "^0.35.0",
"@effect/data": "^0.16.1",
"@effect/io": "^0.35.2",
"fast-check": "^3.11.0"

@@ -14,0 +14,0 @@ },

@@ -913,21 +913,2 @@ <h3 align="center">

### Access the schema for a particular key
The `getPropertySignatures` function takes a `Schema<A>` and returns a new object of type `{ [K in keyof A]: Schema<A[K]> }`. The new object has properties that are the same keys as those in the original object, and each of these properties is a schema for the corresponding property in the original object.
```ts
import * as S from "@effect/schema/Schema";
const Person = S.struct({
name: S.string,
age: S.number
});
// get the schema for each property of `Person`
const shape = S.getPropertySignatures(Person);
shape.name; // S.string
shape.age; // S.number
```
## Pick

@@ -1301,2 +1282,43 @@

## Interop with `@effect/data/Data`
The `@effect/data/Data` module in the Effect ecosystem serves as a utility module that simplifies the process of comparing values for equality without the need for explicit implementations of the `Equal` and `Hash` interfaces. It provides convenient APIs that automatically generate default implementations for equality checks, making it easier for developers to perform equality comparisons in their applications.
```ts
import * as Data from "@effect/data/Data";
import * as Equal from "@effect/data/Equal";
const person1 = Data.struct({ name: "Alice", age: 30 });
const person2 = Data.struct({ name: "Alice", age: 30 });
console.log(Equal.equals(person1, person2)); // true
```
You can use the `Schema.data(schema)` combinator to build a schema from an existing schema that can decode a value `A` to a value `Data<A>`:
```ts
/*
S.Schema<{
readonly name: string;
readonly age: number;
}, Data.Data<{
readonly name: string;
readonly age: number;
}>>
*/
const schema = S.data(
S.struct({
name: S.string,
age: S.number
})
);
const decode = S.decode(schema);
const person1 = decode({ name: "Alice", age: 30 });
const person2 = decode({ name: "Alice", age: 30 });
console.log(Equal.equals(person1, person2)); // true
```
## Option

@@ -1303,0 +1325,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc