Comparing version 1.6.2 to 1.6.3
@@ -17,2 +17,7 @@ # Changelog | ||
# 1.6.3 | ||
- **Bug Fix** | ||
- prevent maximum call stack size exceeded when indexing recursive codecs, closes #259 (@gcanti) | ||
# 1.6.2 | ||
@@ -19,0 +24,0 @@ |
@@ -91,3 +91,3 @@ import { Either } from 'fp-ts/lib/Either'; | ||
export declare class Type<A, O = A, I = unknown> implements Decoder<I, A>, Encoder<A, O> { | ||
/** a unique name for this runtime type */ | ||
/** a unique name for this codec */ | ||
readonly name: string; | ||
@@ -104,3 +104,3 @@ /** a custom type guard */ | ||
constructor( | ||
/** a unique name for this runtime type */ | ||
/** a unique name for this codec */ | ||
name: string, | ||
@@ -130,3 +130,3 @@ /** a custom type guard */ | ||
*/ | ||
export declare const getContextEntry: (key: string, type: Decoder<any, any>) => ContextEntry; | ||
export declare const getContextEntry: (key: string, decoder: Decoder<any, any>) => ContextEntry; | ||
/** | ||
@@ -139,7 +139,7 @@ * @since 1.0.0 | ||
*/ | ||
export declare const getDefaultContext: (type: Decoder<any, any>) => Context; | ||
export declare const getDefaultContext: (decoder: Decoder<any, any>) => Context; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
export declare const appendContext: (c: Context, key: string, type: Decoder<any, any>) => Context; | ||
export declare const appendContext: (c: Context, key: string, decoder: Decoder<any, any>) => Context; | ||
/** | ||
@@ -380,3 +380,3 @@ * @since 1.0.0 | ||
*/ | ||
export declare const refinement: <C extends Any>(type: C, predicate: Predicate<C["_A"]>, name?: string) => RefinementC<C>; | ||
export declare const refinement: <C extends Any>(codec: C, predicate: Predicate<C["_A"]>, name?: string) => RefinementC<C>; | ||
/** | ||
@@ -433,2 +433,4 @@ * @since 1.0.0 | ||
readonly _tag: 'RecursiveType'; | ||
/** @internal */ | ||
getIndexRecord: () => IndexRecord; | ||
constructor(name: string, is: RecursiveType<C, A, O, I>['is'], validate: RecursiveType<C, A, O, I>['validate'], encode: RecursiveType<C, A, O, I>['encode'], runDefinition: () => C); | ||
@@ -457,3 +459,3 @@ readonly type: C; | ||
*/ | ||
export declare const array: <C extends Mixed>(type: C, name?: string) => ArrayC<C>; | ||
export declare const array: <C extends Mixed>(codec: C, name?: string) => ArrayC<C>; | ||
/** | ||
@@ -658,3 +660,3 @@ * @since 1.0.0 | ||
*/ | ||
export declare const readonly: <C extends Mixed>(type: C, name?: string) => ReadonlyC<C>; | ||
export declare const readonly: <C extends Mixed>(codec: C, name?: string) => ReadonlyC<C>; | ||
/** | ||
@@ -676,3 +678,3 @@ * @since 1.0.0 | ||
*/ | ||
export declare const readonlyArray: <C extends Mixed>(type: C, name?: string) => ReadonlyArrayC<C>; | ||
export declare const readonlyArray: <C extends Mixed>(codec: C, name?: string) => ReadonlyArrayC<C>; | ||
/** | ||
@@ -735,3 +737,4 @@ * @since 1.0.0 | ||
export declare type Tagged<Tag extends string, A = any, O = A> = InterfaceType<TaggedProps<Tag>, A, O> | StrictType<TaggedProps<Tag>, A, O> | TaggedRefinement<Tag, A, O> | TaggedUnion<Tag, A, O> | TaggedIntersection<Tag, A, O> | TaggedExact<Tag, A, O> | RecursiveType<any, A, O>; | ||
declare type Index = Array<[unknown, Mixed]>; | ||
interface Index extends Array<[unknown, Mixed]> { | ||
} | ||
interface IndexRecord extends Record<string, Index> { | ||
@@ -794,9 +797,9 @@ } | ||
*/ | ||
export declare function exact<C extends HasProps>(type: C, name?: string): ExactC<C>; | ||
export declare function exact<C extends HasProps>(codec: C, name?: string): ExactC<C>; | ||
/** | ||
* Drops the runtime type "kind" | ||
* Drops the codec "kind" | ||
* @since 1.1.0 | ||
* @deprecated | ||
*/ | ||
export declare function clean<A, O = A, I = unknown>(type: Type<A, O, I>): Type<A, O, I>; | ||
export declare function clean<A, O = A, I = unknown>(codec: Type<A, O, I>): Type<A, O, I>; | ||
/** | ||
@@ -823,9 +826,9 @@ * @since 1.0.0 | ||
/** | ||
* Keeps the runtime type "kind" | ||
* Keeps the codec "kind" | ||
* @since 1.1.0 | ||
* @deprecated | ||
*/ | ||
export declare function alias<A, O, P, I>(type: PartialType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => PartialType<PP, AA, OO, II>; | ||
export declare function alias<A, O, P, I>(type: StrictType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => StrictType<PP, AA, OO, II>; | ||
export declare function alias<A, O, P, I>(type: InterfaceType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => InterfaceType<PP, AA, OO, II>; | ||
export declare function alias<A, O, P, I>(codec: PartialType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => PartialType<PP, AA, OO, II>; | ||
export declare function alias<A, O, P, I>(codec: StrictType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => StrictType<PP, AA, OO, II>; | ||
export declare function alias<A, O, P, I>(codec: InterfaceType<P, A, O, I>): <AA extends Exact<A, AA>, OO extends Exact<O, OO> = O, PP extends Exact<P, PP> = P, II extends I = I>() => InterfaceType<PP, AA, OO, II>; | ||
export { nullType as null, undefinedType as undefined, arrayType as Array, type as interface, voidType as void }; |
242
lib/index.js
@@ -33,3 +33,3 @@ "use strict"; | ||
function Type( | ||
/** a unique name for this runtime type */ | ||
/** a unique name for this codec */ | ||
name, | ||
@@ -86,3 +86,3 @@ /** a custom type guard */ | ||
*/ | ||
exports.getContextEntry = function (key, type) { return ({ key: key, type: type }); }; | ||
exports.getContextEntry = function (key, decoder) { return ({ key: key, type: decoder }); }; | ||
/** | ||
@@ -95,7 +95,7 @@ * @since 1.0.0 | ||
*/ | ||
exports.getDefaultContext = function (type) { return [{ key: '', type: type }]; }; | ||
exports.getDefaultContext = function (decoder) { return [{ key: '', type: decoder }]; }; | ||
/** | ||
* @since 1.0.0 | ||
*/ | ||
exports.appendContext = function (c, key, type) { | ||
exports.appendContext = function (c, key, decoder) { | ||
var len = c.length; | ||
@@ -106,3 +106,3 @@ var r = Array(len + 1); | ||
} | ||
r[len] = { key: key, type: type }; | ||
r[len] = { key: key, type: decoder }; | ||
return r; | ||
@@ -130,2 +130,13 @@ }; | ||
}; | ||
var getIsCodec = function (tag) { return function (codec) { return codec._tag === tag; }; }; | ||
var isUnknownCodec = getIsCodec('UnknownType'); | ||
var isAnyCodec = getIsCodec('AnyType'); | ||
var isLiteralCodec = getIsCodec('LiteralType'); | ||
var isInterfaceCodec = getIsCodec('InterfaceType'); | ||
var isStrictCodec = getIsCodec('StrictType'); | ||
var isIntersectionCodec = getIsCodec('IntersectionType'); | ||
var isUnionCodec = getIsCodec('UnionType'); | ||
var isExactCodec = getIsCodec('ExactType'); | ||
var isRefinementCodec = getIsCodec('RefinementType'); | ||
var isRecursiveCodec = getIsCodec('RecursiveType'); | ||
// | ||
@@ -379,6 +390,6 @@ // basic types | ||
*/ | ||
exports.refinement = function (type, predicate, name) { | ||
if (name === void 0) { name = "(" + type.name + " | " + exports.getFunctionName(predicate) + ")"; } | ||
return new RefinementType(name, function (u) { return type.is(u) && predicate(u); }, function (i, c) { | ||
var validation = type.validate(i, c); | ||
exports.refinement = function (codec, predicate, name) { | ||
if (name === void 0) { name = "(" + codec.name + " | " + exports.getFunctionName(predicate) + ")"; } | ||
return new RefinementType(name, function (u) { return codec.is(u) && predicate(u); }, function (i, c) { | ||
var validation = codec.validate(i, c); | ||
if (validation.isLeft()) { | ||
@@ -391,3 +402,3 @@ return validation; | ||
} | ||
}, type.encode, type, predicate); | ||
}, codec.encode, codec, predicate); | ||
}; | ||
@@ -478,2 +489,11 @@ /** | ||
var Self = new RecursiveType(name, function (u) { return runDefinition().is(u); }, function (u, c) { return runDefinition().validate(u, c); }, function (a) { return runDefinition().encode(a); }, runDefinition); | ||
var indexRecordCache; | ||
Self.getIndexRecord = function () { | ||
if (!indexRecordCache) { | ||
isRecursiveCodecIndexable = false; | ||
indexRecordCache = getCodecIndexRecord(definition(Self), Self); | ||
isRecursiveCodecIndexable = true; | ||
} | ||
return indexRecordCache; | ||
}; | ||
return Self; | ||
@@ -498,5 +518,5 @@ }; | ||
*/ | ||
exports.array = function (type, name) { | ||
if (name === void 0) { name = "Array<" + type.name + ">"; } | ||
return new ArrayType(name, function (u) { return arrayType.is(u) && u.every(type.is); }, function (u, c) { | ||
exports.array = function (codec, name) { | ||
if (name === void 0) { name = "Array<" + codec.name + ">"; } | ||
return new ArrayType(name, function (u) { return arrayType.is(u) && u.every(codec.is); }, function (u, c) { | ||
var arrayValidation = arrayType.validate(u, c); | ||
@@ -513,3 +533,3 @@ if (arrayValidation.isLeft()) { | ||
var x = xs[i]; | ||
var validation = type.validate(x, exports.appendContext(c, String(i), type)); | ||
var validation = codec.validate(x, exports.appendContext(c, String(i), codec)); | ||
if (validation.isLeft()) { | ||
@@ -530,3 +550,3 @@ pushAll(errors, validation.value); | ||
} | ||
}, type.encode === exports.identity ? exports.identity : function (a) { return a.map(type.encode); }, type); | ||
}, codec.encode === exports.identity ? exports.identity : function (a) { return a.map(codec.encode); }, codec); | ||
}; | ||
@@ -727,4 +747,2 @@ /** | ||
exports.DictionaryType = DictionaryType; | ||
var isUnknownType = function (type) { return type._tag === 'UnknownType'; }; | ||
var isAnyType = function (type) { return type._tag === 'AnyType'; }; | ||
var isObject = function (r) { return Object.prototype.toString.call(r) === '[object Object]'; }; | ||
@@ -740,3 +758,3 @@ /** | ||
} | ||
if (!isUnknownType(codomain) && !isAnyType(codomain) && !isObject(u)) { | ||
if (!isUnknownCodec(codomain) && !isAnyCodec(codomain) && !isObject(u)) { | ||
return false; | ||
@@ -752,3 +770,3 @@ } | ||
var o = dictionaryValidation.value; | ||
if (!isUnknownType(codomain) && !isAnyType(codomain) && !isObject(o)) { | ||
if (!isUnknownCodec(codomain) && !isAnyCodec(codomain) && !isObject(o)) { | ||
return exports.failure(u, c); | ||
@@ -830,28 +848,30 @@ } | ||
} | ||
var len = types.length; | ||
return new UnionType(name, function (u) { return types.some(function (type) { return type.is(u); }); }, function (u, c) { | ||
var errors = []; | ||
for (var i = 0; i < len; i++) { | ||
var type_3 = types[i]; | ||
var validation = type_3.validate(u, exports.appendContext(c, String(i), type_3)); | ||
if (validation.isRight()) { | ||
return validation; | ||
else { | ||
var len_1 = types.length; | ||
return new UnionType(name, function (u) { return types.some(function (type) { return type.is(u); }); }, function (u, c) { | ||
var errors = []; | ||
for (var i = 0; i < len_1; i++) { | ||
var type_3 = types[i]; | ||
var validation = type_3.validate(u, exports.appendContext(c, String(i), type_3)); | ||
if (validation.isRight()) { | ||
return validation; | ||
} | ||
else { | ||
pushAll(errors, validation.value); | ||
} | ||
} | ||
else { | ||
pushAll(errors, validation.value); | ||
} | ||
} | ||
return errors.length ? exports.failures(errors) : exports.failure(u, c); | ||
}, useIdentity(types, len) | ||
? exports.identity | ||
: function (a) { | ||
var i = 0; | ||
for (; i < len - 1; i++) { | ||
var type_4 = types[i]; | ||
if (type_4.is(a)) { | ||
return type_4.encode(a); | ||
return errors.length ? exports.failures(errors) : exports.failure(u, c); | ||
}, useIdentity(types, len_1) | ||
? exports.identity | ||
: function (a) { | ||
var i = 0; | ||
for (; i < len_1 - 1; i++) { | ||
var type_4 = types[i]; | ||
if (type_4.is(a)) { | ||
return type_4.encode(a); | ||
} | ||
} | ||
} | ||
return types[i].encode(a); | ||
}, types); | ||
return types[i].encode(a); | ||
}, types); | ||
} | ||
}; | ||
@@ -970,6 +990,6 @@ /** | ||
*/ | ||
exports.readonly = function (type, name) { | ||
if (name === void 0) { name = "Readonly<" + type.name + ">"; } | ||
return new ReadonlyType(name, type.is, function (u, c) { | ||
return type.validate(u, c).map(function (x) { | ||
exports.readonly = function (codec, name) { | ||
if (name === void 0) { name = "Readonly<" + codec.name + ">"; } | ||
return new ReadonlyType(name, codec.is, function (u, c) { | ||
return codec.validate(u, c).map(function (x) { | ||
if (process.env.NODE_ENV !== 'production') { | ||
@@ -980,3 +1000,3 @@ return Object.freeze(x); | ||
}); | ||
}, type.encode === exports.identity ? exports.identity : type.encode, type); | ||
}, codec.encode === exports.identity ? exports.identity : codec.encode, codec); | ||
}; | ||
@@ -1000,5 +1020,5 @@ /** | ||
*/ | ||
exports.readonlyArray = function (type, name) { | ||
if (name === void 0) { name = "ReadonlyArray<" + type.name + ">"; } | ||
var arrayType = exports.array(type); | ||
exports.readonlyArray = function (codec, name) { | ||
if (name === void 0) { name = "ReadonlyArray<" + codec.name + ">"; } | ||
var arrayType = exports.array(codec); | ||
return new ReadonlyArrayType(name, arrayType.is, function (u, c) { | ||
@@ -1013,3 +1033,3 @@ return arrayType.validate(u, c).map(function (x) { | ||
}); | ||
}, arrayType.encode, type); | ||
}, arrayType.encode, codec); | ||
}; | ||
@@ -1040,17 +1060,40 @@ /** | ||
}; | ||
var isLiteralCodec = function (codec) { return codec._tag === 'LiteralType'; }; | ||
var isInterfaceCodec = function (codec) { return codec._tag === 'InterfaceType'; }; | ||
var isStrictCodec = function (codec) { return codec._tag === 'StrictType'; }; | ||
var isIntersectionCodec = function (codec) { | ||
return codec._tag === 'IntersectionType'; | ||
var monoidIndexRecord = { | ||
concat: function (a, b) { | ||
var _a; | ||
if (a === monoidIndexRecord.empty) { | ||
return b; | ||
} | ||
else if (b === monoidIndexRecord.empty) { | ||
return a; | ||
} | ||
else { | ||
var r = cloneIndexRecord(a); | ||
for (var k in b) { | ||
if (r.hasOwnProperty(k)) { | ||
(_a = r[k]).push.apply(_a, b[k]); | ||
} | ||
else { | ||
r[k] = b[k]; | ||
} | ||
} | ||
return r; | ||
} | ||
}, | ||
empty: {} | ||
}; | ||
var isUnionCodec = function (codec) { return codec._tag === 'UnionType'; }; | ||
var isExactCodec = function (codec) { return codec._tag === 'ExactType'; }; | ||
var isRefinementCodec = function (codec) { return codec._tag === 'RefinementType'; }; | ||
var isRecursiveCodec = function (codec) { return codec._tag === 'RecursiveType'; }; | ||
var foldMapIndexRecord = function (as, f) { | ||
return as.reduce(function (acc, a) { return monoidIndexRecord.concat(acc, f(a)); }, monoidIndexRecord.empty); | ||
}; | ||
var cloneIndexRecord = function (a) { | ||
var r = {}; | ||
for (var k in a) { | ||
r[k] = a[k].slice(); | ||
} | ||
return r; | ||
}; | ||
var getCodecIndexRecord = function (codec, override) { | ||
if (override === void 0) { override = codec; } | ||
var _a; | ||
var ir = {}; | ||
if (isInterfaceCodec(codec) || isStrictCodec(codec)) { | ||
var interfaceIndex = {}; | ||
for (var k in codec.props) { | ||
@@ -1060,20 +1103,9 @@ var prop = codec.props[k]; | ||
var value = prop.value; | ||
ir[k] = [[value, override]]; | ||
interfaceIndex[k] = [[value, override]]; | ||
} | ||
} | ||
return interfaceIndex; | ||
} | ||
else if (isIntersectionCodec(codec)) { | ||
var types = codec.types; | ||
ir = getCodecIndexRecord(types[0], codec); | ||
for (var i = 1; i < types.length; i++) { | ||
var cir = getCodecIndexRecord(types[i], codec); | ||
for (var k in cir) { | ||
if (ir.hasOwnProperty(k)) { | ||
(_a = ir[k]).push.apply(_a, cir[k]); | ||
} | ||
else { | ||
ir[k] = cir[k]; | ||
} | ||
} | ||
} | ||
return foldMapIndexRecord(codec.types, function (type) { return getCodecIndexRecord(type, codec); }); | ||
} | ||
@@ -1087,6 +1119,9 @@ else if (isUnionCodec(codec)) { | ||
else if (isRecursiveCodec(codec)) { | ||
return getCodecIndexRecord(codec.type, codec); | ||
return codec.getIndexRecord(); | ||
} | ||
return ir; | ||
else { | ||
return monoidIndexRecord.empty; | ||
} | ||
}; | ||
var isRecursiveCodecIndexable = true; | ||
var isIndexableCodec = function (codec) { | ||
@@ -1098,3 +1133,3 @@ return (((isInterfaceCodec(codec) || isStrictCodec(codec)) && | ||
(isUnionCodec(codec) && codec.types.every(isIndexableCodec)) || | ||
isRecursiveCodec(codec)); | ||
(isRecursiveCodecIndexable && isRecursiveCodec(codec))); | ||
}; | ||
@@ -1109,3 +1144,3 @@ /** | ||
} | ||
var ir = getCodecIndexRecord(types[0]); | ||
var ir = cloneIndexRecord(getCodecIndexRecord(types[0])); | ||
for (var i = 1; i < len; i++) { | ||
@@ -1205,11 +1240,8 @@ var cir = getCodecIndexRecord(types[i]); | ||
if (!indexRecord.hasOwnProperty(tag)) { | ||
var message = "Cannot create a tagged union: " + name + " is not a tagged union with respect to \"" + tag + "\""; | ||
var candidates = Object.keys(indexRecord); | ||
if (candidates.length > 0) { | ||
message += ". Possible alternative candidates: " + JSON.stringify(candidates); | ||
} | ||
throw new Error(message); | ||
var U = exports.union(types, name); | ||
return new TaggedUnionType(name, U.is, U.validate, U.encode, types, tag); | ||
} | ||
var index = indexRecord[tag]; | ||
return taggedUnionWithIndex(index, tag, types, name); | ||
else { | ||
return taggedUnionWithIndex(indexRecord[tag], tag, types, name); | ||
} | ||
}; | ||
@@ -1230,13 +1262,13 @@ /** | ||
exports.ExactType = ExactType; | ||
var getProps = function (type) { | ||
switch (type._tag) { | ||
var getProps = function (codec) { | ||
switch (codec._tag) { | ||
case 'RefinementType': | ||
case 'ReadonlyType': | ||
return getProps(type.type); | ||
return getProps(codec.type); | ||
case 'InterfaceType': | ||
case 'StrictType': | ||
case 'PartialType': | ||
return type.props; | ||
return codec.props; | ||
case 'IntersectionType': | ||
return type.types.reduce(function (props, type) { return Object.assign(props, getProps(type)); }, {}); | ||
return codec.types.reduce(function (props, type) { return Object.assign(props, getProps(type)); }, {}); | ||
} | ||
@@ -1247,7 +1279,7 @@ }; | ||
*/ | ||
function exact(type, name) { | ||
if (name === void 0) { name = "ExactType<" + type.name + ">"; } | ||
var props = getProps(type); | ||
return new ExactType(name, function (u) { return type.is(u) && Object.getOwnPropertyNames(u).every(function (k) { return hasOwnProperty.call(props, k); }); }, function (u, c) { | ||
var looseValidation = type.validate(u, c); | ||
function exact(codec, name) { | ||
if (name === void 0) { name = "ExactType<" + codec.name + ">"; } | ||
var props = getProps(codec); | ||
return new ExactType(name, function (u) { return codec.is(u) && Object.getOwnPropertyNames(u).every(function (k) { return hasOwnProperty.call(props, k); }); }, function (u, c) { | ||
var looseValidation = codec.validate(u, c); | ||
if (looseValidation.isLeft()) { | ||
@@ -1269,17 +1301,17 @@ return looseValidation; | ||
} | ||
}, type.encode, type); | ||
}, codec.encode, codec); | ||
} | ||
exports.exact = exact; | ||
/** | ||
* Drops the runtime type "kind" | ||
* Drops the codec "kind" | ||
* @since 1.1.0 | ||
* @deprecated | ||
*/ | ||
function clean(type) { | ||
return type; | ||
function clean(codec) { | ||
return codec; | ||
} | ||
exports.clean = clean; | ||
function alias(type) { | ||
return function () { return type; }; | ||
function alias(codec) { | ||
return function () { return codec; }; | ||
} | ||
exports.alias = alias; |
{ | ||
"name": "io-ts", | ||
"version": "1.6.2", | ||
"version": "1.6.3", | ||
"description": "TypeScript compatible runtime type system for IO validation", | ||
@@ -5,0 +5,0 @@ "files": [ |
@@ -10,5 +10,5 @@ [![build status](https://img.shields.io/travis/gcanti/io-ts/master.svg?style=flat-square)](https://travis-ci.org/gcanti/io-ts) | ||
A value of type `Type<A, O, I>` (called "runtime type") is the runtime representation of the static type `A`. | ||
A value of type `Type<A, O, I>` (called "codec") is the runtime representation of the static type `A`. | ||
Also a runtime type can | ||
Also a codec can | ||
@@ -27,3 +27,3 @@ - decode inputs of type `I` (through `decode`) | ||
constructor( | ||
/** a unique name for this runtime type */ | ||
/** a unique name for this codec */ | ||
readonly name: string, | ||
@@ -47,3 +47,3 @@ /** a custom type guard */ | ||
A runtime type representing `string` can be defined as | ||
A codec representing `string` can be defined as | ||
@@ -53,3 +53,3 @@ ```ts | ||
// runtime type definition | ||
// codec definition | ||
export class StringType extends t.Type<string> { | ||
@@ -68,7 +68,7 @@ // equivalent to Type<string, string, mixed> as per type parameter defaults | ||
// runtime type instance: use this when building other runtime types instances | ||
// codec instance: use this when building other codecs instances | ||
export const string = new StringType() | ||
``` | ||
A runtime type can be used to validate an object in memory (for example an API payload) | ||
A codec can be used to validate an object in memory (for example an API payload) | ||
@@ -157,6 +157,6 @@ ```ts | ||
- [io-ts-types](https://github.com/gcanti/io-ts-types) - A collection of runtime types and combinators for use with | ||
- [io-ts-types](https://github.com/gcanti/io-ts-types) - A collection of codecs and combinators for use with | ||
io-ts | ||
- [io-ts-reporters](https://github.com/OliverJAsh/io-ts-reporters) - Error reporters for io-ts | ||
- [geojson-iots](https://github.com/pierremarc/geojson-iots) - Runtime types for GeoJSON as defined in rfc7946 made with | ||
- [geojson-iots](https://github.com/pierremarc/geojson-iots) - codecs for GeoJSON as defined in rfc7946 made with | ||
io-ts | ||
@@ -168,3 +168,3 @@ - [graphql-to-io-ts](https://github.com/micimize/graphql-to-io-ts) - Generate typescript and cooresponding io-ts types from a graphql | ||
Runtime types can be inspected | ||
codecs can be inspected | ||
@@ -180,3 +180,3 @@ ![instrospection](docs/images/introspection.png) | ||
Static types can be extracted from runtime types using the `TypeOf` operator | ||
Static types can be extracted from codecs using the `TypeOf` operator | ||
@@ -199,3 +199,3 @@ ```ts | ||
| Type | TypeScript | Runtime type / combinator | | ||
| Type | TypeScript | codec / combinator | | ||
| ------------------------- | --------------------------------------- | ----------------------------------------------------- | | ||
@@ -312,3 +312,3 @@ | null | `null` | `t.null` or `t.nullType` | | ||
You can make a runtime type alias exact (which means that only the given properties are allowed) using the `exact` combinator | ||
You can make a codec alias exact (which means that only the given properties are allowed) using the `exact` combinator | ||
@@ -331,3 +331,3 @@ ```ts | ||
You can make a runtime type strict (which means that only the given properties are allowed) using the `strict` combinator | ||
You can make a codec strict (which means that only the given properties are allowed) using the `strict` combinator | ||
@@ -371,3 +371,3 @@ ```ts | ||
You can apply `partial` to an already defined runtime type via its `props` field | ||
You can apply `partial` to an already defined codec via its `props` field | ||
@@ -423,3 +423,3 @@ ```ts | ||
Polymorphic runtime types are represented using functions. | ||
Polymorphic codecs are represented using functions. | ||
For example, the following typescript: | ||
@@ -465,3 +465,3 @@ | ||
You can pipe two runtime types if their type parameters do align | ||
You can pipe two codecs if their type parameters do align | ||
@@ -468,0 +468,0 @@ ```ts |
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
99006
2196