@contember/typesafe
Advanced tools
Comparing version 1.3.0-alpha.7 to 1.3.0-alpha.8
@@ -57,2 +57,3 @@ declare type Unpacked<T> = T extends readonly (infer U)[] ? U : never; | ||
export declare const nullable: <T extends Json>(inner: Type<T>) => Type<T | null>; | ||
export declare const preprocess: <Input extends Json>(inner: Type<Input>, transform: (input: unknown) => unknown) => (input: unknown, path?: PropertyKey[]) => Input; | ||
export declare const transform: <Input extends Json, Result extends Json>(inner: Type<Input>, transform: (value: Input, input: unknown) => Result) => (input: unknown, path?: PropertyKey[]) => Result; | ||
@@ -59,0 +60,0 @@ export declare const coalesce: <T extends Json, F extends Json>(inner: Type<T>, fallback: F) => Type<T | F>; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.valueAt = exports.coalesce = exports.transform = exports.nullable = exports.false_ = exports.true_ = exports.null_ = exports.enumeration = exports.intersection = exports.discriminatedTupleUnion = exports.tuple = exports.discriminatedUnion = exports.partiallyDiscriminatedUnion = exports.union = exports.record = exports.noExtraProps = exports.partial = exports.object = exports.array = exports.literal = exports.anyJsonObject = exports.anyJson = exports.scalar = exports.boolean = exports.integer = exports.number = exports.string = exports.fail = exports.ParseError = void 0; | ||
exports.valueAt = exports.coalesce = exports.transform = exports.preprocess = exports.nullable = exports.false_ = exports.true_ = exports.null_ = exports.enumeration = exports.intersection = exports.discriminatedTupleUnion = exports.tuple = exports.discriminatedUnion = exports.partiallyDiscriminatedUnion = exports.union = exports.record = exports.noExtraProps = exports.partial = exports.object = exports.array = exports.literal = exports.anyJsonObject = exports.anyJson = exports.scalar = exports.boolean = exports.integer = exports.number = exports.string = exports.fail = exports.ParseError = void 0; | ||
class ParseError extends Error { | ||
@@ -334,2 +334,6 @@ constructor(path, reason, expected) { | ||
exports.nullable = nullable; | ||
const preprocess = (inner, transform) => (input, path = []) => { | ||
return inner(transform(input), path); | ||
}; | ||
exports.preprocess = preprocess; | ||
const transform = (inner, transform) => (input, path = []) => { | ||
@@ -336,0 +340,0 @@ return transform(inner(input, path), input); |
{ | ||
"name": "@contember/typesafe", | ||
"version": "1.3.0-alpha.7", | ||
"version": "1.3.0-alpha.8", | ||
"license": "Apache-2.0", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -380,2 +380,6 @@ type Unpacked<T> = T extends readonly (infer U)[] ? U : never | ||
export const preprocess = <Input extends Json>(inner: Type<Input>, transform: (input: unknown) => unknown) => (input: unknown, path: PropertyKey[] = []): Input => { | ||
return inner(transform(input), path) | ||
} | ||
export const transform = <Input extends Json, Result extends Json>(inner: Type<Input>, transform: (value: Input, input: unknown) => Result) => (input: unknown, path: PropertyKey[] = []): Result => { | ||
@@ -382,0 +386,0 @@ return transform(inner(input, path), input) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
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
77045
799