io-ts-fuzzer
Advanced tools
Comparing version 1.0.0 to 1.1.0
@@ -14,3 +14,5 @@ import * as t from 'io-ts'; | ||
export declare function fuzzString(n: number): string; | ||
export declare function fuzzUnion(b: t.UnionC<any>): ConcreteFuzzer<any>; | ||
export declare function fuzzUnion(b: t.UnionType<t.Any[]>): ConcreteFuzzer<any>; | ||
export declare function fuzzInterface(b: t.InterfaceType<t.Props>): ConcreteFuzzer<any>; | ||
export declare function fuzzPartial(b: t.PartialType<t.Props>): ConcreteFuzzer<any>; | ||
export declare const coreFuzzers: (Fuzzer<number, (t.Decoder<unknown, number> & t.NullType) | (t.Decoder<unknown, number> & t.UndefinedType) | (t.Decoder<unknown, number> & t.VoidType) | (t.Decoder<unknown, number> & t.UnknownType) | (t.Decoder<unknown, number> & t.StringType) | (t.Decoder<unknown, number> & t.NumberType) | (t.Decoder<unknown, number> & t.BooleanType) | (t.Decoder<unknown, number> & t.AnyArrayType) | (t.Decoder<unknown, number> & t.AnyDictionaryType) | (t.Decoder<unknown, number> & t.RefinementType<t.Any, any, any, unknown>) | (t.Decoder<unknown, number> & t.LiteralType<string | number | boolean>) | (t.Decoder<unknown, number> & t.KeyofType<{ | ||
@@ -22,2 +24,2 @@ [key: string]: unknown; | ||
[key: string]: unknown; | ||
}>) | (t.Decoder<unknown, string> & t.RecursiveType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.ArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.InterfaceType<any, any, any, unknown>) | (t.Decoder<unknown, string> & t.PartialType<any, any, any, unknown>) | (t.Decoder<unknown, string> & t.DictionaryType<t.Any, t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.UnionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, string> & t.TupleType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, string> & t.ReadonlyType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.ReadonlyArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.ExactType<t.Any, any, any, unknown>)> | Fuzzer<any, t.UnionC<any>>)[]; | ||
}>) | (t.Decoder<unknown, string> & t.RecursiveType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.ArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.InterfaceType<any, any, any, unknown>) | (t.Decoder<unknown, string> & t.PartialType<any, any, any, unknown>) | (t.Decoder<unknown, string> & t.DictionaryType<t.Any, t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.UnionType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, string> & t.TupleType<t.Any[], any, any, unknown>) | (t.Decoder<unknown, string> & t.ReadonlyType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.ReadonlyArrayType<t.Any, any, any, unknown>) | (t.Decoder<unknown, string> & t.ExactType<t.Any, any, any, unknown>)> | Fuzzer<any, t.UnionType<t.Any[], any, any, unknown>> | Fuzzer<any, t.InterfaceType<t.Props, any, any, unknown>> | Fuzzer<any, t.PartialType<t.Props, any, any, unknown>>)[]; |
@@ -47,2 +47,37 @@ "use strict"; | ||
exports.fuzzUnion = fuzzUnion; | ||
function fuzzInterface(b | ||
// tslint:disable-next-line:no-any | ||
) { | ||
const keys = Object.getOwnPropertyNames(b.props); | ||
const vals = keys.map(k => b.props[k]); | ||
return { | ||
children: vals, | ||
func: (n, ...h) => { | ||
const ret = Object.create(null); | ||
h.forEach((v, i) => { | ||
ret[keys[i]] = v.encode(n); | ||
}); | ||
return ret; | ||
}, | ||
}; | ||
} | ||
exports.fuzzInterface = fuzzInterface; | ||
// tslint:disable-next-line:no-any | ||
function fuzzPartial(b) { | ||
const keys = Object.getOwnPropertyNames(b.props); | ||
const vals = keys.map(k => b.props[k]); | ||
return { | ||
children: vals, | ||
func: (n, ...h) => { | ||
const ret = Object.create(null); | ||
h.forEach((v, i) => { | ||
if (n & (2 ** i)) { | ||
ret[keys[i]] = v.encode(n); | ||
} | ||
}); | ||
return ret; | ||
}, | ||
}; | ||
} | ||
exports.fuzzPartial = fuzzPartial; | ||
exports.coreFuzzers = [ | ||
@@ -53,3 +88,5 @@ concrete(fuzzNumber, 'NumberType'), | ||
gen(fuzzUnion, 'UnionType'), | ||
gen(fuzzInterface, 'InterfaceType'), | ||
gen(fuzzPartial, 'PartialType'), | ||
]; | ||
//# sourceMappingURL=core.js.map |
@@ -0,1 +1,8 @@ | ||
# [1.1.0](https://github.com/holvonix-open/io-ts-fuzzer/compare/v1.0.0...v1.1.0) (2019-08-03) | ||
### Features | ||
* support interfaces and partials ([9d7e0b0](https://github.com/holvonix-open/io-ts-fuzzer/commit/9d7e0b0)) | ||
# 1.0.0 (2019-08-03) | ||
@@ -2,0 +9,0 @@ |
{ | ||
"name": "io-ts-fuzzer", | ||
"version": "1.0.0", | ||
"version": "1.1.0", | ||
"description": "Fuzzing for io-ts codecs and types", | ||
@@ -5,0 +5,0 @@ "repository": { |
@@ -19,3 +19,3 @@ # io-ts-fuzzer - Fuzzing for io-ts codecs and types | ||
// Type to fuzz | ||
const target = t.union([t.string, t.number, t.boolean]); | ||
const target = t.union([t.string, t.type({n:t.number, b:t.boolean})]); | ||
@@ -33,3 +33,12 @@ // Builds a particular fuzzer from the registry. | ||
Currently supports: | ||
* `t.number` | ||
* `t.string` | ||
* `t.boolean` | ||
* `t.union` | ||
* `t.type` (interface) | ||
* `t.partial` | ||
## License | ||
@@ -36,0 +45,0 @@ |
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
35303
282
72