@thisisagile/easy
Advanced tools
Comparing version 1.15.0 to 1.15.1
@@ -5,3 +5,3 @@ import { Converter } from './Converter'; | ||
default?: T; | ||
converter?: Converter<any, T>; | ||
converter?: Converter; | ||
}; | ||
@@ -11,3 +11,3 @@ export declare const isColumn: (p: unknown) => p is Column<unknown>; | ||
default?: T; | ||
converter?: Converter<T, unknown>; | ||
converter?: Converter; | ||
}) => Column<T>; |
@@ -7,3 +7,3 @@ export declare class Converter<From = unknown, To = unknown> { | ||
export declare const convert: { | ||
default: Converter<any, any>; | ||
default: Converter<unknown, unknown>; | ||
toBool: { | ||
@@ -10,0 +10,0 @@ fromNumber: Converter<boolean, number>; |
@@ -6,3 +6,3 @@ "use strict"; | ||
const Column_1 = require("./Column"); | ||
const clone = (subject, key, name, def, convert = (x) => x) => { | ||
const clone = (subject, key, name, def, convert) => { | ||
var _a; | ||
@@ -9,0 +9,0 @@ if (key === name) |
{ | ||
"name": "@thisisagile/easy", | ||
"version": "1.15.0", | ||
"version": "1.15.1", | ||
"description": "Straightforward library for building domain-driven microservice architectures", | ||
@@ -5,0 +5,0 @@ "author": "Sander Hoogendoorn", |
import { convert, Converter } from './Converter'; | ||
import { isA } from '../types'; | ||
export type Column<T = unknown> = { name: string; default?: T; converter?: Converter<any, T> }; | ||
export type Column<T = unknown> = { name: string; default?: T; converter?: Converter }; | ||
export const isColumn = (p: unknown): p is Column => isA<Column>(p, 'name', 'converter'); | ||
export const col = <T>(name: string, options?: { default?: T; converter?: Converter<T> }): Column<T> => ({ | ||
export const col = <T>(name: string, options?: { default?: T; converter?: Converter }): Column<T> => ({ | ||
name, | ||
@@ -9,0 +9,0 @@ default: options?.default, |
@@ -6,3 +6,3 @@ export class Converter<From = unknown, To = unknown> { | ||
export const convert = { | ||
default: new Converter<any, any>( | ||
default: new Converter( | ||
a => a, | ||
@@ -9,0 +9,0 @@ a => a |
import { isDefined, Json, List, meta } from '../types'; | ||
import { Column, isColumn } from './Column'; | ||
const clone = (subject: any, key: string, name: string, def: any, convert = (x: any) => x): any => { | ||
const clone = (subject: any, key: string, name: string, def: unknown, convert: (x: unknown) => unknown): Json => { | ||
if (key === name) return subject; | ||
@@ -6,0 +6,0 @@ const value = subject[name] ?? def; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
160284