typedconverter
Advanced tools
Comparing version 1.0.0-alpha.0 to 1.0.0-alpha.1
@@ -1,3 +0,6 @@ | ||
declare type ConverterMap = Map<Function, Converter>; | ||
declare type Converter = (value: any, path: string[], expectedType: Function | Function[], converters: ConverterMap) => any; | ||
interface ConverterMap { | ||
key: Function; | ||
converter: Converter; | ||
} | ||
declare type Converter = (value: any, path: string[], expectedType: Function | Function[], converters: Map<Function, Converter>) => any; | ||
declare class ConversionError extends Error { | ||
@@ -18,13 +21,10 @@ issues: { | ||
function dateConverter(rawValue: {}, path: string[]): Date; | ||
function modelConverter(value: {}, path: string[], expectedType: Function | Function[], converters: ConverterMap): any; | ||
function arrayConverter(value: {}[], path: string[], expectedType: Function[], converters: ConverterMap): any; | ||
function modelConverter(value: {}, path: string[], expectedType: Function | Function[], converters: Map<Function, Converter>): any; | ||
function arrayConverter(value: {}[], path: string[], expectedType: Function[], converters: Map<Function, Converter>): any; | ||
} | ||
declare function converter(option?: { | ||
type?: Function | Function[]; | ||
converters?: { | ||
key: Function; | ||
converter: Converter; | ||
}[]; | ||
converters?: ConverterMap[]; | ||
}): (value: any, type?: Function | Function[] | undefined, path?: string[]) => any; | ||
export { Converter, DefaultConverters, ConverterMap, ConversionError }; | ||
export default converter; |
@@ -18,3 +18,3 @@ "use strict"; | ||
function createConversionError(value, typ, path) { | ||
const typeName = Array.isArray(typ) ? `Array<${typ[0].name}>` : typ; | ||
const typeName = Array.isArray(typ) ? `Array<${typ[0].name}>` : typ.name; | ||
return new ConversionError({ path: path, messages: [`Unable to convert "${value}" into ${typeName}`] }); | ||
@@ -21,0 +21,0 @@ } |
{ | ||
"name": "typedconverter", | ||
"version": "1.0.0-alpha.0", | ||
"version": "1.0.0-alpha.1", | ||
"description": "Convert object into classes match with TypeScript type annotation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
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
11691