fast-check-io-ts
Advanced tools
Comparing version 0.1.1 to 0.2.0
import * as fc from 'fast-check'; | ||
import * as t from 'io-ts'; | ||
export declare type SupportedType = t.StringType | t.VoidType | t.ArrayType<any> | t.BooleanType | t.ExactType<any> | t.KeyofType<any> | t.NullType | t.TupleType<Array<t.Any>> | t.UnknownType | t.UndefinedType | t.LiteralType<string | number | boolean> | t.NumberType | t.InterfaceType<unknown> | t.PartialType<unknown> | t.UnionType<Array<any>> | t.RefinementType<t.Any>; | ||
export declare type SupportedType = t.StringType | t.VoidType | t.ArrayType<any> | t.BooleanType | t.ExactType<any> | t.KeyofType<any> | t.NullType | t.TupleType<Array<t.Any>> | t.UnknownType | t.UndefinedType | t.LiteralType<string | number | boolean> | t.NumberType | t.InterfaceType<unknown> | t.PartialType<unknown> | t.UnionType<Array<any>> | t.RefinementType<t.Any> | t.IntersectionType<Array<t.Any>>; | ||
export declare function getArbitrary<T extends t.Mixed>(codec: T): fc.Arbitrary<T['_A']>; |
@@ -6,2 +6,3 @@ "use strict"; | ||
var t = require("io-ts"); | ||
var objectTypes = ['ExactType', 'InterfaceType', 'PartialType']; | ||
function getArbitrary(codec) { | ||
@@ -42,2 +43,8 @@ var type = codec; | ||
return getArbitrary(type.type).filter(type.predicate); | ||
case 'IntersectionType': | ||
var isObjectIntersection = objectTypes.includes(type.types[0]._tag); | ||
return isObjectIntersection | ||
? fc.tuple.apply(fc, type.types.map(getArbitrary)).map(function (values) { return Object.assign.apply(Object, [{}].concat(values)); }) | ||
.filter(type.is) | ||
: fc.oneof.apply(fc, type.types.map(getArbitrary)).filter(type.is); | ||
} | ||
@@ -44,0 +51,0 @@ throw new Error("Codec not supported: " + codec); |
{ | ||
"name": "fast-check-io-ts", | ||
"version": "0.1.1", | ||
"version": "0.2.0", | ||
"description": "io-ts codec to fast-check arbitrary mapping", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4824
56