New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.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.45.0 to 0.45.1

27

Arbitrary/dist/effect-schema-Arbitrary.cjs.dev.js

@@ -156,3 +156,10 @@ 'use strict';

{
const elements = ast.elements.map(e => go(e.type));
const elements = [];
let hasOptionals = false;
for (const element of ast.elements) {
elements.push(go(element.type));
if (element.isOptional) {
hasOptionals = true;
}
}
const rest = Function.pipe(ast.rest, Option__namespace.map(ReadonlyArray__namespace.mapNonEmpty(e => go(e))));

@@ -164,10 +171,12 @@ return fc => {

let output = fc.tuple(...elements.map(arb => arb(fc)));
if (elements.length > 0 && Option__namespace.isNone(rest)) {
const firstOptionalIndex = ast.elements.findIndex(e => e.isOptional);
if (firstOptionalIndex !== -1) {
output = output.chain(as => fc.integer({
min: firstOptionalIndex,
max: elements.length - 1
}).map(i => as.slice(0, i)));
}
if (hasOptionals) {
const indexes = fc.tuple(...ast.elements.map(element => element.isOptional ? fc.boolean() : fc.constant(true)));
output = output.chain(tuple => indexes.map(booleans => {
for (const [i, b] of booleans.reverse().entries()) {
if (!b) {
tuple.splice(booleans.length - i, 1);
}
}
return tuple;
}));
}

@@ -174,0 +183,0 @@

@@ -156,3 +156,10 @@ 'use strict';

{
const elements = ast.elements.map(e => go(e.type));
const elements = [];
let hasOptionals = false;
for (const element of ast.elements) {
elements.push(go(element.type));
if (element.isOptional) {
hasOptionals = true;
}
}
const rest = Function.pipe(ast.rest, Option__namespace.map(ReadonlyArray__namespace.mapNonEmpty(e => go(e))));

@@ -164,10 +171,12 @@ return fc => {

let output = fc.tuple(...elements.map(arb => arb(fc)));
if (elements.length > 0 && Option__namespace.isNone(rest)) {
const firstOptionalIndex = ast.elements.findIndex(e => e.isOptional);
if (firstOptionalIndex !== -1) {
output = output.chain(as => fc.integer({
min: firstOptionalIndex,
max: elements.length - 1
}).map(i => as.slice(0, i)));
}
if (hasOptionals) {
const indexes = fc.tuple(...ast.elements.map(element => element.isOptional ? fc.boolean() : fc.constant(true)));
output = output.chain(tuple => indexes.map(booleans => {
for (const [i, b] of booleans.reverse().entries()) {
if (!b) {
tuple.splice(booleans.length - i, 1);
}
}
return tuple;
}));
}

@@ -174,0 +183,0 @@

@@ -116,3 +116,10 @@ import { pipe } from 'effect/Function';

{
const elements = ast.elements.map(e => go(e.type));
const elements = [];
let hasOptionals = false;
for (const element of ast.elements) {
elements.push(go(element.type));
if (element.isOptional) {
hasOptionals = true;
}
}
const rest = pipe(ast.rest, Option.map(ReadonlyArray.mapNonEmpty(e => go(e))));

@@ -124,10 +131,12 @@ return fc => {

let output = fc.tuple(...elements.map(arb => arb(fc)));
if (elements.length > 0 && Option.isNone(rest)) {
const firstOptionalIndex = ast.elements.findIndex(e => e.isOptional);
if (firstOptionalIndex !== -1) {
output = output.chain(as => fc.integer({
min: firstOptionalIndex,
max: elements.length - 1
}).map(i => as.slice(0, i)));
}
if (hasOptionals) {
const indexes = fc.tuple(...ast.elements.map(element => element.isOptional ? fc.boolean() : fc.constant(true)));
output = output.chain(tuple => indexes.map(booleans => {
for (const [i, b] of booleans.reverse().entries()) {
if (!b) {
tuple.splice(booleans.length - i, 1);
}
}
return tuple;
}));
}

@@ -134,0 +143,0 @@

{
"name": "@effect/schema",
"version": "0.45.0",
"version": "0.45.1",
"publishConfig": {

@@ -5,0 +5,0 @@ "access": "public"

@@ -130,3 +130,10 @@ /**

case "Tuple": {
const elements = ast.elements.map((e) => go(e.type))
const elements: Array<Arbitrary<any>> = []
let hasOptionals = false
for (const element of ast.elements) {
elements.push(go(element.type))
if (element.isOptional) {
hasOptionals = true
}
}
const rest = pipe(ast.rest, Option.map(ReadonlyArray.mapNonEmpty((e) => go(e))))

@@ -138,11 +145,16 @@ return (fc) => {

let output = fc.tuple(...elements.map((arb) => arb(fc)))
if (elements.length > 0 && Option.isNone(rest)) {
const firstOptionalIndex = ast.elements.findIndex((e) => e.isOptional)
if (firstOptionalIndex !== -1) {
output = output.chain((as) =>
fc.integer({ min: firstOptionalIndex, max: elements.length - 1 }).map((i) =>
as.slice(0, i)
)
)
}
if (hasOptionals) {
const indexes = fc.tuple(
...ast.elements.map((element) => element.isOptional ? fc.boolean() : fc.constant(true))
)
output = output.chain((tuple) =>
indexes.map((booleans) => {
for (const [i, b] of booleans.reverse().entries()) {
if (!b) {
tuple.splice(booleans.length - i, 1)
}
}
return tuple
})
)
}

@@ -149,0 +161,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